-
Notifications
You must be signed in to change notification settings - Fork 5
/
Index.js
60 lines (45 loc) · 1.8 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
const fs = require('fs');
const managePresence = require('./events/status');
const { token } = require('./config.json');
const { Client, Collection } = require('discord.js');
const { SlashCommandBuilder } = require('@discordjs/builders');
const client = new Client({ intents: [1, 512, 32768, 2, 128]});
// -------------------
// CMD REGISTER
// -------------------
client.commands = new Collection();
const commandFolders = fs.readdirSync('./commands');
for(const folder of commandFolders)
{
const folderFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('.js'));
for(const file of folderFiles)
{
const command = require(`./commands/${folder}/${file}`);
if(command.data instanceof SlashCommandBuilder) {
client.commands.set(command.data.name, command);
}
}
}
// -------------------
// BOT LOAD
// -------------------
client.once('ready', async () => {
const commandData = client.commands.map(command => command.data.toJSON());
await client.application.commands.set(commandData);
console.log(`[Minescord] => [v] Sucess => Logged in as ${client.user.tag}!`);
console.log(`[Minescord] => [!] Alert => ${commandData.length} registered commands.`);
console.log(`[Minescord] => [L] Log => Check project github for updates: https://github.com/Henry8K/Minescord`);
managePresence(client);
});
// -------------------
// BOT COMMANDS
// -------------------
client.on('interactionCreate', async interaction =>
{
if(!interaction.isCommand()) return;
if(!interaction.guild) return;
const command = client.commands.get(interaction.commandName);
if(!command) return;
await command.execute(interaction).catch(console.error);
});
client.login(token);