From 76fbba739f77f967fb9675ac87abb1368b45d5b5 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Tue, 11 Mar 2025 09:12:54 -0400 Subject: [PATCH] Add command to view a group's username length. --- cogs/commands/get.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cogs/commands/get.py b/cogs/commands/get.py index 0dbeb1d..184cb5c 100644 --- a/cogs/commands/get.py +++ b/cogs/commands/get.py @@ -143,6 +143,33 @@ class GetCog(commands.Cog, name="Get command."): f"{group.name} has a pad length of {group.pad_length}.", ephemeral=True ) + @group.subcommand(description="Get the username length of a group.") + async def username_length( + self, + interaction: nextcord.Interaction, + group_id: str = nextcord.SlashOption( + name="group", description="Group to get username length of.", required=True + ), + ) -> None: + """ + Command to view a group's username length. + + Args: + interaction (nextcord.Interaction): Interaction that invoked the command. + group_id (str): String representation of Group id get information from. Is SlashOption. + """ + stmt = select(CategoryGroup).where(col(CategoryGroup.id) == int(group_id)) + + with Session(engine) as session: + group = session.scalar(stmt) + if group is None: + await interaction.response.send_message("Group was not found.", ephemeral=True) + return + + await interaction.response.send_message( + f"{group.name} has a username length of {group.username_length}.", ephemeral=True + ) + @is_ascending.on_autocomplete("category_id") @is_validated.on_autocomplete("category_id") @size.on_autocomplete("category_id") @@ -163,6 +190,7 @@ class GetCog(commands.Cog, name="Get command."): @is_validated.on_autocomplete("group_id") @pad_length.on_autocomplete("group_id") @size.on_autocomplete("group_id") + @username_length.on_autocomplete("group_id") async def group_autocomplete(self, interaction: nextcord.Interaction, group_id: str) -> None: """ Sends results from autofill_groups back to group_output_channel for autocompletion of group_id.