我想让我的机器人在一定时间后会改变。 (在这种情况下为5分钟)
@client.event
async def on_ready():
while True:
presence = randint(1, 5)
if presence == 1:
await client.change_presence(game=discord.Game(name='with commands', type=1))
elif presence == 2:
await client.change_presence(game=discord.Game(name='you', type=3))
elif presence == 3:
await client.change_presence(game=discord.Game(name='and watching', type=2))
elif presence == 4:
await client.change_presence(game=discord.Game(name='Youtube Videos', type=3))
elif presence == 5:
await client.change_presence(game=discord.Game(name='like a boss', type=1))
time.sleep(300)
问题是,在300秒之后,我的机器人在不和谐的情况下脱机了,而python文件仍在运行,并且没有显示任何错误。知道是什么原因造成的吗?谢谢。
答案 0 :(得分:1)
await asyncio.sleep(300)
阻止您的编程,并且连接超时。
使用18/11/13 00:00:50 585 17353 296883 666
18/11/13 00:01:50 965 26536 216201 558
18/11/13 00:02:50 990 38685 390537 768
18/11/13 00:03:50 1004 22435 377633 404
18/11/13 00:04:50 709 15754 161435 12062
18/11/13 00:05:50 96 7084 403551 0
18/11/13 00:06:50 107 14588 504683 597
18/11/13 00:07:50 115 27562 457555 814
awk '{sum+=$4; ++n} END {print " Tot="n," Avg="sum/n}' filename
insead。