Encountered error while handling an interaction handler run method.

Hello, I have encountered an error:
[ERROR] Encountered error while handling an interaction handler run method for interaction-handler "1_ActivateContractHandler" at path "C:\Users\diman\OneDrive\Документы\GNews_v2\dist\interaction-handlers\contract\1_ActivateContractHandler.js" DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (c:\Users\diman\OneDrive\Документы\GNews_v2\lib\internal\process\task_queues.js:105:5)
at async BurstHandler.runRequest (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async ButtonInteraction.update (c:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:237:5)
at async ActivateContract.run (c:\Users\diman\OneDrive\Документы\GNews_v2\src\interaction-handlers\contract\1_ActivateContractHandler.ts:23:7)
at async Result.fromAsync (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@sapphire\result\dist\cjs\index.cjs:957:22)
at async Promise.allSettled (index 0)
at async _InteractionHandlerStore.run (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@sapphire\framework\dist\cjs\lib\structures\InteractionHandlerStore.cjs:45:21)
at async _CoreListener.run (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@sapphire\framework\dist\cjs\listeners\CoreInteractionCreate.cjs:21:7) {requestBody: {…}, rawError: {…}, code: 40060, status: 400, method: 'POST', …}
[ERROR] Encountered error while handling an interaction handler run method for interaction-handler "1_ActivateContractHandler" at path "C:\Users\diman\OneDrive\Документы\GNews_v2\dist\interaction-handlers\contract\1_ActivateContractHandler.js" DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (c:\Users\diman\OneDrive\Документы\GNews_v2\lib\internal\process\task_queues.js:105:5)
at async BurstHandler.runRequest (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async ButtonInteraction.update (c:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:237:5)
at async ActivateContract.run (c:\Users\diman\OneDrive\Документы\GNews_v2\src\interaction-handlers\contract\1_ActivateContractHandler.ts:23:7)
at async Result.fromAsync (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@sapphire\result\dist\cjs\index.cjs:957:22)
at async Promise.allSettled (index 0)
at async _InteractionHandlerStore.run (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@sapphire\framework\dist\cjs\lib\structures\InteractionHandlerStore.cjs:45:21)
at async _CoreListener.run (C:\Users\diman\OneDrive\Документы\GNews_v2\node_modules\@sapphire\framework\dist\cjs\listeners\CoreInteractionCreate.cjs:21:7) {requestBody: {…}, rawError: {…}, code: 40060, status: 400, method: 'POST', …}
My full code:
import { InteractionHandler, InteractionHandlerTypes } from '@sapphire/framework';
import { ActionRowBuilder, ButtonInteraction, StringSelectMenuBuilder } from 'discord.js';
import { categoryEmbed } from '../../ui/contract/embedsContractSource';
import { categoryMenu } from '../../ui/contract/menusContractSource';

export class ActivateContract extends InteractionHandler {
public constructor(ctx: InteractionHandler.LoaderContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button
});
}

public override parse(interaction: ButtonInteraction) {
if (interaction.customId !== 'activate-button') return this.none();

return this.some();
}

public async run(interaction: ButtonInteraction) {
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(categoryMenu);

await interaction.update({
embeds: [categoryEmbed],
components: [row],
});
}
}

export default ActivateContract;
import { InteractionHandler, InteractionHandlerTypes } from '@sapphire/framework';
import { ActionRowBuilder, ButtonInteraction, StringSelectMenuBuilder } from 'discord.js';
import { categoryEmbed } from '../../ui/contract/embedsContractSource';
import { categoryMenu } from '../../ui/contract/menusContractSource';

export class ActivateContract extends InteractionHandler {
public constructor(ctx: InteractionHandler.LoaderContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button
});
}

public override parse(interaction: ButtonInteraction) {
if (interaction.customId !== 'activate-button') return this.none();

return this.some();
}

public async run(interaction: ButtonInteraction) {
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(categoryMenu);

await interaction.update({
embeds: [categoryEmbed],
components: [row],
});
}
}

export default ActivateContract;
I have a message with one button, I click on it, the message is updated within ~1 second, after which an error goes to the console. The bot does not turn off. Nothing else handles this button. If I use Listener, then everything is fine, but I basically want to process it through InteractionHandler 😁 -# Written through a translator
1 Reply
andreichernov200
andreichernov200OP5d ago
I fixed it, I didn't figure out how... 🥲
Want results from more Discord servers?
Add your server