From daf8e1b1f3837582a199be7e300f6b191be9983d Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 17 Oct 2017 02:36:11 -0400 Subject: [PATCH] WIP async for history(), unpin --- src/main/cogs/management.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index c14f21e..8e1d8e3 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -55,7 +55,10 @@ class Administration: if when is None: for channel in channels: - history.extend(await channel.history(limit=None).flatten()) + async for message in channel.history(limit=None): + if message.author.id == user: + history.append(message) + # history.extend(await channel.history(limit=None).flatten()) await ch_sent.edit(content='🗄 **Cached** `{}/{}` **channels.**'.format(channels.index(channel) + 1, len(channels))) await asyncio.sleep(self.RATE_LIMIT) elif when == 'before': @@ -74,7 +77,7 @@ class Administration: await ch_sent.edit(content='🗄 **Cached** `{}/{}` **channels.**'.format(channels.index(channel) + 1, len(channels))) await asyncio.sleep(self.RATE_LIMIT) - history = [message for message in history if message.author.id is user] + # history = [message for message in history if message.author.id == user] est_sent = await ctx.send('⏱ **Estimated time to delete history:** `{}m {}s`'.format(int(self.RATE_LIMIT * len(history) / 60), int(self.RATE_LIMIT * len(history) % 60))) cont_sent = await ctx.send('{} **Continue?** `Y` or `N`'.format(ctx.author.mention)) await self.bot.wait_for('message', check=yes, timeout=10 * 60) @@ -86,6 +89,7 @@ class Administration: await message.delete() await del_sent.edit(content='🗑 **Deleted** `{}/{}` **messages.**'.format(history.index(message) + 1, len(history))) await asyncio.sleep(self.RATE_LIMIT) + await del_sent.unpin() await ctx.send('🗑 `{}` **of** <@{}>**\'s messages deleted from** {}**.**'.format(len(history), user, ctx.guild.name)) await ctx.message.add_reaction('✅')