mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 14:27:27 +00:00
WIP async for history(), unpin
This commit is contained in:
parent
74ac29d27c
commit
daf8e1b1f3
1 changed files with 6 additions and 2 deletions
|
@ -55,7 +55,10 @@ class Administration:
|
||||||
|
|
||||||
if when is None:
|
if when is None:
|
||||||
for channel in channels:
|
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 ch_sent.edit(content='🗄 **Cached** `{}/{}` **channels.**'.format(channels.index(channel) + 1, len(channels)))
|
||||||
await asyncio.sleep(self.RATE_LIMIT)
|
await asyncio.sleep(self.RATE_LIMIT)
|
||||||
elif when == 'before':
|
elif when == 'before':
|
||||||
|
@ -74,7 +77,7 @@ class Administration:
|
||||||
await ch_sent.edit(content='🗄 **Cached** `{}/{}` **channels.**'.format(channels.index(channel) + 1, len(channels)))
|
await ch_sent.edit(content='🗄 **Cached** `{}/{}` **channels.**'.format(channels.index(channel) + 1, len(channels)))
|
||||||
await asyncio.sleep(self.RATE_LIMIT)
|
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)))
|
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))
|
cont_sent = await ctx.send('{} **Continue?** `Y` or `N`'.format(ctx.author.mention))
|
||||||
await self.bot.wait_for('message', check=yes, timeout=10 * 60)
|
await self.bot.wait_for('message', check=yes, timeout=10 * 60)
|
||||||
|
@ -86,6 +89,7 @@ class Administration:
|
||||||
await message.delete()
|
await message.delete()
|
||||||
await del_sent.edit(content='🗑 **Deleted** `{}/{}` **messages.**'.format(history.index(message) + 1, len(history)))
|
await del_sent.edit(content='🗑 **Deleted** `{}/{}` **messages.**'.format(history.index(message) + 1, len(history)))
|
||||||
await asyncio.sleep(self.RATE_LIMIT)
|
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.send('🗑 `{}` **of** <@{}>**\'s messages deleted from** {}**.**'.format(len(history), user, ctx.guild.name))
|
||||||
await ctx.message.add_reaction('✅')
|
await ctx.message.add_reaction('✅')
|
||||||
|
|
Loading…
Reference in a new issue