繁体   English   中英

不知道如何继续这个不和谐的python代码

[英]Not sure how to continue this discord python code

我写了一个名为guesstall的函数,它是一个数字猜谜游戏。 我正在尝试将代码转换为 discord bot 命令。 Discord 用户应该能够使用-guesstall启动游戏。

我对 Python 非常陌生,今天刚开始使用 discord.py。 任何帮助,将不胜感激。

async def guesstall(message):
    n = int(random.randint(1, 50))

    gjett = 5

    while gjett > 0:
      await message.channel.send("Guess a number")
      t = message.content()
      time.sleep(1)
      if t == n:
       await message.channel.send("Your guess was correct")
       break

      elif t < n:
        await message.channel.send("The number is higher than your guess")
        gjett -= 1
        await message.channel.send("you have", str(gjett), "guesses left.")
        await message.channel.send("")

      elif t > n:
        await message.channel.send("The number is smaller than your number")
        gjett -= 1
        await message.channel.send("You have", str(gjett), "guesses left.")
        await message.channel.send("")

      if gjett == 0:
        await message.channel.send("You failed")
        await message.channel.send("The number was", str(n))

  if message.content.startswith("-guesstall"):
    await guesstall(message)

你应该使用discord.py的重写版本,它会让它更容易

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM