mirror of
https://github.com/myned/modufur.git
synced 2024-12-23 22:27:27 +00:00
Added ability to queue messages for deletion if they exist before cache
This commit is contained in:
parent
f85e969dc6
commit
f706b4a18d
1 changed files with 7 additions and 3 deletions
|
@ -19,7 +19,7 @@ class Administration:
|
||||||
|
|
||||||
for channel in u.tasks.get('management', {}).get('auto_delete', []):
|
for channel in u.tasks.get('management', {}).get('auto_delete', []):
|
||||||
temp = self.bot.get_channel(channel)
|
temp = self.bot.get_channel(channel)
|
||||||
self.bot.loop.create_task(self.on_message(temp))
|
self.bot.loop.create_task(self.queue_on_message(temp))
|
||||||
self.bot.loop.create_task(self.delete())
|
self.bot.loop.create_task(self.delete())
|
||||||
print('Looping #{}'.format(temp.name))
|
print('Looping #{}'.format(temp.name))
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ class Administration:
|
||||||
except err.NotFound:
|
except err.NotFound:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def on_message(self, channel):
|
async def queue_on_message(self, channel):
|
||||||
def check(msg):
|
def check(msg):
|
||||||
if msg.content.lower() == 'stop' and msg.channel is channel and msg.author.guild_permissions.administrator:
|
if msg.content.lower() == 'stop' and msg.channel is channel and msg.author.guild_permissions.administrator:
|
||||||
raise exc.Abort
|
raise exc.Abort
|
||||||
|
@ -155,6 +155,10 @@ class Administration:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
async for message in channel.history():
|
||||||
|
if not msg.pinned:
|
||||||
|
await self.queue.put(message)
|
||||||
|
|
||||||
while not self.bot.is_closed():
|
while not self.bot.is_closed():
|
||||||
message = await self.bot.wait_for('message', check=check)
|
message = await self.bot.wait_for('message', check=check)
|
||||||
await self.queue.put(message)
|
await self.queue.put(message)
|
||||||
|
@ -178,7 +182,7 @@ class Administration:
|
||||||
if channel.id not in u.tasks.setdefault('management', {}).setdefault('auto_delete', []):
|
if channel.id not in u.tasks.setdefault('management', {}).setdefault('auto_delete', []):
|
||||||
u.tasks['management']['auto_delete'].append(channel.id)
|
u.tasks['management']['auto_delete'].append(channel.id)
|
||||||
u.dump(u.tasks, 'cogs/tasks.pkl')
|
u.dump(u.tasks, 'cogs/tasks.pkl')
|
||||||
self.bot.loop.create_task(self.on_message(channel))
|
self.bot.loop.create_task(self.queue_on_message(channel))
|
||||||
self.bot.loop.create_task(self.delete())
|
self.bot.loop.create_task(self.delete())
|
||||||
print('Looping #{}'.format(channel.name))
|
print('Looping #{}'.format(channel.name))
|
||||||
await ctx.send('✅ **Auto-deleting all messages in this channel.**', delete_after=5)
|
await ctx.send('✅ **Auto-deleting all messages in this channel.**', delete_after=5)
|
||||||
|
|
Loading…
Reference in a new issue