python - discord .py 的错误代码

标签 python python-3.x error-handling discord.py

 @bot.command(pass_conetext = True)
async def info(ctx,  user: discord.Member):
    embed = discord.Embed(title = "Super Bot", description = "Thinking" , color = 0x00ff00)
    embed.add_field(name = "Name", value = user.name, inline = True)
    embed.add_field(name = "ID", value = user.id , inline = True)
    embed.add_field(name = "Status", value = user.status , inline = True)
    embed.add_field(name = "Highest Role", value = user.top_role , inline = True)
    embed.add_field(name = "Joined", value = user.joined_at , inline = True)
    embed.set_thumbnail(url = user.avatar_url)

每次我运行这段代码都会返回这个错误,我不知道为什么

Ignoring exception in command info
Traceback (most recent call last):
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 367, in invoke
    yield from self.prepare(ctx)
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 345, in prepare
    yield from self._parse_arguments(ctx)
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 304, in _parse_arguments
    transformed = yield from self.transform(ctx, param)
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 212, in transform
    raise MissingRequiredArgument('{0.name} is a required argument that is missing.'.format(param))
discord.ext.commands.errors.MissingRequiredArgument: user is a required argument that is missing.

有人能解释一下为什么吗?也许还有一个解决方案

最佳答案

运行命令的人没有 user 参数。

!info @user 而不是 !info

关于python - discord .py 的错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48997161/

相关文章:

python - 流式传输 Twitter 推文时忽略转发

python - 使用表情符号使用 tweepy(python)流推文

python - 绘制租金图

python - 为什么自定义激活函数会导致网络既零损失又低准确率?

python-3.x - 如何在预测时使用主成分分析?

python - 如何处理Python中被调用库生成的弹出错误提示?

Angular 看不到注入(inject)的服务

python - AWS BOTO3 S3 python - 调用 HeadObject 操作 : Not Found 时发生错误 (404)

python - 使用 Python 以反射方式获取字段名称

python - 从 scrapy 请求打印 'response'