is there a bulkDelete equivalent of JDA?

659 Views Asked by At

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.

1

There are 1 best solutions below

0
On BEST ANSWER
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.