Variable name changes for clarification and fixing runtime issues.

This commit is contained in:
alwayscompiling
2022-12-01 20:21:36 -05:00
parent 2154d713cb
commit d0f328dd2d
4 changed files with 43 additions and 41 deletions
+16 -10
View File
@@ -33,7 +33,9 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
async def group_output_channel(
self,
interaction: nextcord.Interaction,
category_group: nextcord.SlashOption(description="Category Group to assign to channel.", required=True),
group_id: Optional[int] = nextcord.SlashOption(
description="Category Group to assign to channel.", required=True
),
channel: Optional[nextcord.abc.GuildChannel] = nextcord.SlashOption(
description="Channel to register",
required=False,
@@ -46,6 +48,7 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
Args:
interaction (nextcord.Interaction): Interaction that invoked the command
group_id (Optional[int]): Group to register channel to. Is SlashOption.
channel (nextcord.abc.GuildChannel, optional): Channel to register
Is a SlashOption. Limited to text channels, Defaults to None.
"""
@@ -55,7 +58,7 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
stmt = (
select(CategoryGroup)
.where(CategoryGroup.GuildId == interaction.guild_id)
.where(CategoryGroup.GroupId == category_group)
.where(CategoryGroup.GroupId == group_id)
)
group = session.scalar(stmt)
group.ChannelId = channel_id
@@ -130,7 +133,9 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
async def category_pad_length(
self,
interaction: nextcord.Interaction,
category_group: nextcord.SlashOption(description="Category Group to assign to channel.", required=True),
group_id: Optional[int] = nextcord.SlashOption(
description="Category Group to assign to channel.", required=True
),
length: Optional[int] = nextcord.SlashOption(description="Number of characters.", required=True, default=26),
) -> None:
"""
@@ -138,13 +143,14 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
Args:
interaction (nextcord.Interaction): Interaction that invoked the command
group_id (Optional[int]): Group to set pad length in. Is SlashOption.
length (Optional[int]): Number of characters. Is SlashOption. Defaults to 26.
"""
stmt = (
select(CategoryGroup)
.where(CategoryGroup.GuildId == interaction.guild_id)
.where(CategoryGroup.GroupId == category_group)
.where(CategoryGroup.GroupId == group_id)
)
group = session.scalar(stmt)
group.PadLength = length
@@ -153,17 +159,17 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
f"Category pad length set to {length} for {group.GroupName}", ephemeral=True
)
@group_output_channel.on_autocomplete("category_group")
@category_pad_length.on_autocomplete("category_group")
async def group_id_autocomplete(self, interaction: nextcord.Interaction, category_group: str):
@group_output_channel.on_autocomplete("group_id")
@category_pad_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 category_group.
Sends results from autofill_groups back to group_output_channel for autocompletion of group_id.
Args:
interaction (nextcord.Interaction): Interaction with command.
category_group (str): String to run autocompletion against.
group_id (str): String to run autocompletion against.
"""
await interaction.response.send_autocomplete(autofill_groups(interaction.guild_id, category_group))
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(