The application did not respond

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;
//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;
//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;

}
}
//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;

}
}
//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 });
}
});
}
}
//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 });
}
});
}
}
7 Replies
Unknown User
Unknown User15mo ago
Message Not Public
Sign In & Join Server To View
MoinAmMorgen
MoinAmMorgen15mo ago
const command = interaction.client.commands.get(); should throw an error, at least it did in my code once Do you get an error?
Hessel
Hessel15mo ago
yes no
Hessel
Hessel15mo ago
Hessel
Hessel15mo ago
everything looks fine and it should work
d.js docs
d.js docs15mo ago
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops. • Once you do, log relevant values and if-conditions • More sophisticated debugging methods are breakpoints and runtime inspections: learn more
Hessel
Hessel15mo ago
forgot 1 line of code in my index file =-=