Issue
I am making a discord bot, and I can't figure out a way to change the time interval for a task
@tasks.loop(seconds=10)
async def auto_meme(self, ctx):
await ctx.send(meme) #handled
@commands.command()
async def start_meme(self, ctx):
await self.auto_meme.start()
I tried
async def auto_meme(self, ctx):
await ctx.send(meme) #handled
@commands.command()
async def start_meme(self, ctx, args: convert_to_seconds = 10):
self.auto_meme_instance = tasks.loop(args)(self.auto_meme)
await self.auto_meme_instance.start(ctx)
But when I do this, I cannot cancel or stop the task.
Solution
You can simply use Loop.change_interval
auto_meme.change_interval(seconds=1)
Reference:
Answered By - Łukasz Kwieciński
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.