DiscordBot JDA get all Messages in a Channel
Hey I tried to get all the messages from a channel but I always failed. I've already searched for similar questions and tried them but I couldn't find a solution...
I also tried @Minn's solution but it didn't work:
channel.getHistory().retrievePast(2)
.map(messages -> messages.get(1)) // this assumes that the channel has at least 2 messages
.queue(message -> { // success callback
System.out.println("The second most recent message is: " + message.getContentDisplay();
});
Or rather, I didn't manage to rescript it so that all messages are collected.
I found a Solution...
MessageHistory history = MessageHistory.getHistoryFromBeginning(channel).complete();
List<Message> mess = history.getRetrievedHistory();