From 0bcd951db6332c10510bf247e47129e0cd294dd0 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Wed, 12 Oct 2022 08:02:26 -0700 Subject: [PATCH 1/4] test failed mongo connection --- structures/QuarksBot.js | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/structures/QuarksBot.js b/structures/QuarksBot.js index 60ffc24..80dc330 100644 --- a/structures/QuarksBot.js +++ b/structures/QuarksBot.js @@ -6,6 +6,7 @@ const mongoose = require('mongoose'); const Logger = require("../util/Logger"); const path = require("path"); const fs = require('fs'); +const { exit } = require("process"); class QuarksBot extends Client { @@ -69,12 +70,16 @@ class QuarksBot extends Client { } async connectMongo(mongoURI, dbo) { - // Connect to MongoDB database. - this.db = await MongoClient.connect(mongoURI); - this.dbo = this.db.db(dbo); - - mongoose.connect(`${mongoURI}/${dbo}`); - this.log('Successfully connected to mongoDB'); + try { + // Connect to MongoDB database. + this.db = await MongoClient.connect(mongoURI); + this.dbo = this.db.db(dbo); + mongoose.connect(`${mongoURI}/${dbo}`); + this.log('Successfully connected to mongoDB'); + } catch (err) { + this.error('Failed to connect to mongodb'); + process.exit(-1); + } } exists(n) {return null != n && undefined != n && "" != n} @@ -128,7 +133,7 @@ class QuarksBot extends Client { sendTime(Channel, Error) { let embed = new EmbedBuilder() - .setColor(this.config.EmbedColor) + .setColor(this.config.Red) .setDescription(Error); Channel.send(embed); @@ -189,22 +194,8 @@ class QuarksBot extends Client { return guildData; } - log(Text) { - this.logger.log(Text); - } - - error(Text) { - this.logger.error(Text); - } - - sendError(Channel, Error) { - let embed = new EmbedBuilder() - .setTitle("An error occured") - .setColor(client.config.Colors.Red) - .setDescription(Error) - - Channel.send(embed); - } + log(Text) { this.logger.log(Text); } + error(Text) { this.logger.error(Text); } build() { this.login(this.config.Token); From 669bb71392743e306c857dd0248b328e97d7e479 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Wed, 12 Oct 2022 08:07:23 -0700 Subject: [PATCH 2/4] test failed mongo connection --- structures/QuarksBot.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/structures/QuarksBot.js b/structures/QuarksBot.js index 80dc330..1066c29 100644 --- a/structures/QuarksBot.js +++ b/structures/QuarksBot.js @@ -24,7 +24,7 @@ class QuarksBot extends Client { this.db; this.dbo; - this.connectMongo(this.config.mongoURI, this.config.dbo); + this.connectDB(this.config.mongoURI, this.config.dbo); this.LoadCommands(); this.LoadEvents(); @@ -69,6 +69,10 @@ class QuarksBot extends Client { const client = this; } + async connectDB(mongoURI, dbo) { + await this.connectMongo(mongoURI, dbo) + } + async connectMongo(mongoURI, dbo) { try { // Connect to MongoDB database. From 61bee8882fb03dedf0e8c6ef4670fbe5f9f3f386 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Wed, 12 Oct 2022 08:09:20 -0700 Subject: [PATCH 3/4] test failed mongo connection --- structures/QuarksBot.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/structures/QuarksBot.js b/structures/QuarksBot.js index 1066c29..ce86a71 100644 --- a/structures/QuarksBot.js +++ b/structures/QuarksBot.js @@ -24,7 +24,7 @@ class QuarksBot extends Client { this.db; this.dbo; - this.connectDB(this.config.mongoURI, this.config.dbo); + this.connectMongo(this.config.mongoURI, this.config.dbo); this.LoadCommands(); this.LoadEvents(); @@ -69,14 +69,10 @@ class QuarksBot extends Client { const client = this; } - async connectDB(mongoURI, dbo) { - await this.connectMongo(mongoURI, dbo) - } - async connectMongo(mongoURI, dbo) { try { // Connect to MongoDB database. - this.db = await MongoClient.connect(mongoURI); + this.db = await MongoClient.connect(mongoURI, {connectTimeoutMS: 5000}); this.dbo = this.db.db(dbo); mongoose.connect(`${mongoURI}/${dbo}`); this.log('Successfully connected to mongoDB'); From 2b1a179d236c74d85df16d71f8aaff3cacca1411 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Wed, 12 Oct 2022 08:11:18 -0700 Subject: [PATCH 4/4] update version 12.7.7 --- config/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.js b/config/config.js index 85b1535..7de1fc4 100644 --- a/config/config.js +++ b/config/config.js @@ -2,7 +2,7 @@ require('dotenv').config(); module.exports = { Dev: "PROD.", - Version: "12.7.6", + Version: "12.7.7", Admins: ["362791661274660874", "329371697570381824"], // Admins of the bot DefaultPrefix: "?", ServerID: "955668596745461830",