mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 22:27:28 +00:00
Converted history flattening and check to async iteration
This commit is contained in:
parent
e8b672b98e
commit
5312e7a18b
1 changed files with 9 additions and 5 deletions
|
@ -58,26 +58,30 @@ class Administration:
|
||||||
async for message in channel.history(limit=None):
|
async for message in channel.history(limit=None):
|
||||||
if message.author.id == int(user):
|
if message.author.id == int(user):
|
||||||
history.append(message)
|
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':
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
history.extend(await channel.history(limit=None, before=ref.created_at).flatten())
|
async for message in channel.history(limit=None, before=ref.created_at):
|
||||||
|
if message.author.id == int(user):
|
||||||
|
history.append(message)
|
||||||
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 == 'after':
|
elif when == 'after':
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
history.extend(await channel.history(limit=None, after=ref.created_at).flatten())
|
async for message in channel.history(limit=None, after=ref.created_at):
|
||||||
|
if message.author.id == int(user):
|
||||||
|
history.append(message)
|
||||||
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 == 'about':
|
elif when == 'about':
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
history.extend(await channel.history(limit=101, about=ref.created_at).flatten())
|
async for message in channel.history(limit=None, about=ref.created_at):
|
||||||
|
if message.author.id == int(user):
|
||||||
|
history.append(message)
|
||||||
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 == 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)
|
||||||
|
|
Loading…
Reference in a new issue