discord.py删除除固定消息外的消息

时间:2020-06-03 19:55:45

标签: discord.py

我想删除频道中除固定消息之外的所有消息,我尝试使用On message delete message Discord.py,但它是非重写版本,因此无法正常工作

1 个答案:

答案 0 :(得分:1)

您一次只能批量删除(清除)最多100条消息,但这可以解决问题。

@client.command()
async def purge(ctx):
    def not_pinned(msg):
        return not msg.pinned
    purged = await ctx.channel.purge(limit=100, check=not_pinned)
    await ctx.send(f"Successfully removed {len(purged)} non-pinned messages!")

参考:

相关问题