Add command to view a group's username length.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user