Reputation: 35
I'm trying to send a message when a user sends an unknown command, but I'm getting this error. Same happened when I tried to make a message sent if a command was sent on cooldown, but I gave up and scraped that code. But now I really want to know what I am doing wrong!
How I import the discord modules:
import discord
from discord.ext import commands
This is the error handler:
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
embed=discord.Embed(title="Command not found, silly.", description=f"Please use existing commands. {ctx.author.mention}", color=0xd93600)
embed.set_footer(text="Guessity.")
await ctx.send(embed=embed)
Error:
if isinstance(error, commands.CommandNotFound):
AttributeError: 'Command' object has no attribute 'CommandNotFound'
Thanks.
Upvotes: 1
Views: 850
Reputation: 35
I fixed the issue using search function.
@bot.event
async def on_command_error(ctx, error):
print("error: ",error)
if search("not found", str(error)):
embed=discord.Embed(title="Command not found, silly.", description=f"Please use existing commands. {ctx.author.mention}", color=0xd93600)
embed.set_footer(text="Guessity.")
await ctx.send(embed=embed)
else:
raise error
Upvotes: 1