Select Menu Collector

Having some trouble with my collector, per usual since last time I did it took me forever as well. Just threw this together looking through some docs, tutorials, and stackoverflow. The menu pops up and my options are correct but my collector just never collects. Discord.js Version 14.14.1, node version 18.16.0, here's my code:
menuSelect: async function(interaction, results){
const menu = new Discord.StringSelectMenuBuilder().setCustomId("menu").setPlaceholder('Make a selection!');
const options = [];

for(result of results){
options.push(new Discord.StringSelectMenuOptionBuilder().setLabel(result.name).setDescription('placeholder').setValue(result.name));
}
menu.setOptions(...options);

const row = new Discord.ActionRowBuilder().addComponents(menu);
const response = await interaction.reply({ content: 'Choose your card!', components: [row], ephemeral: true });
const collector = response.createMessageComponentCollector({
componentType: Discord.ComponentType.StringSelect,
filter: (i) => i.user.id === interaction.user.id && i.customId === interaction.id,
time: 10000, //10 seconds,
fetchReply: true
});

collector.on('collect', (interaction) => {
console.log("here!")
interaction.reply('yeet');
})
},
menuSelect: async function(interaction, results){
const menu = new Discord.StringSelectMenuBuilder().setCustomId("menu").setPlaceholder('Make a selection!');
const options = [];

for(result of results){
options.push(new Discord.StringSelectMenuOptionBuilder().setLabel(result.name).setDescription('placeholder').setValue(result.name));
}
menu.setOptions(...options);

const row = new Discord.ActionRowBuilder().addComponents(menu);
const response = await interaction.reply({ content: 'Choose your card!', components: [row], ephemeral: true });
const collector = response.createMessageComponentCollector({
componentType: Discord.ComponentType.StringSelect,
filter: (i) => i.user.id === interaction.user.id && i.customId === interaction.id,
time: 10000, //10 seconds,
fetchReply: true
});

collector.on('collect', (interaction) => {
console.log("here!")
interaction.reply('yeet');
})
},
10 Replies
d.js toolkit
d.js toolkit12mo 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
OwlShogunate
OwlShogunateOP12mo ago
my immediate guess is my filter is wrong, probably the latter half. but not sure how to check the interaction id correctly
duck
duck12mo ago
without specifying fetchReply: true in your reply options, reply resolves in an InteractionResponse currently there's a few issues with collectors created from InteractionResponses, including collecting from ephemeral messages therefore you'd want to specify fetchReply: true so that it resolves in a Message instead
OwlShogunate
OwlShogunateOP12mo ago
interesting, well i added that flag at least. still no dice it seems though
duck
duck12mo ago
Though you are correct here Your menu's custom id is menu, not the interaction id
OwlShogunate
OwlShogunateOP12mo ago
any idea if I can retrieve the custom id from the interaction? also, i assume just hard coding the menu ID like that doesn't really help the custom id at all? cuz they'll all just have the same custom ID
duck
duck12mo ago
<ComponentInteraction>.customId would be the custom id of the component that was interacted with That being said, it doesn't really matter what or how your custom id is set if you only intend to utilize components once You also aren't required to filter by custom id at all at that point
OwlShogunate
OwlShogunateOP12mo ago
i found where to grab it from the response after some digging, and that was my thought as well but what about the edge case where a use has 2 menus open at once? then the filters will catch the others. obviously that shouldn't happen. but it could i suppose
duck
duck12mo ago
Creating a collector from a message will only listen for interactions from that message
OwlShogunate
OwlShogunateOP12mo ago
hmmmm welp yea i'm overthinking it lol thanks for the help
Want results from more Discord servers?
Add your server