【问题标题】:How do i make my bot have a random input between 1 and 100我如何让我的机器人有一个介于 1 到 100 之间的随机输入
【发布时间】:2021-06-18 14:04:47
【问题描述】:

我需要帮助我的 Discord 机器人说出 1 到 100 之间的数字吗?这是我的代码行。

@client.command() 异步定义随机数(ctx): 等待 ctx.send("?")

【问题讨论】:

  • import random, random.randint(1, 100)

标签: python discord bots


【解决方案1】:
import random    

#...

@client.command()
async def random_number(ctx):
    await ctx.send(random.randint(1, 100))

【讨论】:

    【解决方案2】:
    import random
    
    @client.command()
    async def random_number(ctx):
        await ctx.send(str(random.randint(1, 100))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-03
      • 2012-03-16
      • 1970-01-01
      • 2011-01-23
      • 2016-01-08
      • 1970-01-01
      相关资源
      最近更新 更多