help meeded
error
```
Node.js v20.15.1
node:events:497
throw er; // Unhandled 'error' event
^
DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:831:23)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1272:22)
at async ChatInputCommandInteraction.reply (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:115:5)
at async Client.<anonymous> (/app/bot.js:57:9)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:402:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'There was an error while executing this command!',
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
}
},
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1290710169088557218/aW50ZXJhY3Rpb246MTI5MDcxMDE2OTA4ODU1NzIxODo3R3JBQWdLdjUzN2xrU0d1eTRibzNaMVhudEREUkNtaDcxNHFKdXR5WFd1Vm5tZVdqTFJlVkZWTDBVWm1XZXJDSU5qMnhoYm82QWZ2Nkt1ekFDQWoxVDlGc3JpRkZaNHBRWURzdEEybFJvRURDcGphemtOc1EzZEZVSm9XajRwVA/callback'
}
Node.js v20.15.1
Node.js v20.15.1
node:events:497
throw er; // Unhandled 'error' event
^
DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:831:23)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1272:22)
at async ChatInputCommandInteraction.reply (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:115:5)
at async Client.<anonymous> (/app/bot.js:57:9)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:402:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'There was an error while executing this command!',
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
}
},
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1290710169088557218/aW50ZXJhY3Rpb246MTI5MDcxMDE2OTA4ODU1NzIxODo3R3JBQWdLdjUzN2xrU0d1eTRibzNaMVhudEREUkNtaDcxNHFKdXR5WFd1Vm5tZVdqTFJlVkZWTDBVWm1XZXJDSU5qMnhoYm82QWZ2Nkt1ekFDQWoxVDlGc3JpRkZaNHBRWURzdEEybFJvRURDcGphemtOc1EzZEZVSm9XajRwVA/callback'
}
Node.js v20.15.1
3 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!code-
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
try {
// Defer the reply immediately to prevent timeout and ensure you can reply later
await interaction.deferReply({ ephemeral: false });
// Calculate the latencies
const botLatency = Date.now() - interaction.createdTimestamp;
const discordLatency = Math.round(interaction.client.ws.ping);
// Create the embed with the latency details
const embed = new EmbedBuilder()
.setColor('#00ffff')
.setTitle('Pong!')
.setDescription(`**Bot Latency:** \`${botLatency}ms\`\n**Discord Latency:** \`${discordLatency >= 0 ? discordLatency : 0}ms\``);
// Edit the reply with the embed content
await interaction.editReply({ embeds: [embed] });
} catch (error) {
console.error('Error executing ping command:', error);
// Send an error message only if the interaction has not been replied to or deferred
if (!interaction.deferred && !interaction.replied) {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
},
};
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
try {
// Defer the reply immediately to prevent timeout and ensure you can reply later
await interaction.deferReply({ ephemeral: false });
// Calculate the latencies
const botLatency = Date.now() - interaction.createdTimestamp;
const discordLatency = Math.round(interaction.client.ws.ping);
// Create the embed with the latency details
const embed = new EmbedBuilder()
.setColor('#00ffff')
.setTitle('Pong!')
.setDescription(`**Bot Latency:** \`${botLatency}ms\`\n**Discord Latency:** \`${discordLatency >= 0 ? discordLatency : 0}ms\``);
// Edit the reply with the embed content
await interaction.editReply({ embeds: [embed] });
} catch (error) {
console.error('Error executing ping command:', error);
// Send an error message only if the interaction has not been replied to or deferred
if (!interaction.deferred && !interaction.replied) {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
},
};
The error points to a .reply somewhere
if that reply is the reply in the code you showed, you should see an error message