Python 如何显示命令名

Python 如何显示命令名,python,discord.py,Python,Discord.py,当有人试图执行一个不存在的命令时,我想发出一个“commandnotfound”错误。 这是我的密码: @client.event async def on_command_error(ctx, error): if isinstance(error, CommandNotFound): команда_не_найдена = discord.Embed( title=':question:Команда не найдена:question:

当有人试图执行一个不存在的命令时,我想发出一个“commandnotfound”错误。 这是我的密码:

@client.event
async def on_command_error(ctx, error):
    if isinstance(error, CommandNotFound):
        команда_не_найдена = discord.Embed(
            title=':question:Команда не найдена:question:',
            description=f'{ctx.author.mention}, command **"{commandnamehere}"** not found.'
            )
        await ctx.send(embed=команда_не_найдена)
        raise error

您只需传递
错误

description=f'{ctx.author.mention}, **{error}**.'

当引发
CommandNotFound
时,返回的消息是:
Command“RandomCommand”未找到

您可能会从
ctx
参数中获取该信息。请看本页的第三个示例: