Improve CLI feedback for 'Waiting for servers', always continue after a delay

cshd
Dragory 2020-08-17 00:19:41 +03:00
parent be7f172b62
commit a327160ed9
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
1 changed files with 32 additions and 5 deletions

View File

@ -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();