-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
25 lines (21 loc) · 1 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const Discord = require('discord.js'); //Discord API too communicate with the node modules
require('dotenv').config(); //Allows the storage of environment variables
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MEMBERS"] }); //Creates Discord Bot called client
const mongoose = require('mongoose');
client.commands = new Discord.Collection();
client.events = new Discord.Collection();
['command_handler', 'event_handler'].forEach(handler => {
require(`./handlers/${handler}`)(client, Discord);
})
//Establish a connection with MongoDB
mongoose.connect(process.env.MONGODB_SRV, {
useNewUrlParser: true,
useUnifiedTopology: true,
//useFindAndModify: false,
}).then(() => {
console.log('Connected to the database!');
}).catch((err) => {
console.log(err);
});
//Discord Bot Token
client.login(process.env.DISCORD_TOKEN);