-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
68 lines (52 loc) · 1.87 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
56
57
58
59
60
61
62
63
64
65
66
67
68
const fs = require("fs");
const Discord = require('discord.js');
const config = require("./config.js");
const client = new Discord.Client({
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'GuildMessageReactions'],
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
});
require("dotenv").config();
client.commands = new Discord.Collection();
client.components = new Discord.Collection();
client.cache = new Discord.Collection(); // Dunno if this exists already; I don't think it does
client.config = config;
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 pull = require(`./handlers/slash/${f}`);
let slashName = pull.data.name;
client.commands.set(slashName, pull);
});
});
fs.readdir("./handlers/component/", (err, files) => {
if (err) return console.error(err);
files.forEach(f => {
let componentName = f.split(".")[0];
let pull = require(`./handlers/component/${f}`);
client.components.set(componentName, pull);
});
});
fs.readdir("./handlers/context/", (err, files) => {
if (err) return console.error(err);
files.forEach(f => {
let pull = require(`./handlers/context/${f}`);
let contextName = pull.data.name;
client.commands.set(contextName, pull);
});
});
require('./utils/registerCommands')(client);
client.login(process.env.TOKEN);