Clarify parameter name for users, correct id usage for autofills.

This commit is contained in:
alwayscompiling
2022-12-02 17:02:44 -05:00
parent bed07d440b
commit 52305c0107
4 changed files with 28 additions and 20 deletions
+17 -13
View File
@@ -57,7 +57,7 @@ class DataManagementCog(commands.Cog, name="Table Management"):
async def from_all(
self,
interaction: nextcord.Interaction,
username: str = nextcord.SlashOption(
user_name: str = nextcord.SlashOption(
description="User to remove scores for. Note: This is not always a user's discord name.", required=True
),
):
@@ -67,13 +67,13 @@ class DataManagementCog(commands.Cog, name="Table Management"):
Args:
interaction (nextcord.Interaction): Interaction that invoked the command.
username (str): User to remove from highscores
user_name (str): User to remove from highscores
"""
stmt = select(distinct(Score.CategoryId)).where(Score.UserName == username)
stmt = select(distinct(Score.CategoryId)).where(Score.UserName == user_name)
category_ids: "list[int]" = list(session.scalars(stmt))
stmt = select(Score).where(Score.UserName == username)
stmt = select(Score).where(Score.UserName == user_name)
for score in session.scalars(stmt):
session.delete(score)
session.commit()
@@ -85,14 +85,16 @@ class DataManagementCog(commands.Cog, name="Table Management"):
for group in session.scalars(stmt):
await send_highscore_message(interaction.guild.get_channel(group.ChannelId), group)
await interaction.send(f'User "{username}" was removed from all tables.')
await interaction.send(f'User "{user_name}" was removed from all tables.')
@user.subcommand(description="Deletes a user's scores from a category.")
async def from_category(
self,
interaction: nextcord.Interaction,
group_id: str = nextcord.SlashOption(description="Group to delete user from.", required=True),
category_id: str = nextcord.SlashOption(description="Category to delete user from.", required=True),
group_id: str = nextcord.SlashOption(name="Group", description="Group to delete user from.", required=True),
category_id: str = nextcord.SlashOption(
name="Category", description="Category to delete user from.", required=True
),
user_name: str = nextcord.SlashOption(description="User to delete.", required=True),
):
"""
@@ -124,7 +126,7 @@ class DataManagementCog(commands.Cog, name="Table Management"):
async def from_group(
self,
interaction: nextcord.Interaction,
group_id: str = nextcord.SlashOption(description="Group to delete user from.", required=True),
group_id: str = nextcord.SlashOption(name="Group", description="Group to delete user from.", required=True),
user_name: str = nextcord.SlashOption(description="User to delete.", required=True),
):
"""
@@ -150,13 +152,13 @@ class DataManagementCog(commands.Cog, name="Table Management"):
@from_category.on_autocomplete("group_id")
@from_group.on_autocomplete("group_id")
async def autocomplete_table(self, interaction: nextcord.Interaction, group_id: str):
async def autocomplete_group(self, interaction: nextcord.Interaction, group_id: str):
"""
Autocomplete function for table names.
Args:
interaction (nextcord.Interaction): Interaction that invoked the command.
group_id (str): String to be autocompleted with Table name.
group_id (str): String to be autocompleted with Group name.
"""
await interaction.response.send_autocomplete(autofill_groups(interaction.guild_id, group_id))
@@ -168,9 +170,11 @@ class DataManagementCog(commands.Cog, name="Table Management"):
Args:
interaction (nextcord.Interaction): Interaction that invoked the command.
category_id (str): String to be autocompleted with Category name.
group_id (str): Table to find Category from.
group_id (str): Group to find Category from.
"""
await interaction.response.send_autocomplete(autofill_categories(interaction.guild_id, group_id, category_id))
await interaction.response.send_autocomplete(
autofill_categories(interaction.guild_id, int(group_id), category_id)
)
@from_category.on_autocomplete("user_name")
@from_group.on_autocomplete("user_name")
@@ -220,7 +224,7 @@ class DataManagementCog(commands.Cog, name="Table Management"):
await interaction.send("Request sent to admins for verification.", ephemeral=True)
@update_username.on_autocomplete("old_username")
@from_all.on_autocomplete("username")
@from_all.on_autocomplete("user_name")
async def username_autofill(self, interaction: nextcord.Interaction, username: str):
"""
Sends response from autofill_users_in_guild back to update_username for autocompletion of old_username.