所以基本上我已经尝试了很多东西,我已经做了一个数字交换器,但无法弄清楚如何随机化
<%= link_to "Make Admin", user_admin_path(user), method: :post,
data: { confirm: "You sure?" } %>
这就是我的shuffle命令看起来像我只想要一个选择数字1-6的命令并说你滚动了4!还是5!等感谢您的帮助
答案 0 :(得分:0)
使用随机模块,您无需随机播放以获取随机数:
import random
cards = ['1','2','3','4']
await self.send_message(channel, "You chose number {}!".format(random.choice(cards)))
答案 1 :(得分:0)
这可能有用。我已经将它用于8ball命令,但是如果你想掷骰子也应该有效。
@client.command(name='8ball',
description="Answers a yes/no question.",
brief="Answers from the beyond.",
aliases=['eight_ball', 'eightball', '8-ball'],
pass_context=True)
async def eight_ball(context):
possible_responses = [
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'Maybe so.'
]
await context.channel.send(random.choice(possible_responses) + ", " + context.message.author.mention)
答案 2 :(得分:-1)
我设置了代码并且它不起作用,它们没有错误,但这就是它的样子
async def cmd_dice(self, channel, random):
cards = ['1','2','3','4']
await self.send_message(channel, "You chose number {}!".format(random.choice(cards)))
我决定使用import random,因为(self,channel,random):选择那些模块
当我运行命令时,它只是给我描述