-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
57 lines (44 loc) · 1.55 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
/*
__ __ _ _ _ _ _ _ _
\ \ / /(_)| |__ ___ | | | || |_ (_)| | ___
\ / | || _ \/ -_)| |_| || _|| || |(_-/
\_/ |_||____/\___| \___/ \__||_||_|/__/
by polar!#7979
*/
const { Client, Intents, Collection } = require('discord.js');
const { token } = require('./configs/config.json')
var fs = require('fs');
let client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES]
})
client.commands = new Collection();
const commandFiles = fs
.readdirSync("./commands/")
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.data.name, command);
}
client.once("ready", () => {
setTimeout(() => {
console.log("🚀 Connected to Discord Socket!");
client.user.setActivity(`${client.users.cache.size} members • /help`)
}, 1000)
})
client.on("interactionCreate", async interaction => {
if(!interaction.isCommand) return;
let command = client.commands.get(interaction.commandName);
if(!command) return;
try {
await command.execute(interaction, client);
console.log("🔗 " + interaction.user.tag + " ran /" + interaction.commandName);
} catch (error) {
console.log("🛑 An error has occured: " + error);
await interaction.reply({
content: "<:icons_Wrong:859388130636988436> Uh oh! An error has occured",
ephemeral: true,
});
return;
}
})
client.login(token);