client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(interaction);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
const errorID = toString(Math.floor(Math.random() * 1000000000));
const errorEmbedServer = new EmbedBuilder()
.setTitle("Critical Error")
.setDescription(`The user ${interaction.user.username} (${interaction.user.id}) has encountered a critical error.`)
.addFields(
{"name": "Command", "value": interaction.commandName, "inline": true},
{"name": "ErrorID", "value": errorID, "inline": true},
{"name": "Error", "value": `\`\`\`${error.stack}\`\`\``}
)
.setColor("RED")
const errorEmbedUser = new EmbedBuilder()
.setTitle("Critical Error")
.setDescription(`Uh Oh, it looks like you've encountered a critical error. Please contact the developers with the errorID of \`${errorID}\``)
.setColor("RED")
logs.createLog(`error-${errorID}`, error.stack); logs.pushLogsToFiles();
interaction.client.channels.fetch(clientData.errorChannel).then(channel => {
channel.send({ embeds: [errorEmbedServer] });
});
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ embeds: [errorEmbedUser], ephemeral: true });
} else {
await interaction.reply({ embeds: [errorEmbedUser], ephemeral: true });
}
}
});client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(interaction);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
const errorID = toString(Math.floor(Math.random() * 1000000000));
const errorEmbedServer = new EmbedBuilder()
.setTitle("Critical Error")
.setDescription(`The user ${interaction.user.username} (${interaction.user.id}) has encountered a critical error.`)
.addFields(
{"name": "Command", "value": interaction.commandName, "inline": true},
{"name": "ErrorID", "value": errorID, "inline": true},
{"name": "Error", "value": `\`\`\`${error.stack}\`\`\``}
)
.setColor("RED")
const errorEmbedUser = new EmbedBuilder()
.setTitle("Critical Error")
.setDescription(`Uh Oh, it looks like you've encountered a critical error. Please contact the developers with the errorID of \`${errorID}\``)
.setColor("RED")
logs.createLog(`error-${errorID}`, error.stack); logs.pushLogsToFiles();
interaction.client.channels.fetch(clientData.errorChannel).then(channel => {
channel.send({ embeds: [errorEmbedServer] });
});
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ embeds: [errorEmbedUser], ephemeral: true });
} else {
await interaction.reply({ embeds: [errorEmbedUser], ephemeral: true });
}
}
});[ERROR] command ping wasn't found[ERROR] command ping wasn't found even though it was successfully registered. Here's my slash command file:const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
description: 'Replies with Pong!',
permissions: [],
isHidden: true,
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
await interaction.reply('Pong!');
},
};const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
description: 'Replies with Pong!',
permissions: [],
isHidden: true,
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
await interaction.reply('Pong!');
},
};