From e268d3f252474b92204a16a41b9c24bbddbd8088 Mon Sep 17 00:00:00 2001 From: Key Date: Thu, 12 Feb 2026 22:56:55 +0000 Subject: [PATCH] FavEmojiFirst: replace aliases with the emoji when not using autocomplete (#763) --- src/plugins/favEmojiFirst/index.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/plugins/favEmojiFirst/index.tsx b/src/plugins/favEmojiFirst/index.tsx index df36ecfde..f369023c5 100644 --- a/src/plugins/favEmojiFirst/index.tsx +++ b/src/plugins/favEmojiFirst/index.tsx @@ -1084,6 +1084,20 @@ const messageContextMenuPatch: NavContextMenuPatchCallback = (children, ...args: insertSetAliasMenuItem(children, emojiRef); }; +const messageSendListener = (_channelId: string, messageObj: { content: string; }) => { + if (!messageObj.content || !Object.keys(aliasMap).length) return; + + messageObj.content = messageObj.content.replace(/:([a-z0-9_]{2,32}):/gi, (match, aliasName) => { + const ref = aliasMap[aliasName.toLowerCase()]; + if (!ref) return match; + + if (ref.kind === "custom" && ref.id) { + return `<${ref.animated ? "a" : ""}:${ref.name}:${ref.id}>`; + } + return getUnicodeSurrogate(ref) ?? resolveUnicodeSurrogateByName(ref.name) ?? match; + }); +}; + export default definePlugin({ name: "FavoriteEmojiFirst", authors: [Devs.Aria, Devs.Ven, EquicordDevs.justjxke], @@ -1097,6 +1111,7 @@ export default definePlugin({ "textarea-context": messageContextMenuPatch }, isModified: true, + onBeforeMessageSend: messageSendListener, patches: [ { find: "renderResults({results:",