Merge pull request #4 from SowinskiBraeden/test_failed_mongo
Catch Failed Mongo
This commit is contained in:
2 files changed
+15
-24
No files matched your search
+1
-1
@@ -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",
|
||||
|
||||
+14
-23
@@ -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, {connectTimeoutMS: 5000});
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user