From 52ee85f17c4c7bf710f254a67a9f749c8636eed5 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Wed, 15 May 2024 14:07:27 -0400 Subject: [PATCH] Add a refresh command. --- cogs/commands/__init__.py | 2 ++ cogs/commands/refresh.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 cogs/commands/refresh.py diff --git a/cogs/commands/__init__.py b/cogs/commands/__init__.py index 013fef5..725f143 100644 --- a/cogs/commands/__init__.py +++ b/cogs/commands/__init__.py @@ -5,6 +5,7 @@ Cog loader. Adds all command cogs to the bot. from nextcord.ext import commands from cogs.commands.record import RecordCog +from cogs.commands.refresh import RefreshCog from cogs.commands.remove import RemoveCog from cogs.commands.request import RequestCog from cogs.commands.set import setCog @@ -20,6 +21,7 @@ def setup(bot: commands.Bot): """ bot.add_cog(RecordCog(bot)) + bot.add_cog(RefreshCog()) bot.add_cog(RemoveCog()) bot.add_cog(RequestCog(bot)) bot.add_cog(TestCog(bot)) diff --git a/cogs/commands/refresh.py b/cogs/commands/refresh.py new file mode 100644 index 0000000..dddfb7e --- /dev/null +++ b/cogs/commands/refresh.py @@ -0,0 +1,32 @@ +""" +Contained commands and views for refresh commands. +""" + +import nextcord +from nextcord.ext import commands + +from utils import update_clan_messages + + +class RefreshCog(commands.Cog, name="Refresh Commands"): + """ + Class holds refresh commands. + """ + + @nextcord.slash_command( + default_member_permissions=nextcord.Permissions(administrator=True) + ) + async def refresh(self, interaction: nextcord.Interaction): + """ + Parent slash command for refresh. Never called. + """ + + @refresh.subcommand(description="Force refresh all of the bot managed messages.") + async def event(self, interaction: nextcord.Interaction): + """ + Calls update_clan_messages() to update all messages. + + Args: + interaction (nextcord.Interaction): Interaction with the command. + """ + await update_clan_messages(interaction.guild)