Collector.on('collect') not collecting for createMessageComponentCollector.

I'm having trouble figuring out why my bot wont fire on Collector.on('collect'). I tried putting a console.log('test') in there but it's never registering. Any idea how to fix this?
const response = await modalSubmission.reply({ embeds: [pollEmbed], components: [row] });

const collector = response.createMessageComponentCollector({ componentType: ComponentType.Button, time: 15_000 });

collector.on('collect', i => {
if (i.user.id === interaction.user.id) {
i.reply(`${i.user.id} clicked on the ${i.customId} button.`);
} else {
i.reply({ content: `These buttons aren't for you!`, ephemeral: true });
}
});
const response = await modalSubmission.reply({ embeds: [pollEmbed], components: [row] });

const collector = response.createMessageComponentCollector({ componentType: ComponentType.Button, time: 15_000 });

collector.on('collect', i => {
if (i.user.id === interaction.user.id) {
i.reply(`${i.user.id} clicked on the ${i.customId} button.`);
} else {
i.reply({ content: `These buttons aren't for you!`, ephemeral: true });
}
});
9 Replies
d.js toolkit
d.js toolkit9mo 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
NyR
NyR9mo ago
Pass fetchReply: true to the reply option
Penitent
PenitentOP9mo ago
to which one the ones inside the collector?
NyR
NyR9mo ago
To your modal submission reply
Penitent
PenitentOP9mo ago
const response = await modalSubmission.reply({ embeds: [pollEmbed], components: [row], fetchReply: true });
const response = await modalSubmission.reply({ embeds: [pollEmbed], components: [row], fetchReply: true });
like this?
NyR
NyR9mo ago
Yes
Penitent
PenitentOP9mo ago
ahhhh that fixed it! thank you so much! can I ask why it's necessary to have fetchReply there? what does fetchReply do exactly? and would this have been necessary had it not been a modal?
NyR
NyR9mo ago
Because the promise returns InteractionResponse which is slightly different than a Message, fetchReply makes sure it returns a message, although it should also create a collector on the InteractionResponse (since there is a method in it too), i think that's an issue that needs fixing (I'm not too sure about this)
Penitent
PenitentOP9mo ago
ahhh I understand, thank you so much for the help!
Want results from more Discord servers?
Add your server