discord.py 调度程序停止
discord.py scheduler to stop
当我说 -startc
计划开始时,我使用 apscheduler.schedulers.asyncio.AsyncIOScheduler 安排任务。当我说 stopc
时,我希望计划停止。
@commands.command()
@commands.has_permissions(administrator=True)
async def startc(self, ctx):
channel = ctx.channel.id
self.client.scheduler.add_job(self.cardDrop, CronTrigger(second='0, 10, 20, 30, 40, 50'), args=[channel])
@commands.command()
@commands.has_permissions(administrator=True)
async def stopc(self, ctx):
使用stop()
@commands.command()
@commands.has_permissions(administrator=True)
async def startc(self, ctx):
channel = ctx.channel.id
self.client.scheduler.add_job(self.cardDrop, CronTrigger(second='0, 10, 20, 30, 40, 50'), args=[channel])
@commands.command()
@commands.has_permissions(administrator=True)
async def stopc(self, ctx):
self.client.scheduler.stop()
我找到了答案谢谢你的帮助。
是
self.client.scheduler.shutdown(wait=False)
如果您想立即停止任务,则为 False。真正是当你想等到任务完成然后停止
当我说 -startc
计划开始时,我使用 apscheduler.schedulers.asyncio.AsyncIOScheduler 安排任务。当我说 stopc
时,我希望计划停止。
@commands.command()
@commands.has_permissions(administrator=True)
async def startc(self, ctx):
channel = ctx.channel.id
self.client.scheduler.add_job(self.cardDrop, CronTrigger(second='0, 10, 20, 30, 40, 50'), args=[channel])
@commands.command()
@commands.has_permissions(administrator=True)
async def stopc(self, ctx):
使用stop()
@commands.command()
@commands.has_permissions(administrator=True)
async def startc(self, ctx):
channel = ctx.channel.id
self.client.scheduler.add_job(self.cardDrop, CronTrigger(second='0, 10, 20, 30, 40, 50'), args=[channel])
@commands.command()
@commands.has_permissions(administrator=True)
async def stopc(self, ctx):
self.client.scheduler.stop()
我找到了答案谢谢你的帮助。
是
self.client.scheduler.shutdown(wait=False)
如果您想立即停止任务,则为 False。真正是当你想等到任务完成然后停止