-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
56 lines (49 loc) · 1.63 KB
/
main.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
const { Client, Partials, Events, GatewayIntentBits} = require('discord.js');
const dotenv = require('dotenv');
dotenv.config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction,
],
});
//-------------------<|commands|>-----------------------//
const cmd_mnger = require("./command_manager");
const slashTree = cmd_mnger.read_from_dir("./commands");
//--------------------<|events|>------------------------//
require("./event_manager").set(client, "./events");
client.once(Events.ClientReady, async (c) => {
await cmd_mnger.set(client, slashTree);
console.log("setted Commands.");
console.log(`Ready! (${c.user.tag})`);
});
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isCommand()) {
return;
}
if(!(interaction.commandName in slashTree.all)){
await interaction.reply({
content: "The Command doesn't exit.",
ephemeral: true,
})
}
const command = slashTree.all[interaction.commandName];
try {
await command.execute(client,interaction);
} catch (error) {
console.error(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true,
})
}
});
client.login(process.env.TOKEN);