Multiselect dropdown list collector doesn't trigger

Good evening I have a first Dropdown list with 2 choices (maxValues = 1), then according to the choices it displays another dropdown list with 3 choices (maxValues = 3). The collector is working correctly for the first dropdown but for the second one when I select for example 2 values and then click away, it does not trigger the collector. Here's the code below :
async execute(interaction) {
const donjonOptions = createDonjonOptions();

const row = new ActionRowBuilder().addComponents(
new StringSelectMenuBuilder()
.setCustomId('dungeonSelect')
.setPlaceholder('Sélectionne un donjon')
.addOptions(donjonOptions)
);

const reply = await interaction.reply({
components: [row],
fetchReply: true,
});

const collector = reply.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
});

const succesSelectMenu = new StringSelectMenuBuilder()
.setCustomId('succesSelect')
.setPlaceholder('Slectionnez les succès')
.setMinValues(1);

let selectedDungeon = '';
const selectedSucces = [];

collector.on('collect', async (menuInteraction) => {
if (menuInteraction.customId === 'dungeonSelect') {
// eslint-disable-next-line prefer-destructuring
selectedDungeon = menuInteraction.values[0];
const succesOptions = createSuccesOptions(selectedDungeon);

succesSelectMenu
.setMaxValues(succesOptions.length)
.addOptions(succesOptions);

const row = new ActionRowBuilder().addComponents(succesSelectMenu);

await menuInteraction.reply({
content: `Donjon sélectionné: ${selectedDungeon}`,
components: [row],
});
} else if (menuInteraction.customId === 'succesSelect') {
selectedSucces.push(...menuInteraction.values); // doesn't trigger
console.log(selectedSucces); // doesn't work
}
});
},
async execute(interaction) {
const donjonOptions = createDonjonOptions();

const row = new ActionRowBuilder().addComponents(
new StringSelectMenuBuilder()
.setCustomId('dungeonSelect')
.setPlaceholder('Sélectionne un donjon')
.addOptions(donjonOptions)
);

const reply = await interaction.reply({
components: [row],
fetchReply: true,
});

const collector = reply.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
});

const succesSelectMenu = new StringSelectMenuBuilder()
.setCustomId('succesSelect')
.setPlaceholder('Slectionnez les succès')
.setMinValues(1);

let selectedDungeon = '';
const selectedSucces = [];

collector.on('collect', async (menuInteraction) => {
if (menuInteraction.customId === 'dungeonSelect') {
// eslint-disable-next-line prefer-destructuring
selectedDungeon = menuInteraction.values[0];
const succesOptions = createSuccesOptions(selectedDungeon);

succesSelectMenu
.setMaxValues(succesOptions.length)
.addOptions(succesOptions);

const row = new ActionRowBuilder().addComponents(succesSelectMenu);

await menuInteraction.reply({
content: `Donjon sélectionné: ${selectedDungeon}`,
components: [row],
});
} else if (menuInteraction.customId === 'succesSelect') {
selectedSucces.push(...menuInteraction.values); // doesn't trigger
console.log(selectedSucces); // doesn't work
}
});
},
Thank you for your help
9 Replies
d.js toolkit
d.js toolkit12mo 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.
Sourceae
Sourceae12mo ago
discord.js@14.11.0
Idris
Idris12mo ago
where are you creating the collector for the 2nd select menu?
Sourceae
Sourceae12mo ago
I thought I didn't need to as I distinguished 2 cases with the customId and it's a stringSelect, so it would work for both
Idris
Idris12mo ago
you're creating the collector on a message where there's just the 1st select menu
Sourceae
Sourceae12mo ago
The first message is updated with the second select menu thought I don't really understand how should I fix this since it's the same message who's been collected all along the process
Idris
Idris12mo ago
you have sent a message in which you have put a row with only one select menu you have also create the collector on that message you don't collect the values for 2nd select menu which is sent in a separate message
Sourceae
Sourceae12mo ago
So I should create a second collector inside the first one after creating my second select menu ?
Idris
Idris12mo ago
try something like this yeah