Hey I'm following the discordjs guide, but when getting to the commands part it shows two ways of writing the commands either like :
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
return interaction.reply('Pong!');
},
};
or like:
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.deferReply();
await wait(4000)
await interaction.reply({
content: 'Secret Pong!',
ephemeral: true
});
}
});
On the second example the guide tells us to create and event forlder and make some changes to the index file but after that the bot doesnt run as it shows and error, but if I dont make the changes and leave the event code in the index file and revert the code to the first example it runs no problem, so my question is which one is up to date manner to write commands.
(soz for the long post)