From a327160ed9d9844e8d555a6c490d885eed8883c8 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 17 Aug 2020 00:19:41 +0300 Subject: [PATCH] Improve CLI feedback for 'Waiting for servers', always continue after a delay --- src/main.js | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/main.js b/src/main.js index 8af38be..460e02c 100644 --- a/src/main.js +++ b/src/main.js @@ -36,11 +36,38 @@ module.exports = { console.log("Connecting to Discord..."); bot.once("ready", async () => { - console.log("Connected! Waiting for guilds to become available..."); - await Promise.all([ - ...config.mainServerId.map(id => waitForGuild(id)), - waitForGuild(config.inboxServerId), - ]); + console.log("Connected! Waiting for servers to become available..."); + + await (new Promise(resolve => { + const waitNoteTimeout = setTimeout(() => { + console.log("Servers did not become available after 15 seconds, continuing start-up anyway"); + console.log(""); + + const isSingleServer = config.mainServerId.includes(config.inboxServerId); + if (isSingleServer) { + console.log("WARNING: The bot will not work before it's invited to the server."); + } else { + const hasMultipleMainServers = config.mainServerId.length > 1; + if (hasMultipleMainServers) { + console.log("WARNING: The bot will not function correctly until it's invited to *all* main servers and the inbox server."); + } else { + console.log("WARNING: The bot will not function correctly until it's invited to *both* the main server and the inbox server."); + } + } + + console.log(""); + + resolve(); + }, 15 * 1000); + + Promise.all([ + ...config.mainServerId.map(id => waitForGuild(id)), + waitForGuild(config.inboxServerId), + ]).then(() => { + clearTimeout(waitNoteTimeout); + resolve(); + }); + })); console.log("Initializing..."); initStatus();