summary refs log tree commit diff homepage
path: root/src/Discord.ts
diff options
context:
space:
mode:
authorsurepy <24486494+surepy@users.noreply.github.com>2020-10-01 17:16:30 -0700
committersurepy <24486494+surepy@users.noreply.github.com>2020-10-01 17:16:30 -0700
commit1ac0fc4a8e61e345c2e6eed715d47958c8020bca (patch)
treef1ed628d3c5b00688a8151605d2ef6ac72072cc1 /src/Discord.ts
parentMerge pull request #61 from MarshallOliver/Discord-mentions-regex (diff)
downloadshulker-1ac0fc4a8e61e345c2e6eed715d47958c8020bca.tar.gz
shulker-1ac0fc4a8e61e345c2e6eed715d47958c8020bca.zip
Add compatibility options for minecraft versions lower than 1.7.2
Diffstat (limited to '')
-rw-r--r--src/Discord.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/Discord.ts b/src/Discord.ts
index 12ac656..93a99ff 100644
--- a/src/Discord.ts
+++ b/src/Discord.ts
@@ -114,7 +114,13 @@ class Discord {
         console.log('[INFO] User attempted a slash command without a role')
       }
     } else {
-      command = `/tellraw @a ${this.makeMinecraftTellraw(message)}`
+        if (this.config.MINECRAFT_TELLRAW_DOESNT_EXIST) 
+        {
+            command = `/say ${this.makeMinecraftTellraw(message)}`
+        }
+        else {
+            command = `/tellraw @a ${this.makeMinecraftTellraw(message)}`
+        }
     }
 
     if (this.config.DEBUG) console.log(`[DEBUG] Sending command "${command}" to the server`)
@@ -123,6 +129,12 @@ class Discord {
       await rcon.command(command).catch((e) => {
         console.log('[ERROR] Could not send command!')
         if (this.config.DEBUG) console.error(e)
+      }).then((str) => {
+        if (str === 'Unknown command. Try /help for a list of commands') {
+            console.error('[ERROR] Could not send command! (Unknown command)')
+            console.error('if this was a chat message, please look into MINECRAFT_TELLRAW_DOESNT_EXIST!')
+            console.error('command: ' + command)
+        }
       })
     }
     rcon.close()
@@ -139,6 +151,16 @@ class Discord {
     for (const v of Object.keys(variables)) {
       variables[v] = JSON.stringify(variables[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)
+                .replace(/%nickname%/g, variables.nickname)
+                .replace(/%discriminator%/g, variables.discriminator)
+                .replace(/%message%/g, variables.text)
+    }
+
 
     return this.config.MINECRAFT_TELLRAW_TEMPLATE
       .replace(/%username%/g, variables.username)