cogs/errors.py
async def on_command_error(self, ctx, error):
        """The event triggered when an error is raised while invoking a command."""
        gumbachi = cfg.bot.get_user(128595549975871488)
        if hasattr(ctx.command, 'on_error'):
            return

        error = getattr(error, 'original', error)

        # ignore non-commands
        if isinstance(error, commands.CommandNotFound):
            return

        # ADD HEAVY COMMAND ERROR AND SUPPRESS ERROR HERE

        cfg.heavy_command_active.discard(ctx.guild.id)  # reset heavy command
        cfg.suppress_output.discard(ctx.guild.id)

        # General command error (should go last)
        if isinstance(error, commands.CommandError):
            embed = discord.Embed(title=str(error), color=discord.Color.red())
            return await ctx.send(embed=embed)

        # 403 Error
        if isinstance(error, discord.Forbidden):
            # Missing Access
            if error.code == 50001:
                embed = discord.Embed(
                    title="Missing Access",
                    description="The bot is not able to access the channel\nPlease ensure the bot has the correct permissions",
                    color=discord.Color.red()
                )
            # Missing Permissions
            elif error.code == 50013:
                embed = discord.Embed(
                    title="Bot Missing Permissions",
                    description="The bot is missing permissions\nPlease ensure the bot has its required permissions",
                    color=discord.Color.red()
                )

            return await ctx.send(embed=embed)

        # NotFound
        if isinstance(error, discord.errors.NotFound):
            # Missing Message
            if error.code == 10008:
                embed = discord.Embed(
                    title="Missing Message",
                    description="Kindly don't delete the progress message",
                    color=discord.Color.red()
                )
            # Missing Role
            elif error.code == 50011:
                embed = discord.Embed(
                    title="Bot couldn't find role",
                    description="Bot couldn't find a role. Try resetting your colors if this persists",
                    color=discord.Color.red()
                )

            return await ctx.send(embed=embed)

        # Unusual error to be fixed
        error_embed = discord.Embed(
            title=f'Your command: {ctx.message.content}',
            description=f"{ctx.guild.id}: {error}",
            color=discord.Colour.red()
        )
        await ctx.send(embed=error_embed)  # send to user
        await gumbachi.send(embed=error_embed)  # send to me

        print(f'Ignoring exception in command {ctx.command}:', file=sys.stderr)
        traceback.print_exception(
            type(error), error, error.__traceback__, file=sys.stderr)
The event triggered when an error is raised while invoking a command.
The event triggered when an error is raised while invoking a command.
The event triggered when an error is raised while invoking a command .
async def on_command_error(self, ctx, error):
        gumbachi = cfg.bot.get_user(128595549975871488)
        if hasattr(ctx.command, 'on_error'):
            return
        error = getattr(error, 'original', error)
        if isinstance(error, commands.CommandNotFound):
            return
        cfg.heavy_command_active.discard(ctx.guild.id)  
        cfg.suppress_output.discard(ctx.guild.id)
        if isinstance(error, commands.CommandError):
            embed = discord.Embed(title=str(error), color=discord.Color.red())
            return await ctx.send(embed=embed)
        if isinstance(error, discord.Forbidden):
            if error.code == 50001:
                embed = discord.Embed(
                    title="Missing Access",
                    description="The bot is not able to access the channel\nPlease ensure the bot has the correct permissions",
                    color=discord.Color.red()
                )
            elif error.code == 50013:
                embed = discord.Embed(
                    title="Bot Missing Permissions",
                    description="The bot is missing permissions\nPlease ensure the bot has its required permissions",
                    color=discord.Color.red()
                )
            return await ctx.send(embed=embed)
        if isinstance(error, discord.errors.NotFound):
            if error.code == 10008:
                embed = discord.Embed(
                    title="Missing Message",
                    description="Kindly don't delete the progress message",
                    color=discord.Color.red()
                )
            elif error.code == 50011:
                embed = discord.Embed(
                    title="Bot couldn't find role",
                    description="Bot couldn't find a role. Try resetting your colors if this persists",
                    color=discord.Color.red()
                )
            return await ctx.send(embed=embed)
        error_embed = discord.Embed(
            title=f'Your command: {ctx.message.content}',
            description=f"{ctx.guild.id}: {error}",
            color=discord.Colour.red()
        )
        await ctx.send(embed=error_embed)  
        await gumbachi.send(embed=error_embed)  
        print(f'Ignoring exception in command {ctx.command}:', file=sys.stderr)
        traceback.print_exception(
            type(error), error, error.__traceback__, file=sys.stderr)
async def on_command_error ( self , ctx , error ) : gumbachi = cfg . bot . get_user ( 128595549975871488 ) if hasattr ( ctx . command , 'on_error' ) : return error = getattr ( error , 'original' , error ) if isinstance ( error , commands . CommandNotFound ) : return cfg . heavy_command_active . discard ( ctx . guild . id ) cfg . suppress_output . discard ( ctx . guild . id ) if isinstance ( error , commands . CommandError ) : embed = discord . Embed ( title = str ( error ) , color = discord . Color . red ( ) ) return await ctx . send ( embed = embed ) if isinstance ( error , discord . Forbidden ) : if error . code == 50001 : embed = discord . Embed ( title = "Missing Access" , description = "The bot is not able to access the channel\nPlease ensure the bot has the correct permissions" , color = discord . Color . red ( ) ) elif error . code == 50013 : embed = discord . Embed ( title = "Bot Missing Permissions" , description = "The bot is missing permissions\nPlease ensure the bot has its required permissions" , color = discord . Color . red ( ) ) return await ctx . send ( embed = embed ) if isinstance ( error , discord . errors . NotFound ) : if error . code == 10008 : embed = discord . Embed ( title = "Missing Message" , description = "Kindly don't delete the progress message" , color = discord . Color . red ( ) ) elif error . code == 50011 : embed = discord . Embed ( title = "Bot couldn't find role" , description = "Bot couldn't find a role. Try resetting your colors if this persists" , color = discord . Color . red ( ) ) return await ctx . send ( embed = embed ) error_embed = discord . Embed ( title = f'Your command: {ctx.message.content}' , description = f"{ctx.guild.id}: {error}" , color = discord . Colour . red ( ) ) await ctx . send ( embed = error_embed ) await gumbachi . send ( embed = error_embed ) print ( f'Ignoring exception in command {ctx.command}:' , file = sys . stderr ) traceback . print_exception ( type ( error ) , error , error . __traceback__ , file = sys . stderr )
The event triggered when an error is raised while invoking a command.
The event triggered when an error is raised while invoking a command .
"""The event triggered when an error is raised while invoking a command.""" # ignore non-commands # ADD HEAVY COMMAND ERROR AND SUPPRESS ERROR HERE # reset heavy command # General command error (should go last) # 403 Error # Missing Access # Missing Permissions # NotFound # Missing Message # Missing Role # Unusual error to be fixed # send to user # send to me
self
ctx
error