From e997c242eab21ee368e1c3c5a0a338567b5703d1 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 02:15:20 -0500 Subject: [PATCH] Added task removal on guild leave --- src/main/run.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/run.py b/src/main/run.py index 898018d..93ccc58 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -114,6 +114,17 @@ async def on_command_completion(ctx): if ctx.command.name != 'lastcommand': u.last_commands[ctx.author.id] = ctx +@bot.event +async def on_guild_remove(guild): + print(f'LEFT : {guild.name}') + + for task, idents in u.tasks.items(): + for channel in guild.channels: + if channel.id in idents: + idents.remove(channel.id) + print(f'STOPPED : {task} in #{channel.id}') + u.dump(u.tasks, 'cogs/tasks.pkl') + # d.opus.load_opus('opus')