is there a way to make discord wait for a second button input after the first update?

Also update the buttons in the action row...
15 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
treble/luna
treble/luna2y ago
use a collector or uhh one sec
d.js docs
d.js docs2y ago
method InteractionResponse#awaitMessageComponent() Collects a single component interaction that passes the filter. The Promise will reject if the time expires.
Snapper
SnapperOP2y ago
ooooh okay cool! Thank you also, am I updating the components in the action row correctly? I'm not getting an error for it but it's not updating
treble/luna
treble/luna2y ago
i cannot see the full file
d.js docs
d.js docs2y ago
To share long code snippets use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks.
Snapper
SnapperOP2y ago
oh okay one sec I'll get a snippet
await confirmation.update({
content: "Question" + questions[i].questionNumber,
embeds: [
quizEmbed
.setTitle(questions[i].questionText)
.setDescription(" ")
.setFields([
{
name: `Option 1`,
value: questions[i].answer1,
inline: true,
},
{
name: `Option 2`,
value: questions[i].answer2,
inline: true,
},
]),
],

components: [row
.answer1
.setStyle(ButtonStyle.Primary)
.setLabel("Option 1")

.answer2
.setStyle(ButtonStyle.Secondary)
.setLabel("Option 2"),
],
});
await confirmation.update({
content: "Question" + questions[i].questionNumber,
embeds: [
quizEmbed
.setTitle(questions[i].questionText)
.setDescription(" ")
.setFields([
{
name: `Option 1`,
value: questions[i].answer1,
inline: true,
},
{
name: `Option 2`,
value: questions[i].answer2,
inline: true,
},
]),
],

components: [row
.answer1
.setStyle(ButtonStyle.Primary)
.setLabel("Option 1")

.answer2
.setStyle(ButtonStyle.Secondary)
.setLabel("Option 2"),
],
});
treble/luna
treble/luna2y ago
what is row defined as
Snapper
SnapperOP2y ago
row is an action row that holds two buttons named answer1 and answer2
treble/luna
treble/luna2y ago
row.answer1, you'd have to acess them using row.components (or something like that, but not .answer1)
Snapper
SnapperOP2y ago
okay, so would the components just be an array inside the action row? I.e. row.components[0] .setStyle() row.components[1] .setStyle ?
d.js docs
d.js docs2y ago
Structures from the API cannot be edited directly. To do so, you can create a new structure (a builder) using the .from() method
const newEmbed = EmbedBuilder.from(embed).setTitle("title")
const newRow = ActionRowBuilder.from(row).addComponents(component)
const newEmbed = EmbedBuilder.from(embed).setTitle("title")
const newRow = ActionRowBuilder.from(row).addComponents(component)
Snapper
SnapperOP2y ago
oooh okay. so I would have to create a new action row all together. That works! Thank you so much for your help!
treble/luna
treble/luna2y ago
you can also use the old one but use something like components[0].data.label = "" (i dont know the exact properties for actionrowbuilders)
Snapper
SnapperOP2y ago
Thank you for the help luna!
Want results from more Discord servers?
Add your server