-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (41 loc) · 1.58 KB
/
index.js
File metadata and controls
45 lines (41 loc) · 1.58 KB
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
const { bot } = require('./config');
const { discordjs } = require('./secure');
const { REST, Routes } = require('discord.js');
const fs = require("fs");
const alias = require('./client');
// EVENT HANDLER
alias.removeAllListeners();
for (const file of fs.readdirSync('./events/')) {
const event = require(`./events/${file}`);
const eventName = file.split(".")[0];
try {
alias.events.set(eventName, event);
alias.on(eventName, event.bind(null));
} catch(e) { console.log(e); }
}
// COMMAND HANDLER
const commands = [];
for (const folder of fs.readdirSync('./commands/')) {
if (folder == ".DS_Store") continue;
for (const file of fs.readdirSync(`./commands/${folder}`).filter(name => name.endsWith('.js'))) {
const command = require(`./commands/${folder}/${file}`);
alias.commands.set(command.settings.name, command);
if (command.settings.existMsg) alias.msgCommands.set(command.settings.name, command);
if (command.settings.existInt) {
alias.intCommands.set(command.settings.name, command);
commands.push(command.settings);
}
}
}
// SLASH HANDLER
const rest = new REST({ version: '10' }).setToken(discordjs.token);
(async () => {
try {
await rest.put(Routes.applicationCommands(bot.id), { body: commands });
console.log(`Slash Commands Done:`, commands.length);
} catch (error) {
console.error(error);
}
console.log(`${alias.commands.size} with ${alias.events.size}: Msg ${alias.msgCommands.size} | Int ${alias.intCommands.size}`);
})();
alias.login(discordjs.token);