From beb63dbbce3e282fdc6cd83def70e5b1f3541abc Mon Sep 17 00:00:00 2001 From: Will Hunt <will@half-shot.uk> Date: Thu, 16 May 2019 18:14:15 +0100 Subject: [PATCH] Move lock statement to after we store in the DB --- src/bot.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index e5a5960..ffc9000 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -450,8 +450,8 @@ export class DiscordBot { opts.embed = embed; msg = await chan.send("", opts); } - this.unlockChannel(chan); await this.StoreMessagesSent(msg, chan, event); + this.unlockChannel(chan); } catch (err) { log.error("Couldn't send message. ", err); } @@ -723,12 +723,12 @@ export class DiscordBot { private async OnMessage(msg: Discord.Message) { const indexOfMsg = this.sentMessages.indexOf(msg.id); - const chan = msg.channel as Discord.TextChannel; if (indexOfMsg !== -1) { log.verbose("Got repeated message, ignoring."); delete this.sentMessages[indexOfMsg]; return; // Skip *our* messages } + const chan = msg.channel as Discord.TextChannel; if (msg.author.id === this.bot.user.id) { // We don't support double bridging. return; -- GitLab