From 6f6d6be9df976730c1ffb084bb76a7b4068a1d40 Mon Sep 17 00:00:00 2001 From: Myned Date: Wed, 11 Oct 2017 11:08:18 -0400 Subject: [PATCH] Checked for channel before looping --- src/main/cogs/management.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index 8fb4d7a..6860623 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -168,9 +168,14 @@ class Administration: @checks.del_ctx() async def auto_delete(self, ctx): channel = ctx.message.channel - u.background.setdefault('management', {}).setdefault('auto_delete', []).append(channel.id) - u.update(u.background, 'background.json') - self.bot.loop.create_task(self.on_message(channel)) - self.bot.loop.create_task(self.delete()) - print('Looping {}'.format(channel.id)) - await ctx.send('✅ **Auto-deleting all messages in this channel.**', delete_after=5) + + try: + if channel.id not in u.background['management']['auto_delete']: + u.background.setdefault('management', {}).setdefault('auto_delete', []).append(channel.id) + u.update(u.background, 'background.json') + self.bot.loop.create_task(self.on_message(channel)) + self.bot.loop.create_task(self.delete()) + print('Looping {}'.format(channel.id)) + await ctx.send('✅ **Auto-deleting all messages in this channel.**', delete_after=5) + else: raise exc.Exists + except exc.Exists: await ctx.send('❌ **Already deleting in this channel.**')