Discord.py while True循环

2024-06-16 12:43:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试在一个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)

    while True:
        embed = discord.Embed(title="Title")
        await msg.edit(embed=embed)
        time.sleep(900)

但是一旦我运行了这个函数,其他命令就不起作用了。我已经尝试创建一个单独的线程,但由于一些异步问题,它没有工作


Tags: true消息titlebotmsgembedawaitcommands