Reputation: 7
In discord.js, there is a way to delete multiple messages in a channel (eventually making a clear command)
But I can't find the equivalent to Java Discord API. What I've tried is message.getChannel().getLatestMessageId()
in a for statement, but it gave me exceptions when doing so, and did not delete any message ofc.
Upvotes: 0
Views: 740
Reputation: 6134
channel.getIterableHistory()
.takeAsync(amount)
.thenAccept(channel::purgeMessages);
Bulk delete is limited to up to 100 messages each and can only delete messages sent within the past 2 weeks. purgeMessages
will split it into chunks of 100 and delete individual messages when they are too old. This can take a while since message delete is a very strictly limited endpoint.
Upvotes: 1