Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
Message collector in Discord.JS not running

I have a basic command for testing the message collector feature on my discord.js v13 bot.

The bot doesn't crash when I run it, but the feature doesn't load properly, as it has an error.

import { ICommand } from 'wokcommands'
import { Message } from 'discord.js'

export default {
    category: 'Testing',
    description: 'Tests the collector system',
    hidden: true,

    callback: ({ message, channel }) => {
        message.reply('Answer your username')

        const filter = (m: Message) => {
            m.author.id === message.author.id
        }

        const collector = channel.createMessageCollector({
            filter,
            max: 1,
            time: 1000 * 10,
        })

        collector.on('collect', message => {
            console.log(message.content)
        })
        
        collector.on('end', collected => {
            if (collected.size === 0) {
                message.reply('You did not provide your username')
                return
            }

            let text = 'Collected:\n\n'

            collected.forEach((message) => {
                text += `${message.content}\n`
            })

            message.reply(text)
        })
    }
} as ICommand

The error is in the line inside the collector function when I call filter. The IDE gives me an error:

Type '(m: Message) => void' is not assignable to type 'CollectorFilter<[Message]>'. Type 'void' is not assignable to type 'boolean | Promise'.

I understand what the error is trying to say, but how can I fix it?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your filter needs to return a boolean. At the moment you don't return anything, you just compare the two variables. Any of these will work:

const filter = (m: Message) => {
  return m.author.id === message.author.id
}
const filter = (m: Message) => m.author.id === message.author.id
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!