peppewarrior1
peppewarrior1

Reputation: 55

discord.py: how to make a message undeletable from channel.purge

My question is very simple: I am scheduling an event that will then delete all messages but I would like the first message never to be deleted from channel.purge. Since users could write 2/3 more messages they could remain if I wanted to be precise when I use channel.purge and I know of a function of mee6 that did not delete 2 week old messages.

Upvotes: 1

Views: 1280

Answers (1)

creed
creed

Reputation: 1427

The discord.TextChannel.purge function allows you filter out what messages are deleted using the check parameter. This means you can create your own check that will check the message to meet your requirements:

def check(m):
    messageID = 1234567890 # Replace this with the message you want to keep
    return m.id != messageID # Bot will ignore the message if it finds the specified Message ID

await channel.purge(check=check)

Upvotes: 3

Related Questions