From 91bb245b596c8d470ba56932d11d0b94efdd651e Mon Sep 17 00:00:00 2001 From: Dragory Date: Sun, 11 Mar 2018 22:45:43 +0200 Subject: [PATCH] Don't start scheduled close loop until after connecting to Discord --- CHANGELOG.md | 4 ++++ src/main.js | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58768a5..37e67cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v2.4.1-v2.4.3 +* Fix errors on first run after upgrading to v2.2.0 +* Various other fixes + ## v2.4.0 * Add thread suspending. A modmail thread can now be suspended with `!suspend`. Suspended threads will function as closed until unsuspended with `!unsuspend`. diff --git a/src/main.js b/src/main.js index d46dada..6cfc5ba 100644 --- a/src/main.js +++ b/src/main.js @@ -188,18 +188,16 @@ async function applyScheduledCloses() { } } -async function closeLoop() { +async function scheduledCloseLoop() { try { await applyScheduledCloses(); } catch (e) { console.error(e); } - setTimeout(closeLoop, 2000); + setTimeout(scheduledCloseLoop, 2000); } -closeLoop(); - // Auto-close threads if their channel is deleted bot.on('channelDelete', async (channel) => { if (! (channel instanceof Eris.TextChannel)) return; @@ -442,9 +440,13 @@ module.exports = { await greeting(bot); await webserver(bot); + // Connect to Discord console.log('Connecting to Discord...'); await bot.connect(); + // Start scheduled close loop + scheduledCloseLoop(); + console.log('Done! Now listening to DMs.'); } };