@@ -59,13 +59,6 @@ public void onMessageReactionAdd(MessageReactionAddEvent event) {
5959 logger .debug ("Received MessageReactionAddEvent: messageId={}, channelId={}, userId={}" ,
6060 event .getMessageId (), event .getChannel ().getId (), event .getUserId ());
6161
62- final MessageReaction messageReaction = event .getReaction ();
63-
64- if (hasAlreadyForwardedMessage (event .getJDA (), messageReaction )) {
65- logger .debug ("Message has already been forwarded by the bot. Skipping." );
66- return ;
67- }
68-
6962 final long guildId = event .getGuild ().getIdLong ();
7063
7164 Optional <TextChannel > boardChannelOptional = findQuoteBoardChannel (event .getJDA (), guildId );
@@ -85,6 +78,11 @@ public void onMessageReactionAdd(MessageReactionAddEvent event) {
8578 }
8679
8780 event .retrieveMessage ().queue (message -> {
81+ if (hasAlreadyForwardedMessage (message )) {
82+ logger .debug ("Message has already been forwarded by the bot. Skipping." );
83+ return ;
84+ }
85+
8886 float emojiScore = calculateMessageScore (message .getReactions ());
8987
9088 if (emojiScore < config .minimumScoreToTrigger ()) {
@@ -137,16 +135,13 @@ private Optional<TextChannel> findQuoteBoardChannel(JDA jda, long guildId) {
137135 }
138136
139137 /**
140- * Checks a {@link MessageReaction} to see if the bot has reacted to it .
138+ * Checks whether the bot has already reacted to the given message with its marker emoji .
141139 */
142- private boolean hasAlreadyForwardedMessage (JDA jda , MessageReaction messageReaction ) {
143- if (!botEmoji .equals (messageReaction .getEmoji ())) {
144- return false ;
145- }
146-
147- return messageReaction .retrieveUsers ()
148- .parallelStream ()
149- .anyMatch (user -> jda .getSelfUser ().getIdLong () == user .getIdLong ());
140+ private boolean hasAlreadyForwardedMessage (Message message ) {
141+ return message .getReactions ()
142+ .stream ()
143+ .filter (reaction -> botEmoji .equals (reaction .getEmoji ()))
144+ .anyMatch (MessageReaction ::isSelf );
150145 }
151146
152147 private float calculateMessageScore (List <MessageReaction > reactions ) {
0 commit comments