我的机器人中有一个计时器命令,它使用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!')
有没有一种方法,(我宁愿不创建新文件的方法,也要在同一个文件中进行此操作)