Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get the command name when a command not found error occurs discord.py

I have made an event called on_command_error which intercepts the orginal command error. In that event it sends to the channel the command was executed in.
"The command you have executed is not found".
I want it to be able to say.
"The command {commandname} has not been found".
I don’t know how to get the command name.

@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, CommandNotFound):
        await ctx.send("The command you have executed is not found.")

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

this may not be the best way of doing this, but a solution I discovered is:

async def on_command_error(ctx, error):
    if isinstance(error, CommandNotFound):
        await ctx.send(f"The command {error} you have executed is not found. use the command !help for a list of available commands")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading