9
9
import net .dv8tion .jda .api .entities .channel .concrete .TextChannel ;
10
10
import net .dv8tion .jda .api .entities .emoji .Emoji ;
11
11
import net .dv8tion .jda .api .events .message .react .MessageReactionAddEvent ;
12
+ import net .dv8tion .jda .api .requests .restaction .MessageCreateAction ;
12
13
import org .slf4j .Logger ;
13
14
import org .slf4j .LoggerFactory ;
14
15
@@ -64,11 +65,12 @@ public void onMessageReactionAdd(MessageReactionAddEvent event) {
64
65
65
66
final int newReactionsCount = originalReactionsCount + 1 ;
66
67
if (isCoolEmoji && newReactionsCount >= config .minimumReactions ()) {
67
- event .retrieveMessage ().queue (message -> {
68
- message .addReaction (coolEmoji ).queue ();
69
-
70
- insertCoolMessage (boardChannel .get (), message );
71
- }, e -> logger .warn ("Tried to retrieve cool message but got: {}" , e .getMessage ()));
68
+ event .retrieveMessage ()
69
+ .queue (message -> message .addReaction (coolEmoji )
70
+ .flatMap (v -> insertCoolMessage (boardChannel .get (), message ))
71
+ .queue (),
72
+ e -> logger .warn ("Tried to retrieve cool message but got: {}" ,
73
+ e .getMessage ()));
72
74
}
73
75
}
74
76
@@ -89,9 +91,12 @@ private Optional<TextChannel> getBoardChannel(JDA jda, long guildId) {
89
91
90
92
/**
91
93
* Inserts a message to the specified text channel
94
+ *
95
+ * @return a {@link MessageCreateAction} of the call to make
92
96
*/
93
- private static void insertCoolMessage (TextChannel boardChannel , Message message ) {
94
- boardChannel .sendMessageEmbeds (Collections .singleton (createQuoteEmbed (message ))).queue ();
97
+ private static MessageCreateAction insertCoolMessage (TextChannel boardChannel ,
98
+ Message message ) {
99
+ return boardChannel .sendMessageEmbeds (Collections .singleton (createQuoteEmbed (message )));
95
100
}
96
101
97
102
/**
0 commit comments