1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 21:02:38 +00:00

Checked for channel before looping

This commit is contained in:
Myned 2017-10-11 11:08:18 -04:00
parent 25c28a509f
commit 6f6d6be9df

View file

@ -168,9 +168,14 @@ class Administration:
@checks.del_ctx() @checks.del_ctx()
async def auto_delete(self, ctx): async def auto_delete(self, ctx):
channel = ctx.message.channel channel = ctx.message.channel
u.background.setdefault('management', {}).setdefault('auto_delete', []).append(channel.id)
u.update(u.background, 'background.json') try:
self.bot.loop.create_task(self.on_message(channel)) if channel.id not in u.background['management']['auto_delete']:
self.bot.loop.create_task(self.delete()) u.background.setdefault('management', {}).setdefault('auto_delete', []).append(channel.id)
print('Looping {}'.format(channel.id)) u.update(u.background, 'background.json')
await ctx.send('✅ **Auto-deleting all messages in this channel.**', delete_after=5) 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.**')