Search code examples
discordpycord

How to get messages in a channel then delete them?


How to get a certain amount of messages in a channel to delete them (Pycord)

I want to create a /purge command to delete a certain amount of messages from a channel. Is there a way to get messages from a specific channel, and then delete them?

Note: A lot of the duplicates that were flagged are either from the wrong library or the wrong language entirely.


Solution

  • You can just use the built-in library channel.purge.

    Or the less suitable async for ... in channel.history.

    In both cases, you need to make some sort of checking function.