W
W
wz2021-08-25 18:26:30
Python
wz, 2021-08-25 18:26:30

discord.py error handler not working?

I wanted to display errors in the chat and used such code as usual, but it does not work.

import discord
from discord.ext import commands
from discord.ext.commands import *

@bot.event
async def on_command_eror(ctx, error):
    if isinstance(error, DisabledCommand):
        e = discord.Embed(description=f"<:err:847921820598534216> `{ctx.command}` is disabled.", color=colour)
        e.set_author(name="Warning")

    elif isinstance(error, CommandNotFound):
        e = discord.Embed(description=f"<:err:847921820598534216> Command `{ctx.command}` does not exist.", color=colour)
        e.set_author(name="Warning")

    elif isinstance(error, MemberNotFound):
        e = discord.Embed(description=f"<:err:847921820598534216> Member does not exist.", color=colour)
        e.set_author(name="Warning")

    elif isinstance(error, CommandInvokeError):
        e = discord.Embed(description=f"<:err:847921820598534216> Command occurred error.", color=colour)
        e.set_author(name="Warning")

    elif isinstance(error, MissingPermissions):
        e = discord.Embed(description=f"<:err:847921820598534216> Missing permissions for use this command.", color=colour)
        e.set_author(name="Warning")

    elif isinstance(error, BotMissingPermissions):
        e = discord.Embed(description=f"<:err:847921820598534216> I am missing permissions for use this command.", color=colour)
        e.set_author(name="Warning")
        
    elif isinstance(error, MissingRequiredArgument):
        e = discord.Embed(description=f"<:err:847921820598534216> Missing required argument: `{error.param}` in `{ctx.command}`.", color=colour)
        e.set_author(name="Warning")

    elif isinstance(error, CommandOnCooldown):
        e = discord.Embed(description=f"<:err:847921820598534216> Command `{ctx.command}` has cooldown. Retry in {round(error.retry_after, 1)} seconds", color=colour)
        e.set_author(name="Warning")

    await ctx.reply(embed=e, mention_author=False)


The bot does not display anything in the chat but writes an error in the console.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RDSKUser, 2021-08-26
@rensly

async def on_command_eror(ctx, error):
fix to on_command_error(ctx. error):

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question