如何取消discord.py中的asyncio.sleep命令

问题描述 投票:0回答:1

我的机器人中有一个计时器命令,它使用asyncio.sleep。如果用户希望取消命令,我想发出命令。

@bot.command()
async def timer(ctx, time: int):
   await ctx.send('Timer set for ' + str(time) + ' seconds')
   await asyncio.sleep(time)
   await ctx.send('Time over!')

有没有一种方法,(我宁愿不创建新文件的方法,也要在同一个文件中进行此操作)

asynchronous discord python-asyncio sleep discord.py
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.