added selfhosted mongo option
This commit is contained in:
@ -16,16 +16,34 @@ module.exports = async (client) => {
|
||||
|
||||
const uri = `mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`
|
||||
|
||||
mongoose.connect(uri, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true
|
||||
}).then(() => {
|
||||
console.log('');
|
||||
console.log(`Connected to the database`);
|
||||
}).catch((error) => {
|
||||
console.log(`Failed to connect to the database`);
|
||||
console.log(error);
|
||||
});
|
||||
const dblocation = process.env.DBLOCATION
|
||||
if (dblocation === 'selfhosted') {
|
||||
|
||||
await mongoose.connect('mongodb://localhost:27017/wolfcounter', {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true
|
||||
}).then(() => {
|
||||
console.log('');
|
||||
console.log(`Connected to the selfhosted database`);
|
||||
}).catch((error) => {
|
||||
console.log(`Failed to connect to the selfhosted database`);
|
||||
console.log(error);
|
||||
});
|
||||
} else if (dblocation === 'cloud') {
|
||||
|
||||
await mongoose.connect(`mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority`, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true
|
||||
}).then(() => {
|
||||
console.log('');
|
||||
console.log(`Connected to the database`);
|
||||
}).catch((error) => {
|
||||
console.log(`Failed to connect to the database`);
|
||||
console.log(error);
|
||||
});
|
||||
} else {
|
||||
console.error(`Failed to connect to the database, it is possible that the host option is not available`);
|
||||
}
|
||||
|
||||
// Slash Commands
|
||||
const slashCommands = await globPromise(`${process.cwd()}/commands/*/*.js`);
|
||||
|
Reference in New Issue
Block a user