Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

discord.js – MessageCollector won't end

The collector won’t end, even if there is time set to 1.

const filter = msg => msg.author.id === message.author.id;

const collector = new MessageCollector(message.channel, filter, {
    max: 3,
    time: 5000,
})

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

collector.on('end', collected => {
    console.log(`${collected.size}`)
})

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The constructor takes arguments (channel, options) and not (channel, filter, options). filter should be part of the options object. See docs.

Right now you are passing the filter function instead of an options object, followed by what should be an options object but is actually just an ignored superfluous third argument.

This is the correct way:

const collector = new MessageCollector(message.channel, {
    filter,
    max: 3,
    time: 5000
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading