Skip to content

Commit

Permalink
Removed ids from registration db & removed advent from pyright except…
Browse files Browse the repository at this point in the history
…ion list
  • Loading branch information
49Indium committed Nov 29, 2023
1 parent fbe25a6 commit c8539ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ build-backend = "poetry.core.masonry.api"
[tool.pyright]
strict = ["**"]
exclude = [
"**/advent.py",
"**/bot.py",
"**/error_handler.py",
"**/events.py",
Expand Down
15 changes: 10 additions & 5 deletions uqcsbot/advent.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,21 +640,22 @@ async def register_command(self, interaction: discord.Interaction, aoc_name: str
@advent_command_group.command(name="register-force")
@app_commands.describe(
year="The year of Advent of Code this registration is for.",
discord_id="The discord ID number of the user. Note that this is not their username.",
discord_id_str="The discord ID number of the user. Note that this is not their username.",
aoc_name="The name shown on Advent of Code.",
aoc_id="The AOC id of the user.",
)
async def register_admin_command(
self,
interaction: discord.Interaction,
year: int,
discord_id: int,
discord_id_str: str, # str as discord can't handle integers this big
aoc_name: Optional[str] = None,
aoc_id: Optional[int] = None,
):
"""
Forces a registration entry to be created. For admin use only. Either aoc_name or aoc_id should be given.
"""
discord_id = int(discord_id_str)
if (aoc_name is None and aoc_id is None) or (
aoc_name is not None and aoc_id is not None
):
Expand Down Expand Up @@ -752,15 +753,16 @@ async def unregister_command(self, interaction: discord.Interaction):
@advent_command_group.command(name="unregister-force")
@app_commands.describe(
year="Year that the registration is for",
discord_id="The discord id to remove. Note that this is not the username.",
discord_id_str="The discord id to remove. Note that this is not the username.",
)
async def unregister_admin_command(
self, interaction: discord.Interaction, year: int, discord_id: int
self, interaction: discord.Interaction, year: int, discord_id_str: str
):
"""
Forces a registration entry to be removed.
For admin use only; assumes you know what you are doing.
"""
discord_id = int(discord_id_str)
await interaction.response.defer(thinking=True)
discord_user = self.bot.uqcs_server.get_member(discord_id)

Expand Down Expand Up @@ -930,6 +932,9 @@ async def add_winners_command(
content=f"There were not enough eligible users to select winners (at least {required_number_of_potential_winners} needed; only {len(potential_winners)} found)."
)
return
number_of_potential_winners = len(
potential_winners
) # potential winners will be changed ahead, so we store this value for the award message

match weights:
case "Stars":
Expand Down Expand Up @@ -977,7 +982,7 @@ async def add_winners_command(
winners_message += " and "

await interaction.edit_original_response(
content=f"The results are in! Out of {len(potential_winners)} potential participants, {winners_message} have recieved a prize from participating in Advent of Code: {prize}"
content=f"The results are in! Out of {number_of_potential_winners} potential participants, {winners_message} have recieved a prize from participating in Advent of Code: {prize}"
)

@app_commands.checks.has_permissions(manage_guild=True)
Expand Down
7 changes: 2 additions & 5 deletions uqcsbot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ class AOCWinners(Base):
class AOCRegistrations(Base):
__tablename__ = "aoc_registrations"

id: Mapped[int] = mapped_column(
"id", Integer, primary_key=True, nullable=False, autoincrement=True
discord_userid: Mapped[int] = mapped_column(
"discord_userid", BigInteger, primary_key=True, nullable=False
)
aoc_userid: Mapped[int] = mapped_column("aoc_userid", Integer, nullable=False)
year: Mapped[int] = mapped_column("year", Integer, nullable=False)
discord_userid: Mapped[int] = mapped_column(
"discord_userid", BigInteger, nullable=False
)


class MCWhitelist(Base):
Expand Down

0 comments on commit c8539ee

Please sign in to comment.