29
29
public final class CoolMessagesBoardManager extends MessageReceiverAdapter {
30
30
31
31
private static final Logger logger = LoggerFactory .getLogger (CoolMessagesBoardManager .class );
32
- private static final Emoji REACT_EMOJI = Emoji . fromUnicode ( "🌟" ) ;
32
+ private Emoji coolEmoji ;
33
33
private final Predicate <String > boardChannelNamePredicate ;
34
34
private final CoolMessagesBoardConfig config ;
35
35
36
36
public CoolMessagesBoardManager (Config config ) {
37
37
this .config = config .getCoolMessagesConfig ();
38
+ this .coolEmoji = Emoji .fromUnicode (this .config .reactionEmoji ());
38
39
39
40
boardChannelNamePredicate =
40
41
Pattern .compile (this .config .boardChannelPattern ()).asMatchPredicate ();
@@ -44,7 +45,7 @@ public CoolMessagesBoardManager(Config config) {
44
45
public void onMessageReactionAdd (MessageReactionAddEvent event ) {
45
46
final MessageReaction messageReaction = event .getReaction ();
46
47
int originalReactionsCount = messageReaction .hasCount () ? messageReaction .getCount () : 0 ;
47
- boolean isCoolEmoji = messageReaction .getEmoji ().getName (). equals (REACT_EMOJI . getName () );
48
+ boolean isCoolEmoji = messageReaction .getEmoji ().equals (coolEmoji );
48
49
long guildId = event .getGuild ().getIdLong ();
49
50
Optional <TextChannel > boardChannel = getBoardChannel (event .getJDA (), guildId );
50
51
@@ -64,7 +65,7 @@ public void onMessageReactionAdd(MessageReactionAddEvent event) {
64
65
final int newReactionsCount = originalReactionsCount + 1 ;
65
66
if (isCoolEmoji && newReactionsCount >= config .minimumReactions ()) {
66
67
event .retrieveMessage ().queue (message -> {
67
- message .addReaction (REACT_EMOJI ).queue ();
68
+ message .addReaction (coolEmoji ).queue ();
68
69
69
70
insertCoolMessage (boardChannel .get (), message );
70
71
}, e -> logger .warn ("Tried to retrieve cool message but got: {}" , e .getMessage ()));
@@ -123,8 +124,8 @@ private static MessageEmbed createQuoteEmbed(Message message) {
123
124
/**
124
125
* Checks a {@link MessageReaction} to see if the bot has reacted to it.
125
126
*/
126
- private static boolean hasBotReacted (JDA jda , MessageReaction messageReaction ) {
127
- if (!REACT_EMOJI .equals (messageReaction .getEmoji ())) {
127
+ private boolean hasBotReacted (JDA jda , MessageReaction messageReaction ) {
128
+ if (!coolEmoji .equals (messageReaction .getEmoji ())) {
128
129
return false ;
129
130
}
130
131
0 commit comments