|
|
|
@ -7,13 +7,15 @@ const ora = require('../util/log/ora'); |
|
|
|
|
module.exports = async client => { |
|
|
|
|
const auth = client.auth; |
|
|
|
|
const t = Date.now(); |
|
|
|
|
client.misc.dbconnected = false; |
|
|
|
|
client.misc.dbconnected = true; |
|
|
|
|
await ora(chalk.blueBright.bold.underline("Connecting to MongoDB..."), |
|
|
|
|
mongoose.connect(`mongodb+srv://${auth.database.user}:${auth.database.password}@${auth.database.cluster}.3jpp4.mongodb.net/test`, { |
|
|
|
|
useFindAndModify: false, useNewUrlParser: true, dbName: auth.database.name, useUnifiedTopology: true, useCreateIndex: true |
|
|
|
|
}) |
|
|
|
|
).catch((e) => client.error("Failed to connect to mongoose!! Error below.", 0, true, true, e)) |
|
|
|
|
.then(() => {client.misc.dbconnected = true;}); |
|
|
|
|
).catch((e) => { |
|
|
|
|
client.error("Failed to connect to mongoose!! Error below.", 0, 0, true, e); |
|
|
|
|
client.misc.dbconnected = false; |
|
|
|
|
}); |
|
|
|
|
if (!client.misc.dbconnected) { |
|
|
|
|
client.warn("Database not connected, considering runtime to be unusable and exiting.", 0, true, true); |
|
|
|
|
throw new Error(); |
|
|
|
|