#Interaction has already been acknowledged - yet I am not acknowledging it ?

12 messages · Page 1 of 1 (latest)

warped sentinel
#

I have had a look through my code and I will append it below, however, I do not see where the issue is appearing as it is stating that the command is already replied to. However, the only reply is the "Error Cannot Execute".

Node Version: v16.10.0
Djs Version: v14.11.0

plain hingeBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

warped sentinel
#

typing it out now

desert raft
#

Means Interaction Is Defined Multi Times

warped sentinel
#
// command-handler.ts
if (!interaction.isChatInputCommand()) return

    const _cantExecute = CustomEmbed.general.unsuccessful_execution;

    try {
        const commandName = interaction.commandName
        const command = allCommandsMap.get(commandName)

        if (!command) throw new Error('Command not found.')

        await command.exec({
            client,
            interaction
        });

        // client.command_log(client, interaction.user, interaction.commandName);

    } catch (error) {
        client.log(`[Command Error] [${interaction?.commandName}]`, error)
        if (interaction.deferred || interaction.replied) {
            return interaction.editReply({
                embeds: [_cantExecute()]
            })
        }
        return interaction.reply({
            ephemeral: true,
            embeds: [_cantExecute()]
        })
    }
// command.ts
const meta = new SlashCommandBuilder()
    .setName('valorant')
    .setDescription('Get information about a Valorant Account.')
    .addStringOption((option) =>
        option
            .setName('name')
            .setDescription('What is the username of the user you would like to check? (Ex: Reflex#1234)')
            .setRequired(true)
    )

export default command(meta, async ({ interaction }) => {
    const user = interaction.options.getString('name', true);

    await interaction.reply({
        content: 'test'
    });
    return 0;
})
#

I get this error:

[[Command Error] [valorant]] DiscordAPIError[40060]: Interaction has already been acknowledged.
    at handleErrors (U:\Coding\roffle_bot\node_modules\@discordjs\rest\dist\index.js:640:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async BurstHandler.runRequest (U:\Coding\roffle_bot\node_modules\@discordjs\rest\dist\index.js:736:23)
    at async REST.request (U:\Coding\roffle_bot\node_modules\@discordjs\rest\dist\index.js:1387:22)
    at async ChatInputCommandInteraction.reply (U:\Coding\roffle_bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
    at async Object.exec (U:\Coding\roffle_bot\dist\commands\general\valorant.js:22:5)
    at async Object.exec (U:\Coding\roffle_bot\dist\events\interactionCreate\commands.js:19:9)
    at async CustomClient.<anonymous> (U:\Coding\roffle_bot\dist\utils\event.js:15:17) {
  requestBody: { files: [], json: { type: 4, data: [Object] } },
  rawError: {
    message: 'Interaction has already been acknowledged.',
    code: 40060
  },
  code: 40060,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/interactions/1111607251543789638/aW50ZXJhY3Rpb246MTExMTYwNzI1MTU0Mzc4OTYzODpmSm0wUXVYUjhPZHNqTG5QRmlvYVo1NTBBQ1UwdzRVN2NXaGJGeG5zRTFxalBBMEJyODFja2JPTzdLeDQ0VFN6RjZWMEp0TkJFY3lWbW51TkhRTHN2clhBbzR6Q0xhT3JxbWlURGFnOUtJQkM3R29qb0FlSks2aXRXUUdrVm9iRw/callback'
}
#

The output I am getting doesn't seem to match with my error.
If the interaction has already been acknowledged? The only thing that could have done it is the catch function of the command handler, no?

#

?

toxic parcel
#

the fact your error embed sends means that it what is replying to the interaction

#

try removing your error .reply method a'd see if that fixes it