InteractionHandler Buttons

I have a problem with my buttons. Somehow they don't work... I guess it's something easy, but I can't figure out what it could be. The buttons are in a folder named interaction-handler/Buttons The error I am getting is:
[ERROR] Encountered error while handling an interaction handler run method for interaction-handler "CancelSetup" at path "C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\src\interaction-handlers\Buttons\Setup\CancelSetup p.ts" Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
at ButtonInteraction.editReply (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:157:48)
at ButtonHandler.run (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\src\interaction-handlers\Buttons\Setup\CancelSetup.ts:27:23)
at C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\framework\src\lib\structures\InteractionHandlerStore.ts:47:29
at Object.fromAsync (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\result\src\lib\Result.ts:53:25)
at Object.some (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\framework\src\lib\structures\InteractionHandlerStore.ts:47:29)
at _OptionSome.match (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\result\src\lib\Option\Some.ts:181:26)
at Object.ok (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\framework\src\lib\structures\InteractionHandlerStore.ts:33:19)
at _ResultOk.match (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\result\src\lib\Result\Ok.ts:188:26)
at _InteractionHandlerStore.run (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\framework\src\lib\structures\InteractionHandlerStore.ts:29:10)
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'InteractionNotReplied'
}
[ERROR] Encountered error while handling an interaction handler run method for interaction-handler "CancelSetup" at path "C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\src\interaction-handlers\Buttons\Setup\CancelSetup p.ts" Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
at ButtonInteraction.editReply (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:157:48)
at ButtonHandler.run (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\src\interaction-handlers\Buttons\Setup\CancelSetup.ts:27:23)
at C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\framework\src\lib\structures\InteractionHandlerStore.ts:47:29
at Object.fromAsync (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\result\src\lib\Result.ts:53:25)
at Object.some (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\framework\src\lib\structures\InteractionHandlerStore.ts:47:29)
at _OptionSome.match (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\result\src\lib\Option\Some.ts:181:26)
at Object.ok (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\framework\src\lib\structures\InteractionHandlerStore.ts:33:19)
at _ResultOk.match (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\result\src\lib\Result\Ok.ts:188:26)
at _InteractionHandlerStore.run (C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\framework\src\lib\structures\InteractionHandlerStore.ts:29:10)
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'InteractionNotReplied'
}
7 Replies
Jarvo
JarvoOP12mo ago
The code for one of the buttons is:
import { InteractionHandler, InteractionHandlerTypes } from '@sapphire/framework';
import { EmbedBuilder, Colors } from "discord.js";
import type { ButtonInteraction } from 'discord.js';
import { config } from "../../../utils/config";

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

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

return this.some();
}

public async run(interaction: ButtonInteraction) {
if (!interaction.isButton()) return;
const embed = new EmbedBuilder()
.setTitle("❌ Setup Cancelled")
.setColor(Colors.Red)
.setFooter({text: `${config.general.MessageEmbedItems.footer.text}`});

await interaction.editReply({ embeds: [embed], components: [] });
}
}
import { InteractionHandler, InteractionHandlerTypes } from '@sapphire/framework';
import { EmbedBuilder, Colors } from "discord.js";
import type { ButtonInteraction } from 'discord.js';
import { config } from "../../../utils/config";

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

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

return this.some();
}

public async run(interaction: ButtonInteraction) {
if (!interaction.isButton()) return;
const embed = new EmbedBuilder()
.setTitle("❌ Setup Cancelled")
.setColor(Colors.Red)
.setFooter({text: `${config.general.MessageEmbedItems.footer.text}`});

await interaction.editReply({ embeds: [embed], components: [] });
}
}
Ben
Ben12mo ago
You cant call editReply() on an interaction if you haven't already called reply() ordefer()
Jarvo
JarvoOP12mo ago
The button is on an existing interactionmessage, then how should I edit it?
Ben
Ben12mo ago
If memory serves, you can call interaction.deferUpdate() and then interaction.editReply() to update the message.
Solution
Ben
Ben12mo ago
Jarvo
JarvoOP12mo ago
Ah. I will try that. Thanks. Currently not available to change the code.
Jarvo
JarvoOP12mo ago
Thanks @Ben
Want results from more Discord servers?
Add your server