From 94ee0c518a087461a7bacbcc6af4050d5889aaa1 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Fri, 21 Mar 2025 08:22:58 -0400 Subject: [PATCH] InvisibleChat: Fix crashing when message contains a link (#3303) --- src/plugins/invisibleChat.desktop/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/invisibleChat.desktop/index.tsx b/src/plugins/invisibleChat.desktop/index.tsx index d6a39cba..f98ab176 100644 --- a/src/plugins/invisibleChat.desktop/index.tsx +++ b/src/plugins/invisibleChat.desktop/index.tsx @@ -149,6 +149,12 @@ export default definePlugin({ renderChatBarButton: ChatBarIcon, + colorCodeFromNumber(color: number): string { + return `#${[color >> 16, color >> 8, color] + .map(x => (x & 0xFF).toString(16)) + .join("")}`; + }, + // Gets the Embed of a Link async getEmbed(url: URL): Promise { const { body } = await RestAPI.post({ @@ -157,6 +163,8 @@ export default definePlugin({ urls: [url] } }); + // The endpoint returns the color as a number, but Discord expects a string + body.embeds[0].color = this.colorCodeFromNumber(body.embeds[0].color); return await body.embeds[0]; }, @@ -166,7 +174,7 @@ export default definePlugin({ message.embeds.push({ type: "rich", rawTitle: "Decrypted Message", - color: "0x45f5f5", + color: "#45f5f5", rawDescription: revealed, footer: { text: "Made with ❤️ by c0dine and Sammy!",