test failed mongo connection
This commit is contained in:
1 file changed
+9
-18
+9
-18
@@ -6,6 +6,7 @@ const mongoose = require('mongoose');
|
|||||||
const Logger = require("../util/Logger");
|
const Logger = require("../util/Logger");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const { exit } = require("process");
|
||||||
|
|
||||||
class QuarksBot extends Client {
|
class QuarksBot extends Client {
|
||||||
|
|
||||||
@@ -69,12 +70,16 @@ class QuarksBot extends Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async connectMongo(mongoURI, dbo) {
|
async connectMongo(mongoURI, dbo) {
|
||||||
|
try {
|
||||||
// Connect to MongoDB database.
|
// Connect to MongoDB database.
|
||||||
this.db = await MongoClient.connect(mongoURI);
|
this.db = await MongoClient.connect(mongoURI);
|
||||||
this.dbo = this.db.db(dbo);
|
this.dbo = this.db.db(dbo);
|
||||||
|
|
||||||
mongoose.connect(`${mongoURI}/${dbo}`);
|
mongoose.connect(`${mongoURI}/${dbo}`);
|
||||||
this.log('Successfully connected to mongoDB');
|
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}
|
exists(n) {return null != n && undefined != n && "" != n}
|
||||||
@@ -128,7 +133,7 @@ class QuarksBot extends Client {
|
|||||||
|
|
||||||
sendTime(Channel, Error) {
|
sendTime(Channel, Error) {
|
||||||
let embed = new EmbedBuilder()
|
let embed = new EmbedBuilder()
|
||||||
.setColor(this.config.EmbedColor)
|
.setColor(this.config.Red)
|
||||||
.setDescription(Error);
|
.setDescription(Error);
|
||||||
|
|
||||||
Channel.send(embed);
|
Channel.send(embed);
|
||||||
@@ -189,22 +194,8 @@ class QuarksBot extends Client {
|
|||||||
return guildData;
|
return guildData;
|
||||||
}
|
}
|
||||||
|
|
||||||
log(Text) {
|
log(Text) { this.logger.log(Text); }
|
||||||
this.logger.log(Text);
|
error(Text) { this.logger.error(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
this.login(this.config.Token);
|
this.login(this.config.Token);
|
||||||
|
|||||||
Reference in new issue
Block a user