From e16f7d8d279d5b7410bf0789dc36b440f68c81e1 Mon Sep 17 00:00:00 2001 From: Chris Sdogkos Date: Fri, 23 Jan 2026 15:00:17 +0200 Subject: [PATCH 1/2] QuoteBoardForwarder.java: don't care about reactions in the board itself Great, we recently made a quotes board, and if a message gets 5 stars, then it's added to the quotes board. What happens if someone reacts from _within_ the quotes board itself? Add an additional condition so that message reaction additions are not counted within this feature if the reaction is in the quotes board itself. Signed-off-by: Chris Sdogkos --- .../features/basic/QuoteBoardForwarder.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/basic/QuoteBoardForwarder.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/QuoteBoardForwarder.java index 22ce51f43f..7aeb13c197 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/basic/QuoteBoardForwarder.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/QuoteBoardForwarder.java @@ -80,22 +80,28 @@ public void onMessageReactionAdd(MessageReactionAddEvent event) { final long guildId = event.getGuild().getIdLong(); - Optional boardChannel = findQuoteBoardChannel(event.getJDA(), guildId); + Optional boardChannelOptional = findQuoteBoardChannel(event.getJDA(), guildId); - if (boardChannel.isEmpty()) { + if (boardChannelOptional.isEmpty()) { logger.warn( "Could not find board channel with pattern '{}' in server with ID '{}'. Skipping reaction handling...", this.config.channel(), guildId); return; } - logger.debug("Forwarding message to quote board channel: {}", boardChannel.get().getName()); + TextChannel boardChannel = boardChannelOptional.get(); + + if (boardChannel.getId().equals(event.getChannel().getId())) { + logger.debug("Someone tried to react with the react emoji to the quotes channel."); + return; + } + + logger.debug("Forwarding message to quote board channel: {}", boardChannel.getName()); event.retrieveMessage() - .queue(message -> markAsProcessed(message) - .flatMap(v -> message.forwardTo(boardChannel.orElseThrow())) + .queue(message -> markAsProcessed(message).flatMap(v -> message.forwardTo(boardChannel)) .queue(_ -> logger.debug("Message forwarded to quote board channel: {}", - boardChannel.get().getName())), + boardChannel.getName())), e -> logger.warn( "Unknown error while attempting to retrieve and forward message for quote-board, message is ignored.", From 722fc9e0d65af740e1763c944b5153a1e00f85ca Mon Sep 17 00:00:00 2001 From: Chris Sdogkos Date: Fri, 23 Jan 2026 16:01:39 +0200 Subject: [PATCH 2/2] nit(QuoteBoardForwarder): use Optional#orElseThrow for boardChannel --- .../togetherjava/tjbot/features/basic/QuoteBoardForwarder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/basic/QuoteBoardForwarder.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/QuoteBoardForwarder.java index 7aeb13c197..a6d067e16e 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/basic/QuoteBoardForwarder.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/QuoteBoardForwarder.java @@ -89,7 +89,7 @@ public void onMessageReactionAdd(MessageReactionAddEvent event) { return; } - TextChannel boardChannel = boardChannelOptional.get(); + TextChannel boardChannel = boardChannelOptional.orElseThrow(); if (boardChannel.getId().equals(event.getChannel().getId())) { logger.debug("Someone tried to react with the react emoji to the quotes channel.");