diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/DiscordListener.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/DiscordListener.kt index 79160c2..18d28d3 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/DiscordListener.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/DiscordListener.kt @@ -3,6 +3,8 @@ package com.mineinabyss.chatty.listeners import com.mineinabyss.chatty.chatty import com.mineinabyss.chatty.chattyProxyChannel import com.mineinabyss.chatty.components.ChannelData +import com.mineinabyss.chatty.helpers.defaultChannel +import com.mineinabyss.chatty.helpers.globalChannel import com.mineinabyss.chatty.helpers.handleChatFilters import com.mineinabyss.chatty.helpers.handleUrlReplacements import com.mineinabyss.geary.papermc.tracking.entities.toGeary @@ -29,7 +31,12 @@ class DiscordListener { @Subscribe(priority = ListenerPriority.HIGHEST) fun DiscordGuildMessagePostProcessEvent.sendDiscordToProxy() { - val minecraftMessage = ComponentDSV.textOfChildren(if (chatty.config.chat.formatURLs) handleUrlReplacements(minecraftMessage.toComponent(), null).toComponentDSV() else minecraftMessage) + val senderName = mm.deserialize(message.author.displayName ?: message.author.name) + val channel = defaultChannel().takeIf { it.value.discordsrv } ?: globalChannel()?.takeIf { it.value.discordsrv } ?: chatty.config.channels.entries.firstOrNull { it.value.discordsrv } ?: return + val channelId = ComponentDSV.text(channel.key) + val simpleMessage = mm.deserialize(message.author.name + ": " + message.contentRaw) + val message = if (chatty.config.chat.formatURLs) handleUrlReplacements(minecraftMessage.toComponent(), null).toComponentDSV() else minecraftMessage + val minecraftMessage = ComponentDSV.textOfChildren(senderName, channelId, message, simpleMessage) chatty.plugin.server.sendPluginMessage(chatty.plugin, chattyProxyChannel, gson.serialize(minecraftMessage).toByteArray()) setMinecraftMessage(minecraftMessage) }