Skip to content

Commit

Permalink
switched to using cog_app_command_error
Browse files Browse the repository at this point in the history
  • Loading branch information
FirePlank committed Nov 2, 2023
1 parent 3e4df48 commit c01ba86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 0 additions & 10 deletions bot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions bot/extensions/clashofcode/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit c01ba86

Please sign in to comment.