summary refs log tree commit diff homepage
path: root/src/Discord.ts
diff options
context:
space:
mode:
authordestruc7i0n <destruc7i0n@users.noreply.github.com>2021-12-29 16:57:59 -0500
committerdestruc7i0n <destruc7i0n@users.noreply.github.com>2021-12-29 16:57:59 -0500
commit8099fd7ac494c12860145f021c46326a1c784ea0 (patch)
treea6fbe5431c05da1568a1d33588dbb527f83ee797 /src/Discord.ts
parentescape unicode characters (diff)
downloadshulker-8099fd7ac494c12860145f021c46326a1c784ea0.tar.gz
shulker-8099fd7ac494c12860145f021c46326a1c784ea0.zip
fallback to bot message if webhook fails
Diffstat (limited to '')
-rw-r--r--src/Discord.ts19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Discord.ts b/src/Discord.ts
index 3a4dab8..8071d7e 100644
--- a/src/Discord.ts
+++ b/src/Discord.ts
@@ -292,17 +292,20 @@ class Discord {
       const webhook = await this.makeDiscordWebhook(username, message)
       try {
         await axios.post(this.config.WEBHOOK_URL, webhook, { headers: { 'Content-Type': 'application/json' } })
+        return
       } catch (e) {
-        console.log('[ERROR] Could not send Discord message through WebHook!')
+        console.log('[ERROR] Could not send Discord message through WebHook! Falling back to sending through bot.')
         if (this.config.DEBUG) console.log(e)
       }
-    } else {
-      try {
-        await this.channel!.send(this.makeDiscordMessage(username, message))
-      } catch (e) {
-        console.log('[ERROR] Could not send Discord message through bot!')
-        process.exit(1)
-      }
+    }
+
+    const messageContent = this.makeDiscordMessage(username, message)
+
+    try {
+      await this.channel!.send(messageContent)
+    } catch (e) {
+      console.log('[ERROR] Could not send Discord message through bot!')
+      process.exit(1)
     }
   }
 }