首页 > 解决方案 > Discord.py 静态定时器

问题描述

我如何有一个静态计时器,用户可以只说 ??abc 并且机器人从让我们说 300 秒开始倒计时 我希望机器人编辑相同的 mssg 而不是发送多个 mssg 谢谢

标签: discord.pydiscord.py-rewrite

解决方案


    @client.command(help="Countdown from specified seconds!")
async def countdown(ctx, t: int):
    msg = await ctx.send(f'Counting down from {t}!')

    while t > 0:
        t -=1
        await msg.edit(content=f'{t} seconds remaining')
        await asyncio.sleep(1)

    await ctx.send(f'Countdown end reached! {ctx.message.author.mention}')

明白这一切意味着什么,不想喂任何人;)。总帐


推荐阅读