From b8f8b7d585a378a671f3d17f853a47abd5bd18e1 Mon Sep 17 00:00:00 2001 From: Vankka Date: Thu, 26 Sep 2024 17:54:55 +0300 Subject: [PATCH] Fix mirroring support for non-text and thread channels --- .../discord/DiscordMessageMirroringModule.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/discord/DiscordMessageMirroringModule.java b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/discord/DiscordMessageMirroringModule.java index d786000a..4f029478 100644 --- a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/discord/DiscordMessageMirroringModule.java +++ b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/discord/DiscordMessageMirroringModule.java @@ -473,14 +473,12 @@ public class DiscordMessageMirroringModule extends AbstractModule { boolean webhookMessage, MirroringConfig config ) { - if (channel instanceof DiscordTextChannel) { - DiscordTextChannel textChannel = (DiscordTextChannel) channel; - return new MessageReference(textChannel, messageId, webhookMessage, config); - } else if (channel instanceof DiscordThreadChannel) { + if (channel instanceof DiscordThreadChannel) { DiscordThreadChannel threadChannel = (DiscordThreadChannel) channel; return new MessageReference(threadChannel, messageId, webhookMessage, config); + } else { + return new MessageReference(channel, messageId, webhookMessage, config); } - throw new IllegalStateException("Unexpected channel type: " + channel.getClass().getName()); } private static class MirrorOperation { @@ -549,12 +547,12 @@ public class DiscordMessageMirroringModule extends AbstractModule { private final MirroringConfig config; public MessageReference( - DiscordTextChannel textChannel, + DiscordMessageChannel messageChannel, long messageId, boolean webhookMessage, MirroringConfig config ) { - this(textChannel.getId(), -1L, messageId, webhookMessage, config); + this(messageChannel.getId(), -1L, messageId, webhookMessage, config); } public MessageReference(