@@ -57,12 +57,11 @@ public void onMessageReceived(MessageReceivedEvent event) {
5757
5858 private static void createThread (Message message ) {
5959 String threadTitle = generateThreadTitle (message );
60- message .createThreadChannel (threadTitle ).queue (null , exception -> {
60+ message .createThreadChannel (threadTitle ).queue (_ -> {
61+ }, exception -> {
6162 if (exception instanceof ErrorResponseException responseException
6263 && responseException .getErrorResponse () == ErrorResponse .UNKNOWN_MESSAGE ) {
63- logger .info (
64- "Create Thread skipped: message was already deleted (likely by scamblocker) - ID: {}" ,
65- message .getIdLong ());
64+ logger .info ("Create Thread skipped: ID: {}" , message .getIdLong ());
6665 return ;
6766
6867 }
@@ -102,24 +101,24 @@ private static void reactWith(String emojiName, Emoji fallbackEmoji, Guild guild
102101 emojiName );
103102 return message .addReaction (fallbackEmoji );
104103 }).queue (ignored -> {
105- }, exception -> {
106- if (exception instanceof ErrorResponseException responseException ) {
107- if (responseException .getErrorResponse () == ErrorResponse .REACTION_BLOCKED ) {
108- // User blocked the bot, hence the bot can not add reactions to their messages.
109- // Nothing we can do here.
110- return ;
111- }
112- if (responseException .getErrorResponse () == ErrorResponse .UNKNOWN_MESSAGE ) {
113- logger .info (
114- "Reaction skipped: message was already deleted (likely by scamblocker) - ID: {}" ,
115- message .getIdLong ());
116- return ;
117- }
104+ }, exception -> handleReactionFailure (exception , message .getIdLong ()));
105+ }
106+
107+ private static void handleReactionFailure (Throwable exception , long messageId ) {
108+ if (exception instanceof ErrorResponseException responseException ) {
109+ if (responseException .getErrorResponse () == ErrorResponse .REACTION_BLOCKED ) {
110+ // User blocked the bot, hence the bot can not add reactions to their messages.
111+ return ;
118112 }
119- logger .error ("Attempted to react to a suggestion, but failed" , exception );
120- });
113+ if (responseException .getErrorResponse () == ErrorResponse .UNKNOWN_MESSAGE ) {
114+ logger .info ("Reaction skipped ID: {}" , messageId );
115+ return ;
116+ }
117+ }
118+ logger .error ("Attempted to react to a suggestion, but failed" , exception );
121119 }
122120
121+
123122 private static Optional <RichCustomEmoji > getEmojiByName (String name , Guild guild ) {
124123 return guild .getEmojisByName (name , false ).stream ().findAny ();
125124 }
0 commit comments