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 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.
</> Idris
</> Idris2y ago
where are you creating the collector for the 2nd select menu?
Sourceae
SourceaeOP2y 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
</> Idris2y ago
you're creating the collector on a message where there's just the 1st select menu
Sourceae
SourceaeOP2y 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
</> Idris2y 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
SourceaeOP2y ago
So I should create a second collector inside the first one after creating my second select menu ?
</> Idris
</> Idris2y ago
try something like this yeah
Want results from more Discord servers?
Add your server