From b2acafd6e7d02a0db936893a8d4efd5edc65118b Mon Sep 17 00:00:00 2001 From: alwayscompiling Date: Thu, 11 Aug 2022 22:44:22 -0400 Subject: [PATCH] Changed design to be one class per file. --- cogs/commands/__init__.py | 12 ++++++------ cogs/commands/message_management.py | 13 +++++++++---- cogs/commands/settings_management.py | 6 +++--- cogs/commands/table_management.py | 9 +++++---- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/cogs/commands/__init__.py b/cogs/commands/__init__.py index 897e62b..6985d26 100644 --- a/cogs/commands/__init__.py +++ b/cogs/commands/__init__.py @@ -5,14 +5,14 @@ Cog loader. Adds all command classes as cogs to the bot. from nextcord.ext import commands # Command classes -from .message_management import PostHighscores -from .settings_management import Register -from .table_management import DeleteScores +from .message_management import MessageManagement +from .settings_management import SettingsManagement +from .table_management import TableManagement # This function will be called when this extension is loaded. # It is necessary to add these functions to the bot. def setup(bot: commands.Bot): """Adds all command classes to bot.""" - bot.add_cog(DeleteScores()) - bot.add_cog(PostHighscores(bot)) - bot.add_cog(Register()) + bot.add_cog(TableManagement()) + bot.add_cog(MessageManagement(bot)) + bot.add_cog(SettingsManagement()) diff --git a/cogs/commands/message_management.py b/cogs/commands/message_management.py index 34cf001..d3172f7 100644 --- a/cogs/commands/message_management.py +++ b/cogs/commands/message_management.py @@ -10,15 +10,14 @@ from highscores import highscores_data # pylint: disable=import-error from utilities.utils import send_highscore_message # pylint: disable=import-error -class PostHighscores(commands.Cog, name="Post Highscores"): +class MessageManagement(commands.Cog, name="Message Management"): """ - Posts Highscores messages. Either creates new messages for each table if one doesn't exist - or edits the existing message. + Class holds commands for managing the messages that display highscores. """ def __init__(self, bot: commands.Bot) -> None: """ - Default constructor for PostHighscores class + Default constructor for MessageManagement class Args: bot (commands.Bot): Bot object. Required to register submission button view. @@ -33,6 +32,12 @@ class PostHighscores(commands.Cog, name="Post Highscores"): """ A command which posts the highscore in the registered channel. Sends warning if no channel has been registered. + + Either creates new messages for each table if one doesn't exist + or edits the existing message. + + Args: + interaction (nextcord.Interaction): Interaction that invoked the command """ guild = highscores_data.get_guild(interaction.guild_id) print(f"Printing out highscores information in channel {guild.highscore_channel}") diff --git a/cogs/commands/settings_management.py b/cogs/commands/settings_management.py index b649b28..92efa06 100644 --- a/cogs/commands/settings_management.py +++ b/cogs/commands/settings_management.py @@ -8,14 +8,14 @@ import nextcord from highscores import highscores_data # pylint: disable=import-error -class Register(commands.Cog, name="Register"): +class SettingsManagement(commands.Cog, name="Settings Management"): """ - Class holds the Register group command. Registers various channels. + Class holds commands for managing Guild's settings. """ def __init__(self) -> None: """ - Default constructor for Register class. Does nothing. + Default constructor for SettingsManagement class. Does nothing. """ @nextcord.slash_command(default_member_permissions=nextcord.Permissions(administrator=True)) diff --git a/cogs/commands/table_management.py b/cogs/commands/table_management.py index c6f49bc..cf7e04e 100644 --- a/cogs/commands/table_management.py +++ b/cogs/commands/table_management.py @@ -8,15 +8,14 @@ import nextcord from highscores import highscores_data # pylint: disable=import-error -class DeleteScores(commands.Cog, name="Delete Scores"): +class TableManagement(commands.Cog, name="Table Management"): """ - Warning: This command only works for developers. - Deletes this guild's scores. + Class holds commands for managing the data storage of the highscores. """ def __init__(self): """ - Default constructor for DeleteScores class. Does nothing. + Default constructor for TableManagement class. Does nothing. """ @nextcord.slash_command( @@ -25,6 +24,8 @@ class DeleteScores(commands.Cog, name="Delete Scores"): ) async def delete_scores(self, interaction: nextcord.Interaction): """ + Warning: This command only works for developers. + A command which deletes all scores in all tables for this guild. Command limits to admins to prevent devs from usings on non-test servers. """