From c8493e1c04bc3a5c8ccb86ba02b82a0a72092911 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Tue, 11 Jun 2024 10:48:13 -0600 Subject: [PATCH] startup connection check... i think --- bot.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/bot.js b/bot.js index 42938fb..f9a100d 100644 --- a/bot.js +++ b/bot.js @@ -6,11 +6,10 @@ const ora = require('ora'); const mongoose = require('mongoose'); const readline = require('readline'); -const {SlashCommand} = require('./util/slash'); const {SlashManager} = require('./util/slashmanager'); -const {SlashCommandBuilder} = require('@discordjs/builders'); const {Tag} = require('./util/tag'); const {TagFilter} = require('./util/tagfilter'); +const wait = require('./util/wait'); const flags = Discord.Intents.FLAGS; let fl = []; Object.keys(flags).forEach(flag => fl.push(flags[flag])); @@ -77,6 +76,27 @@ client.misc = { fullyReady: false }; + + + +let waitAmount = 1000 * 10; +function testConnection() { + return new Promise(async r => { + require('dns').lookup('www.google.com', async e => { + if (e) { + await wait(waitAmount); + waitAmount *= 2; + await testConnection(); + r(); + } + else {r();} + }) + }); +} + + + + const auth = require('./auth.json'); async function init() { @@ -178,4 +198,5 @@ async function init() { await require('./util/wait')(5000); if (!client.misc.readied) {client.misc.forcedReady = true; await require('./events/ready')(client);} } -init().then(() => {}); \ No newline at end of file + +testConnection().then(() => init()); \ No newline at end of file