fauteen
fauteen
DIAdiscord.js - Imagine an app
Created by fauteen on 6/22/2024 in #djs-questions
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.
15 replies
DIAdiscord.js - Imagine an app
Created by fauteen on 6/21/2024 in #djs-questions
Unknown Interaction
for some reason I keep getting this error when trying to run a command, this only happens sometimes.
DiscordAPIError: Unknown interaction
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async CommandInteraction.deferReply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:61:5)
at async module.exports (/home/container/src/events/interactionCreate.js:5:5) {
method: 'post',
path: '/interactions/1253563066042421249/aW50ZXJhY3Rpb246MTI1MzU2MzA2NjA0MjQyMTI0OTpKTlZsOVdWcUJLbFZ4T25wdG1iUzVTUUlDSUFRcjcxUk1wRXpJbmVXUTFseGdXTXhNRHBOOHJpTmo1eUNKMGs4Mkl4eWxBUURKUmZQc0pvcEN4OHVKaVk4WVFYRDlNaHhvV1o2QlNXUUZhQUFVU1hLTDNoUFlReTNzU0s0a0xoTg/callback',
code: 10062,
httpStatus: 404,
requestData: { json: { type: 5, data: [Object] }, files: [] }
}
DiscordAPIError: Unknown interaction
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async CommandInteraction.deferReply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:61:5)
at async module.exports (/home/container/src/events/interactionCreate.js:5:5) {
method: 'post',
path: '/interactions/1253563066042421249/aW50ZXJhY3Rpb246MTI1MzU2MzA2NjA0MjQyMTI0OTpKTlZsOVdWcUJLbFZ4T25wdG1iUzVTUUlDSUFRcjcxUk1wRXpJbmVXUTFseGdXTXhNRHBOOHJpTmo1eUNKMGs4Mkl4eWxBUURKUmZQc0pvcEN4OHVKaVk4WVFYRDlNaHhvV1o2QlNXUUZhQUFVU1hLTDNoUFlReTNzU0s0a0xoTg/callback',
code: 10062,
httpStatus: 404,
requestData: { json: { type: 5, data: [Object] }, files: [] }
}
34 replies