Home > Blockchain >  discord.js - MessageCollector won't end
discord.js - MessageCollector won't end

Time:12-20

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}`)
})

CodePudding user response:

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
})
  • Related