diff --git a/cogs/register/__init__.py b/cogs/register/__init__.py new file mode 100644 index 0000000..bcb2907 --- /dev/null +++ b/cogs/register/__init__.py @@ -0,0 +1,67 @@ +""" +Bot command for registering various channels to the bot. +""" + +from nextcord import Embed +from nextcord.ext import commands + +from highscores import highscores_data # pylint: disable=import-error +from utilities.data_storage import save_highscores_data # pylint: disable=import-error + + +class RegisterVerificationChannel(commands.Cog, name="Register"): + """Bot command for registering various channels to the bot.""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + + @commands.command(name="register") + @commands.has_permissions(administrator=True) + async def register_highscores(self, ctx: commands.Context, registration_type: str): + """A command which registers current channel as for various uses. + Usage: + ``` + ?register verify (Use in channel you want to verify submissions in.) + ?register highscore (Use in channel you want to show highscore messages in.) + ?register submission (Use in channel you want submission messages to be send it.) + ?register help (Shows help message.) + ``` + """ + # respond to the message + channel_id = ctx.channel.id + + if registration_type == "verify": + await ctx.send(f"Registered <#{channel_id}> as channel to post verifications in.") + highscores_data["verification_channel_id"] = channel_id + elif registration_type == "highscore": + await ctx.send(f"Registered <#{channel_id}> as channel to post highscores in.") + highscores_data["highscore_channel_id"] = channel_id + elif registration_type == "submission": + await ctx.send(f"Registered <#{channel_id}> as channel to post submissions in.") + highscores_data["submission_channel_id"] = channel_id + else: + embed = Embed( + title="Register command help", description="How to use the register command." + ) + embed.add_field( + name="?register verify", value="Use in channel you want to verify submissions in." + ) + embed.add_field( + name="?register highscore", + value="Use in channel you want to show highscore messages in.", + ) + embed.add_field( + name="?register submission", + value="Use in channel you want submission messages to be send it.", + ) + embed.add_field(name="?register help", value="Use to show this message.") + await ctx.reply(embed=embed) + + save_highscores_data(highscores_data) + + +# 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 function to bot""" + bot.add_cog(RegisterVerificationChannel(bot)) diff --git a/cogs/register_highscore_channel/__init__.py b/cogs/register_highscore_channel/__init__.py deleted file mode 100644 index c5270e8..0000000 --- a/cogs/register_highscore_channel/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -Bot command to register the highscores channel -""" - -from nextcord.ext import commands -from highscores import highscores_data # pylint: disable=import-error -from utilities.data_storage import save_highscores_data # pylint: disable=import-error - - -class RegisterHighscoreChannel(commands.Cog, name="Register HighScore Channel"): - """Registers Highscore channel""" - - def __init__(self, bot: commands.Bot): - self.bot = bot - - @commands.command(name="register-highscore") - async def register_highscores(self, ctx: commands.Context): - """A command which registers current channel as channel to post highscores in. - Usage: - ``` - ?register-highscore (in channel to post highscores in) - ``` - """ - print(f"Registering {ctx.channel.id} for highscores.") - # respond to the message - await ctx.send(f"Registered <#{ctx.channel.id}> as channel to post highscores in.") - highscores_data["highscore_channel_id"] = ctx.channel.id - save_highscores_data(highscores_data) - - -# 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 function to bot""" - bot.add_cog(RegisterHighscoreChannel(bot)) diff --git a/cogs/register_verification_channel/__init__.py b/cogs/register_verification_channel/__init__.py deleted file mode 100644 index a6c71b9..0000000 --- a/cogs/register_verification_channel/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -Bot command to register the verification channel -""" - -from nextcord.ext import commands -from highscores import highscores_data # pylint: disable=import-error -from utilities.data_storage import save_highscores_data # pylint: disable=import-error - - -class RegisterVerificationChannel(commands.Cog, name="Register Verify Channel"): - """Registers Verification channel""" - - def __init__(self, bot: commands.Bot): - self.bot = bot - - @commands.command(name="register-verify") - async def register_highscores(self, ctx: commands.Context): - """A command which registers current channel as channel to post verifications in. - Usage: - ``` - ?register-verify (in channel to post highscores in) - ``` - """ - print(f"Registering {ctx.channel.id} for verification.") - # respond to the message - await ctx.send(f"Registered <#{ctx.channel.id}> as channel to post verifications in.") - highscores_data["verification_channel_id"] = ctx.channel.id - save_highscores_data(highscores_data) - - -# 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 function to bot""" - bot.add_cog(RegisterVerificationChannel(bot)) diff --git a/cogs/submission/submission_views.py b/cogs/submission/submission_views.py index 6a97acb..e5c6b8d 100644 --- a/cogs/submission/submission_views.py +++ b/cogs/submission/submission_views.py @@ -27,7 +27,8 @@ class SubmissionButton(nextcord.ui.View): embed = nextcord.Embed(title="Highscores Submission") embed.add_field(name="Boss", value=boss_name, inline=False) embed.add_field(name="User", value=interaction.user.display_name, inline=False) - submission_message = await interaction.channel.send( # TODO change channel + channel = self._bot.get_channel(highscores_data["submission_channel_id"]) + submission_message = await channel.send( f"<@{interaction.user.id}>", view=SubmissionDropdownView( self._bot, interaction, await self._category_select_options(boss_name)