When I try to run my command, it doesn't respond and there are no errors
//ping.js
import { SlashCommandBuilder } from 'discord.js'
const ping = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
await interaction.reply('Pong!');
},
};
export default ping;```
```js
//commandHandler.js
import fs from "fs";
export const commandHandler = {
async load(client, Collection) {
console.log("Command handler running");
const commandFiles = fs.readdirSync('./src/commands').filter(file => file.endsWith('.js'));
const commandsArr = await Promise.all(commandFiles.map(async command => (await import(`../commands/${command}`)).default));
client.commands = commandsArr.reduce((res, command) => {
res.set(command.data.name, command);
return res;
}, new Collection());
return client.commands;
}
}```
```js
//commandListener.js
export const commandListener = {
async run(client, Events) {
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
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 });
}
});
}
}```