Don't start scheduled close loop until after connecting to Discord
parent
78740cee47
commit
91bb245b59
|
@ -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`.
|
||||
|
||||
|
|
10
src/main.js
10
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.');
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue