Skip to content

Commit

Permalink
wew, try catch like it's 1984
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Nov 8, 2018
1 parent 49f7941 commit 4907f08
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,29 +112,35 @@ 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) => {
// tslint:disable-next-line:await-promise
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) => {
// tslint:disable-next-line:await-promise
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");
Expand Down

0 comments on commit 4907f08

Please sign in to comment.