Modal not appearing after user is selected from UserSelectMenu

How would I get a module to be created after a member is selected from a user select menu? I think my main issue not being able to figure out how to get the user that was selected. Everything else seems to work so far. This is the event file for interactionCreate:
if (interaction.isUserSelectMenu()) {
switch (interaction.customId) {
case "member-select":

const modal = new ModalBuilder()
.setCustomId("report-form")
.setTitle("Report Form")

const reportReasonInput = new TextInputBuilder()
.setCustomId("reportReasonInput")
.setLabel(`What did ${interaction.user.username} do?`)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true)
.setPlaceholder(`${interaction.user.username} broke a rule`)

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

break;

default:
break;
}
}
if (interaction.isUserSelectMenu()) {
switch (interaction.customId) {
case "member-select":

const modal = new ModalBuilder()
.setCustomId("report-form")
.setTitle("Report Form")

const reportReasonInput = new TextInputBuilder()
.setCustomId("reportReasonInput")
.setLabel(`What did ${interaction.user.username} do?`)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true)
.setPlaceholder(`${interaction.user.username} broke a rule`)

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

break;

default:
break;
}
}
5 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
d.js docs
d.js docs8mo ago
:property: UserSelectMenuInteraction#users Collection of the selected users
Swyftey
SwyfteyOP8mo ago
@Squid I actually figured that out on my own but have another issue the module is still not popping up, even with the updated edit
if (interaction.isUserSelectMenu()) {
console.log(interaction.users.first());
switch (interaction.customId) {
case "member-select":
const selectedMember = interaction.users.first();
const modal = new ModalBuilder()
.setCustomId("report-form")
.setTitle("Report Form")

const reportReasonInput = new TextInputBuilder()
.setCustomId("reportReasonInput")
.setLabel(`What did ${selectedMember.username} do?`)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true)
.setPlaceholder(`${selectedMember.username} broke a rule`)

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

break;

default:
break;
};
if (interaction.isUserSelectMenu()) {
console.log(interaction.users.first());
switch (interaction.customId) {
case "member-select":
const selectedMember = interaction.users.first();
const modal = new ModalBuilder()
.setCustomId("report-form")
.setTitle("Report Form")

const reportReasonInput = new TextInputBuilder()
.setCustomId("reportReasonInput")
.setLabel(`What did ${selectedMember.username} do?`)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true)
.setPlaceholder(`${selectedMember.username} broke a rule`)

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

break;

default:
break;
};
At one point, I used console.log to make sure that it is at least getting to where the modal is supposed to create, and it is. But, the module is not showing
Squid
Squid8mo ago
It's not showing because you never called interaction.showModal(modal) You're defining a modal and adding a component to it, but you never sent that data over to discord
Swyftey
SwyfteyOP8mo ago
jesus I copied it from another script to switch locations it should have been there thank you
Want results from more Discord servers?
Add your server