diff options
author | destruc7i0n <destruc7i0n@users.noreply.github.com> | 2022-01-27 19:15:26 -0500 |
---|---|---|
committer | destruc7i0n <destruc7i0n@users.noreply.github.com> | 2022-01-27 19:15:26 -0500 |
commit | 8a4a5bf73cad90e72368f0cad5740b56301b2228 (patch) | |
tree | f92259b7dd8a344849129cdb3afd7d3fc507012a /src | |
parent | added tests (diff) | |
download | shulker-8a4a5bf73cad90e72368f0cad5740b56301b2228.tar.gz shulker-8a4a5bf73cad90e72368f0cad5740b56301b2228.zip |
encode unicode characters in names too
closes #81
Diffstat (limited to '')
-rw-r--r-- | src/Discord.ts | 12 |
1 files changed, 6 insertions, 6 deletions
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) |