How to retrieve the first message of a forum post #2424
Answered
by
MinnDevelopment
AlexCai2019
asked this question in
Questions and Help
-
I tried using private static final Emoji reminder_ribbon = Emoji.fromUnicode("🎗️");
private static final String reminder_ribbonFormat = reminder_ribbon.getFormatted();
public static void archiveForumPost(ThreadChannel forumPost)
{
forumPost.retrieveParentMessage().queue(message ->
{
if (message.getReactions().stream().anyMatch(messageReaction -> messageReaction.getEmoji().getFormatted().equals(reminder_ribbonFormat)))
message.removeReaction(reminder_ribbon, forumPost.getJDA().getSelfUser()).queue();
});
} |
Beta Was this translation helpful? Give feedback.
Answered by
MinnDevelopment
Mar 21, 2023
Replies: 2 comments 1 reply
-
You can use getIterableHistory: channel.getIterableHistory()
.reverse() // iterate from the beginning of the channel history
.limit(1) // only take first message
.queue(messages -> {
Message message = messages.get(0); // get first from list (might throw if channel is empty)
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
AlexCai2019
-
Update: after v5.0.0-beta.10, you can use retrieveStartMessage: channel.retrieveStartMessage().queue(message ->
{
///TODO: put your code here.
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use getIterableHistory: