second .update function erroring due to interaction already "replying"

I'm sorry if this is a common issue asked, I just need an answer as to why I cannot update the initial reply's embed twice (with components)? What should I be doing instead? Both a user select menu and a button are below the initial reply. My goal is to get the input from both of the components on the embed.
(async () => {
let selectedMember = null;
collector.on('collect', i => {
if (i.user.id === interaction.user.id) {
if (i.componentType === ComponentType.UserSelect) {
selectedMember = i.users.first();
i.update({
embeds: [
createEmbed(interaction, selectedMember.username)
],
ephemeral: true,
components: [userSelectRow, addReasonRow],
})
} else if (i.componentType === ComponentType.Button) {
const modal = new ModalBuilder()
.setCustomId("report-form")
.setTitle("Report Form")

const reportReasonInput = new TextInputBuilder()
.setCustomId("report-reason")
.setLabel(`What did this member do?`)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true)
.setPlaceholder(`This member broke a rule`)

const reportFormRow = new ActionRowBuilder().addComponents(reportReasonInput);
modal.addComponents(reportFormRow);
i.showModal(modal);

interaction.awaitModalSubmit({ time: 60_000 })
.then(interaction => i.update({
embeds: [
createEmbed(interaction, selectedMember.username, interaction.fields.getTextInputValue("report-reason"))
],
ephemeral: true,
components: [userSelectRow, addReasonRow],
}))
.catch(err => console.log("No modal submit interaction was collected", err))
}
} else {
i.reply({ content: `These buttons aren't for you!`, ephemeral: true });
}
});
})();
(async () => {
let selectedMember = null;
collector.on('collect', i => {
if (i.user.id === interaction.user.id) {
if (i.componentType === ComponentType.UserSelect) {
selectedMember = i.users.first();
i.update({
embeds: [
createEmbed(interaction, selectedMember.username)
],
ephemeral: true,
components: [userSelectRow, addReasonRow],
})
} else if (i.componentType === ComponentType.Button) {
const modal = new ModalBuilder()
.setCustomId("report-form")
.setTitle("Report Form")

const reportReasonInput = new TextInputBuilder()
.setCustomId("report-reason")
.setLabel(`What did this member do?`)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true)
.setPlaceholder(`This member broke a rule`)

const reportFormRow = new ActionRowBuilder().addComponents(reportReasonInput);
modal.addComponents(reportFormRow);
i.showModal(modal);

interaction.awaitModalSubmit({ time: 60_000 })
.then(interaction => i.update({
embeds: [
createEmbed(interaction, selectedMember.username, interaction.fields.getTextInputValue("report-reason"))
],
ephemeral: true,
components: [userSelectRow, addReasonRow],
}))
.catch(err => console.log("No modal submit interaction was collected", err))
}
} else {
i.reply({ content: `These buttons aren't for you!`, ephemeral: true });
}
});
})();
No description
6 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Swyftey
SwyfteyOP8mo ago
Thank you, I've got it working but it doesn't seem like the proper way to do it, am I doing alright?
Swyftey
SwyfteyOP8mo ago
No description
Swyftey
SwyfteyOP8mo ago
modal.addComponents(reportFormRow);
await i.showModal(modal)
i.awaitModalSubmit({ time: 60_000 })
.then(i =>
i.update({
embeds: [
createEmbed(interaction, selectedMember.username, i.fields.fields.first().value)
],
ephemeral: true,
components: [userSelectRow, addReasonRow],
}))
.catch(err => console.log("No modal submit interaction was collected", err))
modal.addComponents(reportFormRow);
await i.showModal(modal)
i.awaitModalSubmit({ time: 60_000 })
.then(i =>
i.update({
embeds: [
createEmbed(interaction, selectedMember.username, i.fields.fields.first().value)
],
ephemeral: true,
components: [userSelectRow, addReasonRow],
}))
.catch(err => console.log("No modal submit interaction was collected", err))
is there a better way to get a specific value in the collection like by name
d.js docs
d.js docs8mo ago
:method: ModalSubmitFields#getTextInputValue() Gets the value of a text input component given a custom id
Swyftey
SwyfteyOP8mo ago
that wasn't working earlier but ill try it again lol i changed so much that it works now thanks
Want results from more Discord servers?
Add your server