Update functions for username length being in group.
This commit is contained in:
@@ -159,8 +159,36 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
|
||||
f"Category pad length set to {length} for {group.GroupName}", ephemeral=True
|
||||
)
|
||||
|
||||
@set.subcommand(description="Set username length for a Group of Categories.")
|
||||
async def username_length(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
group_id: str = nextcord.SlashOption(
|
||||
name="group", description="Group to change username length of.", required=True
|
||||
),
|
||||
length: int = nextcord.SlashOption(description="Number of characters.", required=True, default=12),
|
||||
) -> None:
|
||||
"""
|
||||
Changes guild's username length limit.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command
|
||||
length (int): Number of characters. Is SlashOption. Defaults to 12.
|
||||
"""
|
||||
|
||||
stmt = (
|
||||
select(CategoryGroup)
|
||||
.where(CategoryGroup.GuildId == interaction.guild_id)
|
||||
.where(CategoryGroup.GroupId == int(group_id))
|
||||
)
|
||||
group = session.scalar(stmt)
|
||||
group.UsernameLength = length
|
||||
session.commit()
|
||||
await interaction.response.send_message(f"Username length set to {length}.", ephemeral=True)
|
||||
|
||||
@group_output_channel.on_autocomplete("group_id")
|
||||
@category_pad_length.on_autocomplete("group_id")
|
||||
@username_length.on_autocomplete("group_id")
|
||||
async def group_id_autocomplete(self, interaction: nextcord.Interaction, group_id: str):
|
||||
"""
|
||||
Sends results from autofill_groups back to group_output_channel for autocompletion of group_id.
|
||||
@@ -170,23 +198,3 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
|
||||
group_id (str): String to run autocompletion against.
|
||||
"""
|
||||
await interaction.response.send_autocomplete(autofill_groups(interaction.guild_id, group_id))
|
||||
|
||||
@set.subcommand(description="Set username length. Limits all submissions to this length.")
|
||||
async def username_length(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
length: int = nextcord.SlashOption(description="Number of characters.", required=True, default=12),
|
||||
) -> None:
|
||||
"""
|
||||
Changes guild's username length limit.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command
|
||||
length (int): Number of charactesr. Is SlashOption. Defaults to 12.
|
||||
"""
|
||||
|
||||
stmt = select(Guild).where(Guild.GuildId == interaction.guild_id)
|
||||
guild = session.scalar(stmt)
|
||||
guild.UsernameLength = length
|
||||
session.commit()
|
||||
await interaction.response.send_message(f"Username length set to {length}", ephemeral=True)
|
||||
|
||||
Reference in New Issue
Block a user