【发布时间】:2021-04-08 23:32:53
【问题描述】:
我正在创建一个不和谐的机器人,我想知道是否有任何第三方库可以与 threading.Timer 做同样的事情,但支持 Discord.client.send 的协程。
@client.command(aliases = ['Timer'])
async def timer(ctx, secs, *message):
await ctx.send(f"Your timer {message} started, and it is gonna take {secs}secs to stop.")
async def stop_timer():
await ctx.send(f'Your timer: {message} is over, it took {secs} secs.')
def timer_over():
asyncio.run(stop_timer())
simpleTimer = threading.Timer(int(secs), timer_over)
simpleTimer.start()
我的代码在那里,我正在寻找一个需要几秒钟的函数,然后在几秒钟后该函数返回一个协程。有点像闹钟。
【问题讨论】:
标签: python discord discord.py coroutine