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

11 messages · Page 1 of 1 (latest)

hot breach
#

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 });
            }
        });```
cedar scrollBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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
sour night
#

Pass fetchReply: true to the reply option

hot breach
#

to which one

#

the ones inside the collector?

sour night
#

To your modal submission reply

hot breach
#
const response = await modalSubmission.reply({ embeds: [pollEmbed], components: [row], fetchReply: true });``` like this?
sour night
#

Yes

hot breach
#

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?

sour night
#

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)