Interaction already replied issue
const { MessageEmbed } = require('discord.js');
module.exports = {
name: 'flightlog',
description: 'Log a flight with a flight number',
options: [
{
name: 'flight_number',
type: 'STRING',
description: 'The flight number to log',
required: true,
},
],
run: async (client, interaction) => {
const userId = interaction.user.id;
const userName = interaction.user.username;
const flightNumber = interaction.options.getString('flight_number');
const embed = new MessageEmbed()
.setTitle('Flight Log Entry')
.setDescription(`**User:** ${userName}\n**Flight Number:** ${flightNumber}`)
.setColor('BLUE')
.setFooter('Flight Log Bot')
.setTimestamp();
const logChannelId = '1244624724223332463';
const logChannel = client.channels.cache.get(logChannelId);
if (logChannel) {
logChannel.send({ embeds: [embed] })
.then(() => {
interaction.reply({ content: 'Flight log entry recorded successfully.', ephemeral: true });
})
.catch((error) => {
console.error('Failed to send message to the log channel:', error);
interaction.reply({ content: 'There was an error recording your flight log entry. Please try again later.', ephemeral: true });
});
} else {
console.error('Log channel not found');
interaction.reply({ content: 'Log channel not found. Please contact the server administrator.', ephemeral: true });
}
},
};
const { MessageEmbed } = require('discord.js');
module.exports = {
name: 'flightlog',
description: 'Log a flight with a flight number',
options: [
{
name: 'flight_number',
type: 'STRING',
description: 'The flight number to log',
required: true,
},
],
run: async (client, interaction) => {
const userId = interaction.user.id;
const userName = interaction.user.username;
const flightNumber = interaction.options.getString('flight_number');
const embed = new MessageEmbed()
.setTitle('Flight Log Entry')
.setDescription(`**User:** ${userName}\n**Flight Number:** ${flightNumber}`)
.setColor('BLUE')
.setFooter('Flight Log Bot')
.setTimestamp();
const logChannelId = '1244624724223332463';
const logChannel = client.channels.cache.get(logChannelId);
if (logChannel) {
logChannel.send({ embeds: [embed] })
.then(() => {
interaction.reply({ content: 'Flight log entry recorded successfully.', ephemeral: true });
})
.catch((error) => {
console.error('Failed to send message to the log channel:', error);
interaction.reply({ content: 'There was an error recording your flight log entry. Please try again later.', ephemeral: true });
});
} else {
console.error('Log channel not found');
interaction.reply({ content: 'Log channel not found. Please contact the server administrator.', ephemeral: true });
}
},
};
10 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!you likely defer or reply somewhere else in your code
i am only using this command, and this command gets the error only
you appear to be replying somewhere else though
check your interactionCreate
const { MessageEmbed, Collection } = require('discord.js')
module.exports = async (client, interaction) => {
if (interaction.isCommand()) {
await interaction.deferReply({ ephemeral: false })
let embed = new MessageEmbed()
const cmd = client.commands.get(interaction.commandName);
if (!cmd) return interaction.followUp({ content: "An error has occured " });
const args = [];
for (let option of interaction.options.data) {
if (option.type === "SUB_COMMAND") {
if (option.name) args.push(option.name);
option.options ?.forEach((x) => {
if (x.value) args.push(x.value);
});
} else if (option.value) args.push(option.value);
}
if (cmd.cooldown) {
if (!client.cooldown.has(cmd.name)) { client.cooldown.set(cmd.name, new Collection()) }
if (client.cooldown.get(cmd.name).has(interaction.user.id)) {
if (Date.now() < client.cooldown.get(cmd.name).get(interaction.user.id) + (cmd.cooldown) * 1000) {
const time_left = (client.cooldown.get(cmd.name).get(interaction.user.id) + (cmd.cooldown) * 1000 - Date.now()) / 1000;
return interaction.followUp({
content: `cooldown for \`${time_left.toFixed(1)}\` seconds`,
ephemeral: true
})
}
}
client.cooldown.get(cmd.name).set(interaction.user.id, Date.now());
setTimeout(() => client.cooldown.get(cmd.name).delete(interaction.user.id), (cmd.cooldown) * 1000);
}
if (cmd.permissions) {
if (!client.vaildPermissions.includes(cmd.permissions)) return;
if (!interaction.member.permissions.has(cmd.permissions)) return interaction.followUp({
content: `You don\'t have \`${cmd.permissions}\` permission`,
ephemeral: true
})
}
cmd.run(client, interaction, args);
}
}
const { MessageEmbed, Collection } = require('discord.js')
module.exports = async (client, interaction) => {
if (interaction.isCommand()) {
await interaction.deferReply({ ephemeral: false })
let embed = new MessageEmbed()
const cmd = client.commands.get(interaction.commandName);
if (!cmd) return interaction.followUp({ content: "An error has occured " });
const args = [];
for (let option of interaction.options.data) {
if (option.type === "SUB_COMMAND") {
if (option.name) args.push(option.name);
option.options ?.forEach((x) => {
if (x.value) args.push(x.value);
});
} else if (option.value) args.push(option.value);
}
if (cmd.cooldown) {
if (!client.cooldown.has(cmd.name)) { client.cooldown.set(cmd.name, new Collection()) }
if (client.cooldown.get(cmd.name).has(interaction.user.id)) {
if (Date.now() < client.cooldown.get(cmd.name).get(interaction.user.id) + (cmd.cooldown) * 1000) {
const time_left = (client.cooldown.get(cmd.name).get(interaction.user.id) + (cmd.cooldown) * 1000 - Date.now()) / 1000;
return interaction.followUp({
content: `cooldown for \`${time_left.toFixed(1)}\` seconds`,
ephemeral: true
})
}
}
client.cooldown.get(cmd.name).set(interaction.user.id, Date.now());
setTimeout(() => client.cooldown.get(cmd.name).delete(interaction.user.id), (cmd.cooldown) * 1000);
}
if (cmd.permissions) {
if (!client.vaildPermissions.includes(cmd.permissions)) return;
if (!interaction.member.permissions.has(cmd.permissions)) return interaction.followUp({
content: `You don\'t have \`${cmd.permissions}\` permission`,
ephemeral: true
})
}
cmd.run(client, interaction, args);
}
}
there you go https://bork.treble-is-fluffy.gay/floof91c1930d.png
either use editReply
or dont defer
let me fix that and see
when i changed that line to editreply, it worked. but i got this error when trying to run other commands.
rror [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
at CommandInteraction.editReply (/home/runner/System-Bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:149:48)
at module.exports (/home/runner/System-Bot/src/events/interactionCreate.js:5:23)
at Client.emit (node:events:394:28)
at InteractionCreateAction.handle (/home/runner/System-Bot/node_modules/discord.js/src/client/actions/InteractionCreate.js:83:12)
at Object.module.exports [as INTERACTION_CREATE] (/home/runner/System-Bot/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/runner/System-Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31)
at WebSocketShard.onPacket (/home/runner/System-Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:493:22)
at WebSocketShard.onMessage (/home/runner/System-Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:327:10)
at callListener (/home/runner/System-Bot/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onMessage (/home/runner/System-Bot/node_modules/ws/lib/event-target.js:209:9) {
[Symbol(code)]: 'INTERACTION_NOT_REPLIED'
}
rror [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
at CommandInteraction.editReply (/home/runner/System-Bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:149:48)
at module.exports (/home/runner/System-Bot/src/events/interactionCreate.js:5:23)
at Client.emit (node:events:394:28)
at InteractionCreateAction.handle (/home/runner/System-Bot/node_modules/discord.js/src/client/actions/InteractionCreate.js:83:12)
at Object.module.exports [as INTERACTION_CREATE] (/home/runner/System-Bot/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/runner/System-Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31)
at WebSocketShard.onPacket (/home/runner/System-Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:493:22)
at WebSocketShard.onMessage (/home/runner/System-Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:327:10)
at callListener (/home/runner/System-Bot/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onMessage (/home/runner/System-Bot/node_modules/ws/lib/event-target.js:209:9) {
[Symbol(code)]: 'INTERACTION_NOT_REPLIED'
}
then you arent deferring some of your other commands
Yep, I've found out the issue. Thanks!