Skip to content
Discussion options

You must be logged in to vote

The @CommandTree.error decorator cannot be used inside a cog but there are alternatives.

  1. Cog.cog_app_command_error, this is a special method that is called for errors that occur for app commands that are defined in that cog.
from discord import app_commands, Interaction 
from discord.ext import commands

class MyCog(commands.Cog):
    async def cog_app_command_error(
        self,
        interaction: Interaction,
        error: app_commands.AppCommandError
    ):
        # disclaimer: this is an example implementation.
        print("An error occurred in the following command:", interaction.command, "error:", str(error))
        raise error
  1. Staying on the theme of in a Cog but not rea…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hitblast
Comment options

Answer selected by hitblast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants