mirror of
https://github.com/BluemediaGER/discord-cleanup-bot.git
synced 2024-11-23 00:05:29 +01:00
Don't delete pinned messages
This commit is contained in:
parent
296db66e28
commit
a356cf8db4
3
bot.py
3
bot.py
|
@ -50,7 +50,8 @@ class BotClient(discord.Client):
|
||||||
before = now - timedelta(hours=persisted_channel.retention_hours)
|
before = now - timedelta(hours=persisted_channel.retention_hours)
|
||||||
after = now - timedelta(days=14)
|
after = now - timedelta(days=14)
|
||||||
messages = [message async for message in channel.history(before=before, after=after)]
|
messages = [message async for message in channel.history(before=before, after=after)]
|
||||||
message_chunks = divide_chunks(messages, 100)
|
filtered_messages = filter(lambda message: message.pinned == False, messages)
|
||||||
|
message_chunks = divide_chunks(filtered_messages, 100)
|
||||||
for chunk in message_chunks:
|
for chunk in message_chunks:
|
||||||
await channel.delete_messages(chunk, reason='Configured retention period expired.')
|
await channel.delete_messages(chunk, reason='Configured retention period expired.')
|
||||||
persisted_channel.last_pruned=now
|
persisted_channel.last_pruned=now
|
||||||
|
|
Loading…
Reference in a new issue