-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (35 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
const Discord = require("discord.js")
const client = new Discord.Client(
{
intents:[
"Guilds", "GuildMessages"
]
}
)
client.login("tuo token")
client.on("ready", () => {
console.log("MarioBot Online!")
})
const fs = require("fs")
client.commands = new Discord.Collection()
const commandsFolder = fs.readdirSync("./commands");
for (const folder of commandsFolder) {
const commandsFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith(".js"));
for (const file of commandsFiles) {
const command = require(`./commands/${folder}/${file}`);
client.commands.set(command.name, command);
}
}
client.on("ready", () => {
client.guilds.cache.forEach(guild => {
client.commands.forEach(command => {
guild.commands.create(command.data)
})
})
})
client.on("interactionCreate", interaction => {
if (!interaction.isCommand()) return
const command = client.commands.get(interaction.commandName)
if (!command) return
command.execute(interaction)
})