How to delete interaction buttons?

Hello
3 Replies
CodingWithJamal
CodingWithJamalOP2y ago
Im trying to use the button handler and im running into some problems
export class ButtonHandler extends InteractionHandler {
public constructor(ctx: PieceContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button
});
}

public override parse(interaction: ButtonInteraction) {
if (interaction.customId === ButtonCustomId.HELP_COMMAND_DELETE) return this.some();

return this.none();
}

public async run(interaction: ButtonInteraction) {
if (interaction.customId === ButtonCustomId.HELP_COMMAND_DELETE) {
await interaction.deleteReply(interaction.message.id);
}
}
}
export class ButtonHandler extends InteractionHandler {
public constructor(ctx: PieceContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button
});
}

public override parse(interaction: ButtonInteraction) {
if (interaction.customId === ButtonCustomId.HELP_COMMAND_DELETE) return this.some();

return this.none();
}

public async run(interaction: ButtonInteraction) {
if (interaction.customId === ButtonCustomId.HELP_COMMAND_DELETE) {
await interaction.deleteReply(interaction.message.id);
}
}
}
the button component:
.addComponents(
new ButtonBuilder()
.setCustomId(ButtonCustomId.HELP_COMMAND_DELETE)
.setLabel('Delete')
.setStyle(ButtonStyle.Danger),
)
.addComponents(
new ButtonBuilder()
.setCustomId(ButtonCustomId.HELP_COMMAND_DELETE)
.setLabel('Delete')
.setStyle(ButtonStyle.Danger),
)
the button is created on my help command and when clicked I want it to delete the interaction but it does not know which interaction message to delete. How can i find it?
Favna
Favna2y ago
the interaction is the button press but you want to edit the original interaction, not the button interaction, so you use interaction.message
CodingWithJamal
CodingWithJamalOP2y ago
ah i see
Want results from more Discord servers?
Add your server