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•13mo 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👑OP•13mo ago
do I need to put this inside a specific folder?
Favna
Favna•13mo ago
it's all in the guide, just read it
-Carlos👑
-Carlos👑OP•13mo ago
do I need to create 1 file per button?
Favna
Favna•13mo ago
again, also covered in the guide. Hint: parse method
-Carlos👑
-Carlos👑OP•13mo 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•13mo 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👑OP•13mo 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•13mo ago
code where you create the button? is the folder named exactly interaction-handlers?
-Carlos👑
-Carlos👑OP•13mo ago
yes
-Carlos👑
-Carlos👑OP•13mo 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•13mo ago
idk then. Add some debugging to your code.
-Carlos👑
-Carlos👑OP•13mo ago
figured it out, there was a spelling error in the modal handler
Want results from more Discord servers?
Add your server