Skip to content

Commit

Permalink
English and notes in code
Browse files Browse the repository at this point in the history
  • Loading branch information
Diogo-Coding committed Nov 11, 2023
1 parent b66a97a commit 18fb73f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions deploy-commands.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 18fb73f

Please sign in to comment.