Don't start scheduled close loop until after connecting to Discord

master
Dragory 2018-03-11 22:45:43 +02:00
parent 78740cee47
commit 91bb245b59
2 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
## v2.4.1-v2.4.3
* Fix errors on first run after upgrading to v2.2.0
* Various other fixes
## v2.4.0 ## 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`. * Add thread suspending. A modmail thread can now be suspended with `!suspend`. Suspended threads will function as closed until unsuspended with `!unsuspend`.

View File

@ -188,18 +188,16 @@ async function applyScheduledCloses() {
} }
} }
async function closeLoop() { async function scheduledCloseLoop() {
try { try {
await applyScheduledCloses(); await applyScheduledCloses();
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
setTimeout(closeLoop, 2000); setTimeout(scheduledCloseLoop, 2000);
} }
closeLoop();
// Auto-close threads if their channel is deleted // Auto-close threads if their channel is deleted
bot.on('channelDelete', async (channel) => { bot.on('channelDelete', async (channel) => {
if (! (channel instanceof Eris.TextChannel)) return; if (! (channel instanceof Eris.TextChannel)) return;
@ -442,9 +440,13 @@ module.exports = {
await greeting(bot); await greeting(bot);
await webserver(bot); await webserver(bot);
// Connect to Discord
console.log('Connecting to Discord...'); console.log('Connecting to Discord...');
await bot.connect(); await bot.connect();
// Start scheduled close loop
scheduledCloseLoop();
console.log('Done! Now listening to DMs.'); console.log('Done! Now listening to DMs.');
} }
}; };