【问题标题】:why discord.py gives error to convery message to a number [closed]为什么discord.py会出错以将消息传达给数字[关闭]
【发布时间】:2021-05-26 00:07:12
【问题描述】:

我在这里需要帮助,我不知道我的代码有什么问题。谁能解释一下?

@client.command()
async def gameONE(ctx):
    await ctx.send("Welcome to the GAME! (between 1-20) ")

    pcNumber = random.randint(0,21)
    print(pcNumber)

    await ctx.send("Enter a number please.. ")
    userNumber = await client.wait_for("message")
    corro = float(userNumber.contect)
    if pcNumber > corro:
        ctx.send("PC won!")
    elif corro > pcNumber:
        ctx.send("YOU won!")
    else:
        ctx.send("I didnt understand")

它给了我这个错误:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Message' object has no attribute 'contect'

【问题讨论】:

  • 你的意思是Message.content

标签: python error-handling discord.py


【解决方案1】:

userNumber.contect 应改为 userNumber.content

【讨论】:

  • 感谢您的帮助
  • await 放在每个ctx.send() 命令之前。
  • 如果正确,请务必将此答案标记为正确。
猜你喜欢
  • 2014-08-09
  • 1970-01-01
  • 2011-07-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-31
  • 2017-07-17
相关资源
最近更新 更多