In a discord.py rewrite bot, if someone types the bots prefix and then any text after it, if the text is not found as a command you will get
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "sd" is not found
Is there anyway to stop the bot from logging this?
Use this "await ctx. message. delete()" at the top of your command, it will find the last sent message and delete it.
Discord py is getting discontinued because Discord implemented more and more restrictions for Bot Developers, promised easy verification steps but is behind verification processes by months. Yet introducing more restrictions and now requiring even ID copies.
Commands are defined by attaching it to a regular Python function. The command is then invoked by the user using a similar signature to the Python function. You must have access to the message_content intent for the commands extension to function. This must be set both in the developer portal and within your code.
Write an on_command_error
error handler that checks if the error is an instance of CommandNotFound
, and ignores it if it is
from discord.ext.commands import CommandNotFound
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, CommandNotFound):
return
raise error
You can try this, just change the title and the description inside the "em" part.
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
em = discord.Embed(title=f"Error!!!", description=f"Command not found.", color=ctx.author.color)
await ctx.send(embed=em)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With