summary refs log tree commit diff homepage
path: root/src
diff options
context:
space:
mode:
authordestruc7i0n <6181960+destruc7i0n@users.noreply.github.com>2020-04-21 09:30:53 -0400
committerGitHub <noreply@github.com>2020-04-21 09:30:53 -0400
commit428431f3d8585574243e6c4d43916bc3499e2f04 (patch)
treed53199b099269d7bd9f361992620c63dbb737208 /src
parentUpdate README.md (diff)
parentFixed tellraw components not being encoded properly (diff)
downloadshulker-428431f3d8585574243e6c4d43916bc3499e2f04.tar.gz
shulker-428431f3d8585574243e6c4d43916bc3499e2f04.zip
Merge pull request #51 from blandin/master
Fixed tellraw components not being encoded properly
Diffstat (limited to 'src')
-rw-r--r--src/Discord.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Discord.ts b/src/Discord.ts
index bc15fac..8415ad0 100644
--- a/src/Discord.ts
+++ b/src/Discord.ts
@@ -91,11 +91,15 @@ class Discord {
   }
 
   private makeMinecraftTellraw(message: Message): string {
-    const username = emojiStrip(message.author.username)
-    const discriminator = message.author.discriminator
-    const text = emojiStrip(message.cleanContent)
+    const variables: {[index: string]: string} = {
+      username: emojiStrip(message.author.username),
+      discriminator: message.author.discriminator,
+      text: emojiStrip(message.cleanContent)
+    }
     // hastily use JSON to encode the strings
-    const variables = JSON.parse(JSON.stringify({ username, discriminator, text }))
+    for (const v of Object.keys(variables)) {
+      variables[v] = JSON.stringify(variables[v]).slice(1,-1)
+    }
 
     return this.config.MINECRAFT_TELLRAW_TEMPLATE
       .replace('%username%', variables.username)