From 1ec1b927fb10c0e79f500e37b28d07825ec880cb Mon Sep 17 00:00:00 2001 From: JandereDev Date: Sun, 5 Dec 2021 15:16:41 +0100 Subject: [PATCH] attempt to query database before loading bot --- src/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index be91376..07311a3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,6 +12,13 @@ login(client); export { client } -// Load modules -import('./bot/modules/command_handler'); -import('./bot/modules/mod_logs'); +(async () => { + // Wait for a database query to succeed before loading the rest + logger.info('Connecting to database...'); + await db.get('servers').findOne({}); + logger.done('DB ready!'); + + // Load modules + import('./bot/modules/command_handler'); + import('./bot/modules/mod_logs'); +})();