diff --git a/suggestions/__init__.py b/suggestions/__init__.py index 0910258..be2a860 100644 --- a/suggestions/__init__.py +++ b/suggestions/__init__.py @@ -1,5 +1,14 @@ -from .suggestions import Suggestions +from .suggestions import Suggestions, approve_context, deny_context async def setup(bot): await bot.add_cog(Suggestions(bot)) + +async def setup(bot): + bot.tree.add_command(approve_context) + bot.tree.add_command(deny_context) + +async def teardown(bot): + # We're removing the commands here to ensure they get unloaded properly when the cog is unloaded. + bot.tree.remove_command("approve_context", type=discord.AppCommandType.message) + bot.tree.remove_command("deny_context", type=discord.AppCommandType.message) diff --git a/suggestions/suggestions.py b/suggestions/suggestions.py index 53939a3..3237904 100644 --- a/suggestions/suggestions.py +++ b/suggestions/suggestions.py @@ -208,14 +208,6 @@ class Suggestions(commands.Cog): await old_msg.edit(content=content, embed=embed) await ctx.tick() - @app_commands.context_menu(name="Approve Suggestion") - async def approve_context(self, interaction: discord.Interaction, message: discord.Message): - await interaction.response.send_modal(self.SuggestionApproveModal(self, message)) - - @app_commands.context_menu(name="Deny Suggestion") - async def deny_context(self, interaction: discord.Interaction, message: discord.Message): - await interaction.response.send_modal(self.SuggestionDenyModal(self, message)) - @checks.admin() @checks.bot_has_permissions( manage_channels=True, add_reactions=True, manage_messages=True @@ -647,3 +639,11 @@ class Suggestions(commands.Cog): else: await self.cog_instance.interaction_finish_suggestion(interaction, self.message, False, None) await interaction.response.send_message(content="Suggestion denied!", ephemeral=True) + +@app_commands.context_menu(name="Approve Suggestion") +async def approve_context(interaction: discord.Interaction, message: discord.Message): + await interaction.response.send_modal(Suggestions.SuggestionApproveModal(Suggestions, message)) + +@app_commands.context_menu(name="Deny Suggestion") +async def deny_context(interaction: discord.Interaction, message: discord.Message): + await interaction.response.send_modal(Suggestions.SuggestionDenyModal(Suggestions, message))