forked from LyricalString/Modelo-Discord-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslashcommands.js
28 lines (25 loc) · 952 Bytes
/
slashcommands.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
const fs = require('fs')
const { REST } = require('@discordjs/rest')
const { Routes } = require('discord-api-types/v9')
const { clientId, guildId, token } = require('./config.json')
const rest = new REST({ version: '9'}).setToken(token)
createSlash()
async function createSlash() {
try{
const commands = []
fs.readdirSync('./commands').forEach(async (category) => {
const commandFiles = fs.readdirSync(`./commands/${category}`).filter((archivo) => archivo.endsWith('.js'))
for (const archivo of commandFiles) {
const command = require(`./commands/${category}/${archivo}`)
commands.push(command.data.toJSON())
}
})
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands }
)
console.log('Se han publicado los slash commands.')
} catch(e) {
console.error(e)
}
}