diff options
author | destruc7i0n <destruc7i0n@users.noreply.github.com> | 2021-12-29 16:57:59 -0500 |
---|---|---|
committer | destruc7i0n <destruc7i0n@users.noreply.github.com> | 2021-12-29 16:57:59 -0500 |
commit | 8099fd7ac494c12860145f021c46326a1c784ea0 (patch) | |
tree | a6fbe5431c05da1568a1d33588dbb527f83ee797 | |
parent | escape unicode characters (diff) | |
download | shulker-8099fd7ac494c12860145f021c46326a1c784ea0.tar.gz shulker-8099fd7ac494c12860145f021c46326a1c784ea0.zip |
fallback to bot message if webhook fails
Diffstat (limited to '')
-rw-r--r-- | src/Discord.ts | 19 |
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) } } } |