purge
Purge messages from a MessageChannel. Will not purge pinned messages by default, but that can be configured using the predicate.
Return
the MessageChannel that has messages purged.
Samples
import dev.jaims.kda.channel.purge
import dev.jaims.kda.channel.send
import dev.jaims.kda.message.buildEmbed
import dev.jaims.kda.message.cleanup
import net.dv8tion.jda.api.entities.MessageChannel
import net.dv8tion.jda.api.entities.TextChannel
import net.dv8tion.jda.api.entities.User
fun main() {
//sampleStart
// send a message and clean it up
channel.send(buildEmbed { setDescription("This is my embed!") }).cleanup().queue()
// send a message
textChannel.send("This is an example!").queue()
// purge a channel with a custom predicate
textChannel.purge { it.author != someUser && !it.isPinned }
//sampleEnd
}
Parameters
limit
the amount of messages to purge in that channel.
predicate
the requirement to be met for the message purge. Defaults to not purging pinned messages.