From 7ca4496f8adb933d08a6f29bd7e030f391db09de Mon Sep 17 00:00:00 2001 From: Bryce72 Date: Thu, 12 Feb 2026 20:49:46 -0500 Subject: [PATCH 1/4] SuggestionsUpDownVoter should have UNKNOWN_MESSAGE exception gracefully with an INFO log instead #1414 --- .../basic/SuggestionsUpDownVoter.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java index 5dbbdbf8b2..2489ec7fb3 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java @@ -50,13 +50,23 @@ public void onMessageReceived(MessageReceivedEvent event) { Message message = event.getMessage(); createThread(message); + reactWith(config.getUpVoteEmoteName(), FALLBACK_UP_VOTE, guild, message); reactWith(config.getDownVoteEmoteName(), FALLBACK_DOWN_VOTE, guild, message); } private static void createThread(Message message) { String threadTitle = generateThreadTitle(message); - message.createThreadChannel(threadTitle).queue(); + message.createThreadChannel(threadTitle).queue(null, exception -> { + if (exception instanceof ErrorResponseException responseException + && responseException.getErrorResponse() == ErrorResponse.UNKNOWN_MESSAGE) { + logger.info( + "Create Thread skipped: message was already deleted (likely by scamblocker) - ID: {}", + message.getIdLong()); + return; + + } + }); } /** @@ -93,13 +103,19 @@ private static void reactWith(String emojiName, Emoji fallbackEmoji, Guild guild return message.addReaction(fallbackEmoji); }).queue(ignored -> { }, exception -> { - if (exception instanceof ErrorResponseException responseException - && responseException.getErrorResponse() == ErrorResponse.REACTION_BLOCKED) { - // User blocked the bot, hence the bot can not add reactions to their messages. - // Nothing we can do here. - return; + if (exception instanceof ErrorResponseException responseException) { + if (responseException.getErrorResponse() == ErrorResponse.REACTION_BLOCKED) { + // User blocked the bot, hence the bot can not add reactions to their messages. + // Nothing we can do here. + return; + } + if (responseException.getErrorResponse() == ErrorResponse.UNKNOWN_MESSAGE) { + logger.info( + "Reaction skipped: message was already deleted (likely by scamblocker) - ID: {}", + message.getIdLong()); + return; + } } - logger.error("Attempted to react to a suggestion, but failed", exception); }); } From 775ad21858b300e10935da9c8baa68981b2ea238 Mon Sep 17 00:00:00 2001 From: Bryce72 Date: Fri, 13 Feb 2026 08:35:56 -0500 Subject: [PATCH 2/4] SuggestionsUpDownVoter should have UNKNOWN_MESSAGE exception gracefully with an INFO log instead #1414 Refactored and idomaticized --- .../basic/SuggestionsUpDownVoter.java | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java index 2489ec7fb3..3960400f20 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java @@ -57,12 +57,11 @@ public void onMessageReceived(MessageReceivedEvent event) { private static void createThread(Message message) { String threadTitle = generateThreadTitle(message); - message.createThreadChannel(threadTitle).queue(null, exception -> { + message.createThreadChannel(threadTitle).queue(_ -> { + }, exception -> { if (exception instanceof ErrorResponseException responseException && responseException.getErrorResponse() == ErrorResponse.UNKNOWN_MESSAGE) { - logger.info( - "Create Thread skipped: message was already deleted (likely by scamblocker) - ID: {}", - message.getIdLong()); + logger.info("Create Thread skipped: ID: {}", message.getIdLong()); return; } @@ -102,24 +101,24 @@ private static void reactWith(String emojiName, Emoji fallbackEmoji, Guild guild emojiName); return message.addReaction(fallbackEmoji); }).queue(ignored -> { - }, exception -> { - if (exception instanceof ErrorResponseException responseException) { - if (responseException.getErrorResponse() == ErrorResponse.REACTION_BLOCKED) { - // User blocked the bot, hence the bot can not add reactions to their messages. - // Nothing we can do here. - return; - } - if (responseException.getErrorResponse() == ErrorResponse.UNKNOWN_MESSAGE) { - logger.info( - "Reaction skipped: message was already deleted (likely by scamblocker) - ID: {}", - message.getIdLong()); - return; - } + }, exception -> handleReactionFailure(exception, message.getIdLong())); + } + + private static void handleReactionFailure(Throwable exception, long messageId) { + if (exception instanceof ErrorResponseException responseException) { + if (responseException.getErrorResponse() == ErrorResponse.REACTION_BLOCKED) { + // User blocked the bot, hence the bot can not add reactions to their messages. + return; } - logger.error("Attempted to react to a suggestion, but failed", exception); - }); + if (responseException.getErrorResponse() == ErrorResponse.UNKNOWN_MESSAGE) { + logger.info("Reaction skipped ID: {}", messageId); + return; + } + } + logger.error("Attempted to react to a suggestion, but failed", exception); } + private static Optional getEmojiByName(String name, Guild guild) { return guild.getEmojisByName(name, false).stream().findAny(); } From 26c2c90c83ebab4f3df29e4d8919eeacbbd85898 Mon Sep 17 00:00:00 2001 From: Bryce72 Date: Fri, 13 Feb 2026 08:43:50 -0500 Subject: [PATCH 3/4] SuggestionsUpDownVoter should have UNKNOWN_MESSAGE exception gracefully with an INFO log instead #1414 Refactored and idomaticized -- oops updated to make sure its similar via both react and create thread --- .../tjbot/features/basic/SuggestionsUpDownVoter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java index 3960400f20..bebac4825a 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java @@ -100,7 +100,7 @@ private static void reactWith(String emojiName, Emoji fallbackEmoji, Guild guild "Unable to vote on a suggestion with the configured emoji ('{}'), using fallback instead.", emojiName); return message.addReaction(fallbackEmoji); - }).queue(ignored -> { + }).queue(_ -> { }, exception -> handleReactionFailure(exception, message.getIdLong())); } From 201dba868b3ecd19fa54f449ea252fecb9cd12e9 Mon Sep 17 00:00:00 2001 From: Bryce72 Date: Fri, 13 Feb 2026 09:04:50 -0500 Subject: [PATCH 4/4] updated info log strings --- .../tjbot/features/basic/SuggestionsUpDownVoter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java index bebac4825a..e07682725f 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java @@ -61,7 +61,7 @@ private static void createThread(Message message) { }, exception -> { if (exception instanceof ErrorResponseException responseException && responseException.getErrorResponse() == ErrorResponse.UNKNOWN_MESSAGE) { - logger.info("Create Thread skipped: ID: {}", message.getIdLong()); + logger.info("Failed to start suggestion thread: source message deleted"); return; } @@ -101,17 +101,17 @@ private static void reactWith(String emojiName, Emoji fallbackEmoji, Guild guild emojiName); return message.addReaction(fallbackEmoji); }).queue(_ -> { - }, exception -> handleReactionFailure(exception, message.getIdLong())); + }, SuggestionsUpDownVoter::handleReactionFailure); } - private static void handleReactionFailure(Throwable exception, long messageId) { + private static void handleReactionFailure(Throwable exception) { if (exception instanceof ErrorResponseException responseException) { if (responseException.getErrorResponse() == ErrorResponse.REACTION_BLOCKED) { // User blocked the bot, hence the bot can not add reactions to their messages. return; } if (responseException.getErrorResponse() == ErrorResponse.UNKNOWN_MESSAGE) { - logger.info("Reaction skipped ID: {}", messageId); + logger.info("Failed to react to suggestion: source message deleted"); return; } }