#Message Collector Error

1 messages · Page 1 of 1 (latest)

summer apex
#

@supple field I know the slash command listener is working correctly.

#

And the collector.end event listener is too. But nothing is passing through to 'collect'. Do collectors need to be outside of slash commands / other interactions?

supple field
#

No, I use them all the time everywhere.

#

Can you please resend your code here

summer apex
#

I run into the same issue with awaitMessages too

#

Yeah

#
module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Collects messages for 10 sec'),
async execute(interaction) {
    const filter = m => m.content.includes('discord');
    const collector = await interaction.channel.createMessageCollector({ filter, time: 15000 });

    await collector.on('collect', m => {
        console.log(`Collected ${m.content}`);
    });

    await collector.on('end', collected => {
        console.log(`Collected ${collected.size} items`);
    });
    await interaction.reply('collecting...');
    }
#

this is with added awaits before everything in case something was off due to that. But that shouldn't be the case if its just creating the collector

supple field
#

and you get nothing when a message is collected in your on('collect') ?

summer apex
#
const filter = (message) => { return true; };
await interaction.reply({ content: 'Pong!', fetchReply: true })
    .then(interaction.channel.awaitMessages({ filter, time: 10000 })
        .then((collected) => { console.log(collected.size); })
        .catch((err) => { console.log(err); }));

this is another try I made with await messages and I always got collected.size = 0

#

Yea nothing comes through to the console

#

I might just try reinstalling discord.js

supple field
#

can you show me where you initialize your client

#

like, where your flags are

summer apex
#

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

supple field
#

@summer apex you need GUILD_MESSAGES

summer apex
#

cheers. figured it was something i missed, appreciate the help