I've made a Discord bot that loops a task every 15 minutes. I've got it working as intended but now I want to add a command that to stop and start the task. Here's part of my code:
class a(commands.Cog):
def __init__(self, client):
self.client = client
@tasks.loop(minutes=15.0)
async def b(self):
#do something
b.start(self)
@commands.command(pass_context=True)
async def stopb(self, ctx):
b.cancel(self)
def setup(client):
client.add_cog(a(client))
When I use the command stopb an error is returned saying that that stopb is not defined. I've tried to change the indentation but then the error is that b is not defined. The code above is part of a cog. In my main file I have a command that can load and unload the cogs but this does not stop the task.