【问题标题】:How can i make a command that shows a random percentage in the response? Discord python如何制作一个在响应中显示随机百分比的命令?不和谐蟒蛇
【发布时间】:2020-10-09 20:07:21
【问题描述】:

好的,所以我想为我正在执行的不和谐机器人发出命令,当用户执行命令时,机器人会以“您的船费是 [随机百分比]”作为响应,我该怎么做?

【问题讨论】:

    标签: discord discord.py


    【解决方案1】:

    您可以使用随机库函数。如randint()w3Schools on randint()

    import random
    @bot.command()
    async def commandName(ctx):
        percentage = (random.randint(0, 100))
        await ctx.send(f'Your shiprate is {percentage}')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-07
      • 2019-02-20
      • 2021-05-13
      • 2018-05-06
      • 2021-06-17
      • 2021-05-22
      • 2017-04-29
      • 2021-04-19
      相关资源
      最近更新 更多