-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (43 loc) · 1.45 KB
/
index.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const fs = require("fs");
const Discord = require('discord.js');
const client = new Discord.Client({
intents: ['Guilds', 'GuildMessages'],
});
require("dotenv").config();
require('./utils/mongoFunctions')(client);
require('./utils/updateEmbed')(client);
client.mongoose = require('./utils/mongoose');
client.slash = new Discord.Collection();
client.select = new Discord.Collection();
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);
});
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
});
});
fs.readdir("./handlers/slash/", (err, files) => {
if (err) return console.error(err);
files.forEach(f => {
let slashName = f.split(".")[0];
let pull = require(`./handlers/slash/${slashName}`);
client.slash.set(slashName, pull);
});
});
fs.readdir("./handlers/select/", (err, files) => {
if (err) return console.error(err);
files.forEach(f => {
let selectName = f.split(".")[0];
let pull = require(`./handlers/select/${selectName}`);
client.select.set(selectName, pull);
});
});
client.mongoose.init();
client.login(process.env.TOKEN);