diff --git a/src/d2m/converters/emoji-to-key.js b/src/d2m/converters/emoji-to-key.js index 54bda18..5f913c9 100644 --- a/src/d2m/converters/emoji-to-key.js +++ b/src/d2m/converters/emoji-to-key.js @@ -34,7 +34,20 @@ async function emojiToKey(emoji, message_id) { // If the reaction was used on Matrix already, it might be using a different arrangement of Variation Selector 16 characters. // We'll use the same arrangement that was originally used, otherwise a duplicate of the emoji will appear as a separate reaction. const originalEncoding = select("reaction", "original_encoding", {message_id, encoded_emoji: encodeURIComponent(name)}).pluck().get() - key = originalEncoding || name + if (originalEncoding) { + key = originalEncoding + } else { + key = name + + // ™, ® and © are weird, because they exist in two forms: emoji and text... + // ... and discord prefers the text version + // on m->d we're forced to convert emoji versions to text + // the branch above already handles the case where the initial reaction was on matrix, + // but in case that it's on discord, convert the text to a proper emoji before bridging it + if (key === "™") key = "™️" + if (key === "®") key = "®️" + if (key === "©") key = "©️" + } } return key } diff --git a/src/m2d/converters/emoji.js b/src/m2d/converters/emoji.js index 63e53a9..31689a6 100644 --- a/src/m2d/converters/emoji.js +++ b/src/m2d/converters/emoji.js @@ -43,6 +43,13 @@ async function encodeDefaultEmoji(input) { const emojis = await emojisp const encoded = encodeURIComponent(input) + // ™, ® and © are weird, because they exist in two forms: emoji and text... + // ... and discord prefers the text version + // so if someone reacts with the emoji version, convert it to the text version discord wants + if (input === "™️") return encodeURIComponent("™") + if (input === "®️") return encodeURIComponent("®") + if (input === "©️") return encodeURIComponent("©") + // Best case scenario: they reacted with an exact replica of a valid emoji. if (emojis.includes(input)) return encoded