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 });
}
},
};the embed sends to the desired channel id, but i get an interaction already replied error even though the embed sends, and it wont send the user a confirmation message saying Flight log entry recorded successfully.