如何处理特定的 CommandInvokeError? [DIscord.py]

How can I handle for a specific CommandInvokeError? [DIscord.py]

我的一个函数可能会引发 KeyError 错误。这引发了 CommandInvokeError。但是,还有其他错误,例如 DivisionByZero 可能会导致引发 CommandInvokeError。我只知道一种处理错误的方法,它是:

@cmd.error
async def cmd_error(self, ctx, error):
    if isinstance(error, commands.CommandInvokeError):
        await ctx.send("Error!")

这对于导致 CommandInvokeError 的任何错误都是一样的。我怎样才能让它只在引发 KeyError 时才发送消息?

注意:这是一个齿轮

@cmd.error
async def cmd_error(self, ctx, error):
    if isinstance(error, commands.CommandInvokeError):
        if isinstance(error.original, KeyError):
            await ctx.send("Error!")

你也可以用error.__cause__,没区别