【发布时间】:2019-08-24 11:40:28
【问题描述】:
我正在尝试让我的后台任务使用random.choice() 在不同的频道中发送。当我打开机器人时,它只会发送一个随机频道并且只发送那个频道。有没有办法在每次循环时在不同的频道中发送?
async def test_loop():
await client.wait_until_ready()
channels = ['550528972226', '5149003563352', '514900351233', '5799132312340']
channel = client.get_channel(random.choice(channels))
while not client.is_closed:
time = random.randint(1,5)+random.random()
monies = random.randint(100,250)
emojigrab = dollar
emojimsg = await client.send_message(channel, emojigrab)
await client.add_reaction(emojimsg, hand)
pay = await client.wait_for_reaction(emoji=hand, message=emojimsg, timeout=1800,
check=lambda reaction, user: user != client.user)
if pay:
await client.delete_message(emojimsg)
await client.send_message(channel, "{} collects {:,} dollars".format(pay.user.mention, monies))
add_dollars(pay.user, monies)
await asyncio.sleep(int(time))
【问题讨论】:
标签: python python-3.x discord discord.py