Reputation: 15689
I want to delete all the messages in a channel apart from the pinned ones, I tried this solution
On message delete message Discord.py
but it's the non-rewrite version so it's not working for me sadly.
Upvotes: 1
Views: 621
Reputation: 6944
You can only bulk delete (purge) a maximum of 100 messages at a time, but this should do the trick.
@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!")
References:
Upvotes: 1