Corrected autofill function return structures.
This commit is contained in:
@@ -91,8 +91,8 @@ class DataManagementCog(commands.Cog, name="Table Management"):
|
||||
async def from_category(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
group_id: int = nextcord.SlashOption(description="Group to delete user from.", required=True),
|
||||
category_id: int = nextcord.SlashOption(description="Category to delete user from.", required=True),
|
||||
group_id: str = nextcord.SlashOption(description="Group to delete user from.", required=True),
|
||||
category_id: str = nextcord.SlashOption(description="Category to delete user from.", required=True),
|
||||
user_name: str = nextcord.SlashOption(description="User to delete.", required=True),
|
||||
):
|
||||
"""
|
||||
@@ -100,27 +100,31 @@ class DataManagementCog(commands.Cog, name="Table Management"):
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
group_id (int): Group to remove user from. Is SlashOption.
|
||||
category_id (int): Category to remove user from. Is SlashOption.
|
||||
group_id (str): String representation of Group id to remove user from. Is SlashOption.
|
||||
category_id (str): String representation of Category id to remove user from. Is SlashOption.
|
||||
user_name (str): The user to remove. Is SlashOption.
|
||||
"""
|
||||
|
||||
stmt = select(CategoryGroup).where(CategoryGroup.GroupId == group_id)
|
||||
stmt = select(CategoryGroup).where(CategoryGroup.GroupId == int(group_id))
|
||||
group = session.scalar(stmt)
|
||||
stmt = select(Score).where(Score.CategoryId == category_id)
|
||||
|
||||
stmt = select(Category.CategoryName).where(Category.CategoryId == int(category_id))
|
||||
category_name = session.scalar(stmt)
|
||||
|
||||
stmt = select(Score).where(Score.CategoryId == int(category_id))
|
||||
|
||||
for score in session.scalars(stmt):
|
||||
session.delete(score)
|
||||
session.commit()
|
||||
|
||||
await send_highscore_message(interaction.guild.get_channel(group.ChannelId), group)
|
||||
await interaction.response.send_message(f'User "{user_name}" removed from "{category_id}".', ephemeral=True)
|
||||
await interaction.response.send_message(f'User "{user_name}" removed from "{category_name}".', ephemeral=True)
|
||||
|
||||
@user.subcommand(description="Deletes a user's scores from entire group.")
|
||||
async def from_group(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
group_id: int = nextcord.SlashOption(description="Group to delete user from.", required=True),
|
||||
group_id: str = nextcord.SlashOption(description="Group to delete user from.", required=True),
|
||||
user_name: str = nextcord.SlashOption(description="User to delete.", required=True),
|
||||
):
|
||||
"""
|
||||
@@ -128,13 +132,13 @@ class DataManagementCog(commands.Cog, name="Table Management"):
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
group_id (int): Group to remove user from. Is SlashOption.
|
||||
group_id (str): String representation of Group id to remove user from. Is SlashOption.
|
||||
user_name (str): The user to remove. Is SlashOption.
|
||||
"""
|
||||
|
||||
stmt = select(CategoryGroup).where(CategoryGroup.GroupId == group_id)
|
||||
stmt = select(CategoryGroup).where(CategoryGroup.GroupId == int(group_id))
|
||||
group = session.scalar(stmt)
|
||||
category_ids = select(Category.Id).where(Category.GroupId == group_id).subquery()
|
||||
category_ids = select(Category.Id).where(Category.GroupId == int(group_id)).subquery()
|
||||
stmt = select(Score).where(Score.CategoryId.in_(category_ids)).where(Score.UserName == user_name)
|
||||
|
||||
for score in session.scalars(stmt):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Commands for managing/displaying the highscores messages.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from typing import Optional, Union
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
@@ -115,20 +115,20 @@ class MessageManagementCog(commands.Cog, name="Message Management"):
|
||||
async def refresh_group(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
group_id: int = nextcord.SlashOption(description="Name of table.", required=True),
|
||||
group_id: str = nextcord.SlashOption(description="Name of table.", required=True),
|
||||
) -> None:
|
||||
"""
|
||||
Refreshes a table given by user.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
group_id (int): Group id to refresh. Is SlashOption.
|
||||
group_id (str): Str representation of Group id to refresh. Is SlashOption.
|
||||
"""
|
||||
|
||||
stmt = (
|
||||
select(CategoryGroup)
|
||||
.where(CategoryGroup.GuildId == interaction.guild_id)
|
||||
.where(CategoryGroup.GroupId == group_id)
|
||||
.where(CategoryGroup.GroupId == int(group_id))
|
||||
)
|
||||
group = session.scalar(stmt)
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
|
||||
async def group_output_channel(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
group_id: int = nextcord.SlashOption(description="Category Group to assign to channel.", required=True),
|
||||
group_id: str = 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,7 +46,7 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command
|
||||
group_id (int): Group to register channel to. Is SlashOption.
|
||||
group_id (str): String representation of Group id to register channel to. Is SlashOption.
|
||||
channel (nextcord.abc.GuildChannel, optional): Channel to register
|
||||
Is a SlashOption. Limited to text channels, Defaults to None.
|
||||
"""
|
||||
@@ -56,7 +56,7 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
|
||||
stmt = (
|
||||
select(CategoryGroup)
|
||||
.where(CategoryGroup.GuildId == interaction.guild_id)
|
||||
.where(CategoryGroup.GroupId == group_id)
|
||||
.where(CategoryGroup.GroupId == int(group_id))
|
||||
)
|
||||
group = session.scalar(stmt)
|
||||
group.ChannelId = channel_id
|
||||
@@ -131,7 +131,7 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
|
||||
async def category_pad_length(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
group_id: int = nextcord.SlashOption(description="Category Group to assign to channel.", required=True),
|
||||
group_id: str = nextcord.SlashOption(description="Category Group to assign pad length to.", required=True),
|
||||
length: int = nextcord.SlashOption(description="Number of characters.", required=True, default=26),
|
||||
) -> None:
|
||||
"""
|
||||
@@ -139,14 +139,14 @@ class SettingsManagementCog(commands.Cog, name="Settings Management"):
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command
|
||||
group_id (int): Group to set pad length in. Is SlashOption.
|
||||
group_id (str): String representation of Group id to set pad length in. Is SlashOption.
|
||||
length (int): Number of characters. Is SlashOption. Defaults to 26.
|
||||
"""
|
||||
|
||||
stmt = (
|
||||
select(CategoryGroup)
|
||||
.where(CategoryGroup.GuildId == interaction.guild_id)
|
||||
.where(CategoryGroup.GroupId == group_id)
|
||||
.where(CategoryGroup.GroupId == int(group_id))
|
||||
)
|
||||
group = session.scalar(stmt)
|
||||
group.PadLength = length
|
||||
|
||||
Reference in New Issue
Block a user