Python Discord.py while True循环
我尝试在一个while-true循环中用15分钟的睡眠更新从bot发送的多条消息Python Discord.py while True循环,python,python-3.x,discord.py,Python,Python 3.x,Discord.py,我尝试在一个while-true循环中用15分钟的睡眠更新从bot发送的多条消息 @commands.cooldown(1, 30, commands.BucketType.user) @bot.command() async def updater(ctx): embed = discord.Embed(title="Title") msg = await ctx.send(embed=embed) all_stock.append(msg
@commands.cooldown(1, 30, commands.BucketType.user)
@bot.command()
async def updater(ctx):
embed = discord.Embed(title="Title")
msg = await ctx.send(embed=embed)
all_stock.append(msg)
while True:
embed = discord.Embed(title="Title")
await msg.edit(embed=embed)
time.sleep(900)
但是一旦我运行了这个函数,其他命令就不起作用了。我已经尝试创建一个单独的线程,但由于一些异步问题,它没有工作。其他命令不工作,因为
time.sleep
被阻塞,您应该改用asyncio.sleep
导入异步IO
尽管如此:
# ...
等待异步睡眠(900)
您必须将其作为自己的线程运行。您已经尝试过了,但由于异步,它无法工作。谢谢您救了我的命