Command Error Event #8224
-
Help me please! I am doing slash commands in the bot, and I need to make an event on command error, as well as recognize the error (for example, when a person has no rights (Missing Permissions)). Please tell me the code! Update: I'm use slash-commands (app commands) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You can attach an error handler to the client = discord.Client(...)
tree = discord.app_commands.CommandTree(client)
@tree.error
async def on_app_command_error(interaction: discord.Interaction, error: discord.app_commands.AppCommandError) -> None:
... You can check which exact subclass of |
Beta Was this translation helpful? Give feedback.
You can attach an error handler to the
CommandTree
of your client by either using theerror
decorator or subclassingCommandTree
and overwriting theon_error
callback. Here is an example of the former:You can check which exact subclass of
AppCommandError
was raised here to handle it, they are listed in the Interactions API Documentation.