summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorBen Landin <blastyr@blastyr.net>2020-04-19 09:43:55 -0400
committerBen Landin <blastyr@blastyr.net>2020-04-19 09:43:55 -0400
commitf102729237d5c20ceeebaae8dbccafaa6ca55e21 (patch)
treed53199b099269d7bd9f361992620c63dbb737208
parentUpdate README.md (diff)
downloadshulker-f102729237d5c20ceeebaae8dbccafaa6ca55e21.tar.gz
shulker-f102729237d5c20ceeebaae8dbccafaa6ca55e21.zip
Fixed tellraw components not being encoded properly
-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)