Changed design to be one class per file.

This commit is contained in:
alwayscompiling
2022-08-11 22:44:22 -04:00
parent 349fdfe18d
commit b2acafd6e7
4 changed files with 23 additions and 17 deletions
+6 -6
View File
@@ -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())
+9 -4
View File
@@ -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}")
+3 -3
View File
@@ -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))
+5 -4
View File
@@ -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.
"""