Error [InteractionAlreadyReplied] The reply to this interaction has already been sent or deferred.

const { EmbedBuilder, SlashCommandBuilder, Integration } = require('discord.js');
const wait = require('node:timers/promises').setTimeout;
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Gets Bot and API ping'),
async execute(interaction) {
const pingEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('Calculating Bot Ping...')
await interaction.reply({ embeds: [pingEmbed]})
const apiPing = client.ws.ping;
const botPing = interaction.createdTimestamp - message.createdTimestamp;
const pingFinalEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('Ping')
.setDescription(`**API Ping:** ${apiPing}ms\n**Bot Ping:** ${botPing}ms`)
await wait(2000);
await interaction.editReply({ embeds: [pingFinalEmbed]});

}
}
const { EmbedBuilder, SlashCommandBuilder, Integration } = require('discord.js');
const wait = require('node:timers/promises').setTimeout;
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Gets Bot and API ping'),
async execute(interaction) {
const pingEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('Calculating Bot Ping...')
await interaction.reply({ embeds: [pingEmbed]})
const apiPing = client.ws.ping;
const botPing = interaction.createdTimestamp - message.createdTimestamp;
const pingFinalEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('Ping')
.setDescription(`**API Ping:** ${apiPing}ms\n**Bot Ping:** ${botPing}ms`)
await wait(2000);
await interaction.editReply({ embeds: [pingFinalEmbed]});

}
}
12 Replies
d.js docs
d.js docs2y ago
DiscordAPIError: Interaction has already been acknowledged[INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred. You have already replied to the interaction. • Use <Interaction>.followUp() to send a new message • If you deferred reply it's better to use <Interaction>.editReply() • Responding to slash commands / buttons / select menus
PAdventures
PAdventures2y ago
ReferenceError: client is not defined
at Object.execute (D:\PA_Admin Backup copy\Commands\ping.js:12:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:12:13)
node:events:498
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:101:46)
at Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:15:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:381:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21) {
[Symbol(code)]: 90
}
ReferenceError: client is not defined
at Object.execute (D:\PA_Admin Backup copy\Commands\ping.js:12:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:12:13)
node:events:498
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:101:46)
at Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:15:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:381:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21) {
[Symbol(code)]: 90
}
Almeida
Almeida2y ago
use interaction.client
PAdventures
PAdventures2y ago
ReferenceError: message is not defined
at Object.execute (D:\PA_Admin Backup copy\Commands\ping.js:13:56)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:12:13)
node:events:498
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:101:46)
at Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:15:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:381:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21) {
[Symbol(code)]: 90
}
ReferenceError: message is not defined
at Object.execute (D:\PA_Admin Backup copy\Commands\ping.js:13:56)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:12:13)
node:events:498
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (D:\PA_Admin Backup copy\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:101:46)
at Object.execute (D:\PA_Admin Backup copy\Events\interactionCreate.js:15:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:381:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21) {
[Symbol(code)]: 90
}
Almeida
Almeida2y ago
you didnt define message
PAdventures
PAdventures2y ago
TypeError: Cannot read properties of undefined (reading 'createdTimestamp')
TypeError: Cannot read properties of undefined (reading 'createdTimestamp')
const botPing = interaction.createdTimestamp - interaction.createdTimestamp;
const botPing = interaction.createdTimestamp - interaction.createdTimestamp;
Output
0ms
0ms
how do i get the interaction that just i just sent to make dis work
Mozzy
Mozzy2y ago
x - x is 0
PAdventures
PAdventures2y ago
ik
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventures2y ago
const interactionTime = interaction.fetchReply()
const botPing = interactionTime.createdTimestamp - interaction.createdTimestamp;
const interactionTime = interaction.fetchReply()
const botPing = interactionTime.createdTimestamp - interaction.createdTimestamp;
will this do?
Almeida
Almeida2y ago
.fetchReply() returns a promise
PAdventures
PAdventures2y ago
const message = await interaction.fetchReply();
const botPing = message.createdTimestamp - interaction.createdTimestamp;
const message = await interaction.fetchReply();
const botPing = message.createdTimestamp - interaction.createdTimestamp;
Output (Correct I think)
//As Embed
Ping
API Ping: 106ms
Bot Ping: 204ms
//As Embed
Ping
API Ping: 106ms
Bot Ping: 204ms