Add get is_validated command.

This commit is contained in:
2025-03-10 16:06:28 -04:00
parent 1fcb25193d
commit 84c910b19c
+37 -1
View File
@@ -28,7 +28,9 @@ class GetCog(commands.Cog, name="Get command."):
self, self,
interaction: nextcord.Interaction, interaction: nextcord.Interaction,
group_id: str = nextcord.SlashOption(name="group", description="Group that Category is in.", required=True), 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: ) -> None:
""" """
Command to view how a category is sorted. Command to view how a category is sorted.
@@ -53,6 +55,38 @@ class GetCog(commands.Cog, name="Get command."):
ephemeral=True, 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.") @category.subcommand(description="Get the size for a category.")
async def size( async def size(
self, self,
@@ -85,6 +119,7 @@ class GetCog(commands.Cog, name="Get command."):
"""Parent slash subcommand for getting group information. Never called.""" """Parent slash subcommand for getting group information. Never called."""
@is_ascending.on_autocomplete("category_id") @is_ascending.on_autocomplete("category_id")
@is_validated.on_autocomplete("category_id")
@size.on_autocomplete("category_id") @size.on_autocomplete("category_id")
async def category_autocomplete(self, interaction: nextcord.Interaction, category_id: str, group_id: str) -> None: 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_ascending.on_autocomplete("group_id")
@is_validated.on_autocomplete("group_id")
@size.on_autocomplete("group_id") @size.on_autocomplete("group_id")
async def group_autocomplete(self, interaction: nextcord.Interaction, group_id: str) -> None: async def group_autocomplete(self, interaction: nextcord.Interaction, group_id: str) -> None:
""" """