No he tocado js en años, por lo que estoy bastante oxidado en términos de codificación en javascript. Si tienes respuestas, ¡no dudes en decirme y criticar! Dentro de ping.js
const { SlashCommandBuilder } = require('@discordjs/builders'); module.exports = { data: new SlashCommandBuilder() .setName('ping') .setDescription('Replies with Pong!'), async execute(interaction) { return interaction.reply('Pong!'); }, };en mi archivo bot.js
client.commands = new Collection(); const commandFiles = fs.readdirSync('./src/commands').filter(file => file.endsWith('.js')); for (const file of commandFiles) { const command = require(`./src/commands/${file}`); client.commands.set(command.data.name, command); } client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return; const command = client.commands.get(interaction.commandName); if (!command) return; try { await command.execute(interaction); } catch (error) { console.error(error); await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); } });