Button doing nothing

const button = new ButtonBuilder()
.setCustomId("COB")
.setLabel("Custom Options")
.setEmoji("⚙️")
.setStyle(ButtonStyle.Secondary);
const button = new ButtonBuilder()
.setCustomId("COB")
.setLabel("Custom Options")
.setEmoji("⚙️")
.setStyle(ButtonStyle.Secondary);
import { InteractionHandler, InteractionHandlerTypes } from "@sapphire/framework";
import type { ButtonInteraction } from "discord.js";

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 !== "COB") return this.none();
return this.some();
}

public async run(interaction: ButtonInteraction) {
await interaction.reply({
content: "Hello from a button interaction handler!",
ephemeral: true,
});
await interaction.channel?.send("Hi");
}
}
import { InteractionHandler, InteractionHandlerTypes } from "@sapphire/framework";
import type { ButtonInteraction } from "discord.js";

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 !== "COB") return this.none();
return this.some();
}

public async run(interaction: ButtonInteraction) {
await interaction.reply({
content: "Hello from a button interaction handler!",
ephemeral: true,
});
await interaction.channel?.send("Hi");
}
}
No errors too
Solution:
the folder for your buttons is incorrect then. As per our guide the folder should be called interaction-handlers: https://sapphirejs.dev/docs/Guide/interaction-handlers/what-are-they
Sapphire Framework
What are they? | Sapphire
These are interaction handlers! A simple class you can extend to handle almost all the interactions you may receive in
Jump to solution
7 Replies
<3
<38mo ago
Try wrapping the handler in try catch block
Ahmad A.
Ahmad A.OP8mo ago
💀
<3
<38mo ago
And add logging within your handler to see if the handler method parse is being called when you click the button
Ahmad A.
Ahmad A.OP8mo ago
its not called alr checked
Spinel
Spinel8mo ago
1. Which version of @sapphire/framework are you using? 2. What's your file/folder structure? 3. Did you use the CLI to generate your bot? 4. What's your main (CJS) or module (ESM) property in package.json 5. Are you using TypeScript? And if so, how are you compiling and running your code? That is to say, what are your build and startup scripts? - Did you remove your output folder and rebuild then try again? 6. Is your problem related to message commands? Did you add loadMessageCommandListeners to your SapphireClient options Remember that if you are new to @sapphire/framework it is important that you read the user guide.
Ahmad A.
Ahmad A.OP8mo ago
Latest version index.js - buttons - commands I didnt use the cli module Im using tsc i tried rebuilding not related i think @Favna answered Sorry for ping
Solution
Favna
Favna8mo ago
the folder for your buttons is incorrect then. As per our guide the folder should be called interaction-handlers: https://sapphirejs.dev/docs/Guide/interaction-handlers/what-are-they
Sapphire Framework
What are they? | Sapphire
These are interaction handlers! A simple class you can extend to handle almost all the interactions you may receive in
Want results from more Discord servers?
Add your server