本文介绍了discord.py:如何使消息无法从channel.purge删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单:
我正在安排一个事件,该事件随后将删除所有消息,但是我希望永远不要从 channel.purge
因为用户可以再写2/3则消息,如果我想精确地使用 channel.purge ,它们可以保留,我知道mee6的功能没有删除2周的邮件。

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.

推荐答案

函数可用于过滤使用 check 参数删除哪些邮件。这意味着您可以创建自己的支票,以检查邮件是否符合您的要求:

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)

这篇关于discord.py:如何使消息无法从channel.purge删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 18:25