问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/52900101/remove-command-not-found-error-discord-py