-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
48 lines (39 loc) · 1.1 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
const { Client, Collection } = require("discord.js");
const { readdirSync } = require(`fs`);
// Global variable
global.bot = {};
// Config
bot.cfg = require(`./config.json`);
// Client
bot.client = new Client({
allowedMentions: {
parse: ["everyone", "roles", "users"],
repliedUser: true
},
intents: 107
});
// Colors
bot.colors = {};
bot.colors.success = 0x00ee00;
bot.colors.standart = 0x2f3136;
bot.colors.error = 0xff0000;
// Handlers
bot.commands = new Collection();
(async() => {
const commandDir = readdirSync(`./src/commands/`).filter(file => file.endsWith(`.js`));
const eventDir = readdirSync(`./src/events/`).filter(file => file.endsWith(`.js`));
for(const file of commandDir) {
const cmd = require(`./src/commands/${file}`);
bot.commands.set(cmd.name, cmd);
}
for(let file of eventDir) {
file = file.slice(0, -3);
const e = require(`./src/events/${file}`);
if(e.once) {
bot.client.once(file, e);
} else {
bot.client.on(file, e);
}
}
})();
bot.client.login(bot.cfg.token);