From 8a4a5bf73cad90e72368f0cad5740b56301b2228 Mon Sep 17 00:00:00 2001 From: destruc7i0n Date: Thu, 27 Jan 2022 19:15:26 -0500 Subject: encode unicode characters in names too closes #81 --- src/Discord.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Discord.ts') diff --git a/src/Discord.ts b/src/Discord.ts index 110ce64..0da51ac 100644 --- a/src/Discord.ts +++ b/src/Discord.ts @@ -145,11 +145,6 @@ class Discord { text: emojiStrip(message.cleanContent), } - // use JSON to encode the strings for tellraw - for (const [k, v] of Object.entries(variables)) { - variables[k] = JSON.stringify(v).slice(1,-1) - } - if (this.config.MINECRAFT_TELLRAW_DOESNT_EXIST) { return this.config.MINECRAFT_TELLRAW_DOESNT_EXIST_SAY_TEMPLATE .replace(/%username%/g, variables.username) @@ -158,7 +153,12 @@ class Discord { .replace(/%message%/g, variables.text) } - variables.text = escapeUnicode(variables.text) + for (const [k, v] of Object.entries(variables)) { + // use JSON to encode the strings for tellraw + const stringified = JSON.stringify(v).slice(1, -1) + // encode unicode characters for all fields + variables[k] = escapeUnicode(stringified) + } return this.config.MINECRAFT_TELLRAW_TEMPLATE .replace(/%username%/g, variables.username) -- cgit 1.4.1