Button Handler

is there some sort of built-in button handler in sapphire? if no, how can I handle them
Solution:
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
13 Replies
Solution
Favna
Favna•8mo ago
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
-Carlos👑
-Carlos👑•8mo ago
do I need to put this inside a specific folder?
Favna
Favna•8mo ago
it's all in the guide, just read it
-Carlos👑
-Carlos👑•8mo ago
do I need to create 1 file per button?
Favna
Favna•8mo ago
again, also covered in the guide. Hint: parse method
-Carlos👑
-Carlos👑•8mo ago
probably wrong but is it like this?
parse(interaction) {
if (interaction.customId === "reply1") return this.none();

return this.some();
}

async run(interaction) {
await interaction.reply({
content: "Reply1",
ephemeral: true,
});
}

parse(interaction) {
if (interaction.customId === "reply2") return this.none();

return this.some();
}

async run(interaction) {
await interaction.reply({
content: "Reply2",
ephemeral: true,
});
}
parse(interaction) {
if (interaction.customId === "reply1") return this.none();

return this.some();
}

async run(interaction) {
await interaction.reply({
content: "Reply1",
ephemeral: true,
});
}

parse(interaction) {
if (interaction.customId === "reply2") return this.none();

return this.some();
}

async run(interaction) {
await interaction.reply({
content: "Reply2",
ephemeral: true,
});
}
Favna
Favna•8mo ago
a class can always only have 1 instance of a method. In any programming language. I recommend reviewing the basics of classes
-Carlos👑
-Carlos👑•8mo ago
I figured it out, however when I click submit it says "Something went wrong. Try again." button handler: https://pastebin.com/HnBC2tcd modal handler: https://pastebin.com/sXUS3VTb
Pastebin
Button Handler - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
Modal Handler - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Favna
Favna•8mo ago
code where you create the button? is the folder named exactly interaction-handlers?
-Carlos👑
-Carlos👑•8mo ago
yes
-Carlos👑
-Carlos👑•8mo ago
Pastebin
button.js - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Favna
Favna•8mo ago
idk then. Add some debugging to your code.
-Carlos👑
-Carlos👑•8mo ago
figured it out, there was a spelling error in the modal handler