From 983b9b6f34ae306084704ae9d0d24e546ae3dfd3 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Tue, 11 Mar 2025 09:03:54 -0400 Subject: [PATCH] Add command for getting group's pad length. --- cogs/commands/get.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cogs/commands/get.py b/cogs/commands/get.py index 3d5b58d..4d784c0 100644 --- a/cogs/commands/get.py +++ b/cogs/commands/get.py @@ -118,6 +118,31 @@ class GetCog(commands.Cog, name="Get command."): async def group(self, interaction: nextcord.Interaction) -> None: """Parent slash subcommand for getting group information. Never called.""" + @group.subcommand(description="Get the pad length of a group.") + async def pad_length( + self, + interaction: nextcord.Interaction, + group_id: str = nextcord.SlashOption(name="group", description="Group to get pad length of.", required=True), + ) -> None: + """ + Command to view a group's pad 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 pad length of {group.pad_length}.", ephemeral=True + ) + @is_ascending.on_autocomplete("category_id") @is_validated.on_autocomplete("category_id") @size.on_autocomplete("category_id")