Trying to Handle Errors but Missing Positional Arguments

I am currently making a discord bot, but when trying to handle errors, I am getting this:
Ignoring exception in on_command_error
Traceback (most recent call last):
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/”, line 343, in _run_event
await coro(*args, **kwargs)
TypeError: on_command_error() missing 2 required positional arguments: ‘error’ and ‘exc’
This is the code that is causing issues:

async def on_command_error(bot, ctx, error, exc):
    if isinstance(exc, CommandNotFound):
    elif isinstance(exc, CommandOnCooldown):
     await ctx.send(f"Command is on cooldown. Command resets in {exc.retry_after:,.2f} seconds.")
    elif hasattr(exc, ["original"]):
      raise exc.original

      raise exc

Any help would be greatly appreciated!

This error means, for whatever reason, function is called using only two arguments, while definition of function requires four arguments.

How would I fix this issue?

Most likely either change function definition or change way function is called from elsewhere. But that depends on which case is it exactly - function is not defined like it should, or it’s improperly called.

I’m not getting the error anymore, thank you! It’s still not doing what I want but I’ll have to play around with it more haha. I’ve been trying to code at 5am before I go to work so my brain is not awake when I try to do this.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.