From 4bab23bc356727dd444245473a0c167a4eb84172 Mon Sep 17 00:00:00 2001 From: Vankka Date: Sun, 29 Oct 2023 22:53:47 +0200 Subject: [PATCH] Add check for attachments in blocking empty messages --- .../messageforwarding/discord/DiscordChatMessageModule.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java index 46733571..06eea706 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java @@ -197,8 +197,9 @@ public class DiscordChatMessageModule extends AbstractModule { } chatConfig.contentRegexFilters.forEach(message::replaceAll); + boolean attachments = !discordMessage.getAttachments().isEmpty() && format.contains("message_attachments"); String finalMessage = message.toString(); - if (finalMessage.trim().isEmpty()) { + if (finalMessage.trim().isEmpty() && !attachments) { // No sending empty messages return; } @@ -206,7 +207,7 @@ public class DiscordChatMessageModule extends AbstractModule { Component messageComponent = DiscordSRVMinecraftRenderer.getWithContext(guild, chatConfig, () -> discordSRV.componentFactory().minecraftSerializer().serialize(finalMessage)); - if (discordSRV.componentFactory().plainSerializer().serialize(messageComponent).trim().isEmpty()) { + if (discordSRV.componentFactory().plainSerializer().serialize(messageComponent).trim().isEmpty() && !attachments) { // Check empty-ness again after rendering return; }