From 84c910b19c1788f87300d8b123b879cbcc80e84a Mon Sep 17 00:00:00 2001 From: imcompiling Date: Mon, 10 Mar 2025 16:06:28 -0400 Subject: [PATCH] Add get is_validated command. --- cogs/commands/get.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/cogs/commands/get.py b/cogs/commands/get.py index 43f97a0..3d5b58d 100644 --- a/cogs/commands/get.py +++ b/cogs/commands/get.py @@ -28,7 +28,9 @@ class GetCog(commands.Cog, name="Get command."): self, interaction: nextcord.Interaction, group_id: str = nextcord.SlashOption(name="group", description="Group that Category is in.", required=True), - category_id: str = nextcord.SlashOption(name="category", description="Category to get size of.", required=True), + category_id: str = nextcord.SlashOption( + name="category", description="Category to information from.", required=True + ), ) -> None: """ Command to view how a category is sorted. @@ -53,6 +55,38 @@ class GetCog(commands.Cog, name="Get command."): ephemeral=True, ) + @category.subcommand(description="Get whether a category required validation.") + async def is_validated( + self, + interaction: nextcord.Interaction, + group_id: str = nextcord.SlashOption(name="group", description="Group that Category is in.", required=True), + category_id: str = nextcord.SlashOption( + name="category", description="Category to information from.", required=True + ), + ) -> None: + """ + Command to view if a category required photo validation. + + Args: + interaction (nextcord.Interaction): Interaction that invoked the command. + group_id (str): String representation of Group id to register channel to. Is SlashOption. + category_id (str): String representation of Category id to register channel to. Is SlashOption. + """ + stmt = ( + select(Category).where(col(CategoryGroup.id) == int(group_id)).where(col(Category.id) == int(category_id)) + ) + + with Session(engine) as session: + category = session.scalar(stmt) + if category is None: + await interaction.response.send_message("Group or Category was not found.", ephemeral=True) + return + + await interaction.response.send_message( + f"{category.name} does {'not ' if not category.is_validated else ''} require validation.", + ephemeral=True, + ) + @category.subcommand(description="Get the size for a category.") async def size( self, @@ -85,6 +119,7 @@ class GetCog(commands.Cog, name="Get command."): """Parent slash subcommand for getting group information. Never called.""" @is_ascending.on_autocomplete("category_id") + @is_validated.on_autocomplete("category_id") @size.on_autocomplete("category_id") async def category_autocomplete(self, interaction: nextcord.Interaction, category_id: str, group_id: str) -> None: """ @@ -100,6 +135,7 @@ class GetCog(commands.Cog, name="Get command."): ) @is_ascending.on_autocomplete("group_id") + @is_validated.on_autocomplete("group_id") @size.on_autocomplete("group_id") async def group_autocomplete(self, interaction: nextcord.Interaction, group_id: str) -> None: """