From c01ba86c62a9411886977aafb57bb888157e838c Mon Sep 17 00:00:00 2001 From: FirePlank <44502537+FirePlank@users.noreply.github.com> Date: Thu, 2 Nov 2023 23:57:19 +0200 Subject: [PATCH] switched to using cog_app_command_error --- bot/core.py | 10 ---------- bot/extensions/clashofcode/commands.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bot/core.py b/bot/core.py index 2db15e95..f3a14134 100644 --- a/bot/core.py +++ b/bot/core.py @@ -105,16 +105,6 @@ async def on_app_command_error(self, interaction: "InteractionType", error: app_ return if isinstance(error, app_commands.CheckFailure): - if interaction.command.qualified_name.startswith("coc "): - if isinstance(error, app_commands.MissingAnyRole): - await interaction.response.send_message( - "You need to have the Clash Of Code role to use this command", ephemeral=True - ) - else: - await interaction.response.send_message( - "You need to be in the Clash Of Code channel to use this command", ephemeral=True - ) - log.info(f"{interaction.user} failed to use the command {interaction.command.qualified_name}") return diff --git a/bot/extensions/clashofcode/commands.py b/bot/extensions/clashofcode/commands.py index eb74b581..f2778651 100644 --- a/bot/extensions/clashofcode/commands.py +++ b/bot/extensions/clashofcode/commands.py @@ -272,6 +272,19 @@ async def coc_invite(self, interaction: core.InteractionType, url: str): await interaction.channel.send(embed=embed) + async def cog_app_command_error(self, interaction: core.InteractionType, error): + if not isinstance(error, app_commands.CheckFailure): + return + + if isinstance(error, app_commands.MissingAnyRole): + await interaction.response.send_message( + "You need to have the Clash Of Code role to use this command", ephemeral=True + ) + else: + await interaction.response.send_message( + "You need to be in the Clash Of Code channel to use this command", ephemeral=True + ) + async def setup(bot: core.DiscordBot): await bot.add_cog(ClashOfCode(bot=bot))