【问题标题】:'MissingRequiredArgument' object has no attribute 'send' - discord.py rewrite'MissingRequiredArgument' 对象没有属性 'send' - discord.py 重写
【发布时间】:2020-12-17 00:23:04
【问题描述】:

我有一个脚本,可以检测命令上何时出现“MissingRequiredArgument”错误并发送消息通知用户。直到昨天出现此错误时,它都可以正常工作:

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'MissingRequiredArgument' object has no attribute 'send'

我不知道发生了什么! 另外,这是代码:

@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send("Missing argument(s)!")

【问题讨论】:

    标签: python-3.x discord.py-rewrite


    【解决方案1】:

    希望这对你有用

        async def on_command_error(ctx, exception):
            error = getattr(exception, "original", exception)
    
            if isinstance(error, commands.MissingRequiredArgument):
                await ctx.send("Missing argument(s)!")
                return
    

    【讨论】:

      【解决方案2】:

      改用这个

       #     await client.send_message(message.channel, 'Missing Arguments')      #
      

      或尝试替换: # 'send' 和 'send_message' #

      【讨论】:

        猜你喜欢
        • 2020-09-15
        • 2021-07-27
        • 1970-01-01
        • 1970-01-01
        • 2019-06-19
        • 1970-01-01
        • 2021-08-01
        • 2021-02-17
        • 2023-01-23
        相关资源
        最近更新 更多