Skip to content

Commit

Permalink
fix(command-deployment): Cleanup page (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite authored Nov 28, 2023
1 parent 9a754ae commit 400d0db
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 55 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module.exports = {
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
return interaction.reply('Pong!');
await interaction.reply('Pong!');
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('server')
.setDescription('Display info about this server.'),
.setDescription('Provides information about the server.'),
async execute(interaction) {
return interaction.reply(`Server name: ${interaction.guild.name}\nTotal members: ${interaction.guild.memberCount}`);
await interaction.reply(`This server is ${interaction.guild.name} and has ${interaction.guild.memberCount} members.`);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module.exports = {
.setName('user')
.setDescription('Provides information about the user.'),
async execute(interaction) {
// interaction.user is the object representing the User who ran the command
// interaction.member is the GuildMember object, which represents the user in the specific guild
await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`);
},
};
8 changes: 5 additions & 3 deletions code-samples/creating-your-bot/command-deployment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ client.once(Events.ClientReady, readyClient => {

client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);

const command = client.commands.get(interaction.commandName);

if (!command) return;
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}

try {
await command.execute(interaction);
Expand Down
2 changes: 1 addition & 1 deletion guide/creating-your-bot/command-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const fs = require('node:fs');
const path = require('node:path');

const commands = [];
// Grab all the command files from the commands directory you created earlier
// Grab all the command folders from the commands directory you created earlier
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

Expand Down

0 comments on commit 400d0db

Please sign in to comment.