diff --git a/README.md b/README.md index 34d947b..38dbb6b 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ ``` npm install ``` +Register commands in discord api ***(First you have to create the bot in [Discord Developers Documentation](https://discord.com/developers/docs/intro))*** + +``` +node deploy-commands.js +``` ## Guide / Usage diff --git a/deploy-commands.js b/deploy-commands.js index bb331f7..13c307b 100644 --- a/deploy-commands.js +++ b/deploy-commands.js @@ -1,3 +1,6 @@ +// THIS CODE ITS TO SET THE COMMANDS TO THE DISCORD BOT, EACH TIME YOU CREATE A NEW COMMAND YOU HAVE TO SEND IT TO THE DISCORD API +// TO REGISTER THE COMMANDS YOU HAVE TO RUN THE FOLLOWING: +// --> node deploy-commands.js const { REST, Routes } = require('discord.js'); const { clientId, guildId, token } = require('./config.json'); const fs = require('node:fs'); diff --git a/index.js b/index.js index b4d3e84..3885fe2 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ const fs = require('node:fs') const path = require('node:path'); const { Client, Collection, Events, GatewayIntentBits } = require('discord.js'); -const { clientId, guildId, token } = require('./config.json'); +const { token } = require('./config.json'); const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.commands = new Collection() @@ -31,16 +31,16 @@ client.once(Events.ClientReady, c => { client.on(Events.InteractionCreate, async interaction => { if (!interaction.isChatInputCommand()) return; - // Busca el comando por su nombre + // Search the command by the chat input prompt command const command = interaction.client.commands.get(interaction.commandName); - // Si no hay comando hace return y para + // If the comand is incorrect stop if (!command) { console.error(`No command matching ${interaction.commandName} was found.`); return; } - // En caso contrario + // If it was a command try { await command.execute(interaction); } catch (error) {