From 4907f08b8500d07d7a678d88cf1f2ce3f8be31a6 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 8 Nov 2018 22:07:27 +0000 Subject: [PATCH] wew, try catch like it's 1984 --- src/bot.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index 131fbdb7..5c5cd658 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -112,9 +112,11 @@ export class DiscordBot { await Bluebird.delay(this.config.limits.discordSendDelay); this.discordMessageQueue[msg.channel.id] = (async () => { await (this.discordMessageQueue[msg.channel.id] || Promise.resolve()); - await (this.DeleteDiscordMessage(msg).catch( - (err) => log.error("Caught while handing 'messageDelete'", err), - )); + try { + await this.DeleteDiscordMessage(msg); + } catch (err) { + log.error("Caught while handing 'messageDelete'", err); + } })(); }); client.on("messageUpdate", async (oldMessage: Discord.Message, newMessage: Discord.Message) => { @@ -122,9 +124,11 @@ export class DiscordBot { await Bluebird.delay(this.config.limits.discordSendDelay); this.discordMessageQueue[newMessage.channel.id] = (async () => { await (this.discordMessageQueue[newMessage.channel.id] || Promise.resolve()); - await (this.OnMessageUpdate(oldMessage, newMessage).catch( - (err) => log.error("Caught while handing 'messageUpdate'", err), - )); + try { + await this.OnMessageUpdate(oldMessage, newMessage); + } catch (err) { + log.error("Caught while handing 'messageUpdate'", err); + } })(); }); client.on("message", async (msg: Discord.Message) => { @@ -132,9 +136,11 @@ export class DiscordBot { await Bluebird.delay(this.config.limits.discordSendDelay); this.discordMessageQueue[msg.channel.id] = (async () => { await (this.discordMessageQueue[msg.channel.id] || Promise.resolve()); - await (this.OnMessage(msg).catch( - (err) => log.error("Caught while handing 'message'", err), - )); + try { + await this.OnMessage(msg); + } catch (err) { + log.error("Caught while handing 'message'", err); + } })(); }); const jsLog = new Log("discord.js");