-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
56 lines (47 loc) · 1.7 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
require('dotenv').config()
const Discord = require('discord.js');
const { Webhook } = require('dis-logs');
const fs = require('fs');
const client = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.MessageContent, /* required for CHAT commands, requires MESSAGE CONTENT INTENT */
Discord.GatewayIntentBits.GuildMembers, /* requires SERVER MEMBERS INTENT */
Discord.GatewayIntentBits.GuildWebhooks,
Discord.GatewayIntentBits.DirectMessages
],
/**
* @brief Partials are required to receive DMs
partials: [
Discord.Partials.Channel
]
*/
});
client.ms = require('ms');
client.log = new Webhook(process.env.LOG_WEBHOOK);
client.discord = Discord;
client.plugins = new Discord.Collection();
client.events = new Discord.Collection();
client.commands = new Discord.Collection();
client.commands.normal = new Discord.Collection();
client.commands.normal.aliases = new Discord.Collection();
client.commands.buttons = new Discord.Collection();
client.commands.menus = new Discord.Collection();
client.commands.slash = new Discord.Collection();
// Load all handlers
const handlers = fs.readdirSync(`./handler`)
.filter(file => file.endsWith('.js') || file.endsWith('.ts'));
handlers
.forEach(handler => {
try {
require(`./handler/${handler}`)(client);
} catch (e) {
client.log.error('[HANDLER] | Error while loading: ' + handler + ', ' + e);
}
});
client
.login(process.env.BOT_TOKEN)
.catch(err => {
client.log.error('[BOT] | Failed to log in. Discord response: ' + err);
});