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

520
Views
Discord.js Message Collector not working properly, can someone recommend an other way to collect messages or how to make this work?

I made a discord bot using discord.js. This bot should ask questions about a game when someone uses !rank [rank name] and if the user answers correctly he/she receives the rank. I found a way to collect messages, but this method does not want to work, it send the message multiple times and also ignores the time given to the collector, I tried multiple things but neither of them worked, I am very new to creating discord bots so can someone recommend me any other solution to make this bot work?

CODE:

    client.on('messageCreate', message => {
    if (message.content == '!rank r6') {
        message.channel.send('Is Frost an attacker?')
        const collector = new Discord.MessageCollector(message.channel, m => m.author.id == message.author.id, {max: 1, time: 8000})
        collector.on('collect', message => {
                if (message.content == 'no'){
                    message.channel.send('Role added')
                    message.member.roles.add('775660517053562900')
                }
         })
        }     
})

enter image description here

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

0

I'm not sure how you formatted your code to look like that, as the official docs & guide suggest different ways of implementing Collectors. I personally suggest following the guides carefully.

Specifically I see that you try making a new Discord.MessageCollector whereas the guide suggests using a function on message.channel to instate a message collector.

Here are some resources to help you out (assuming you're using Discord.js v12): https://v12.discordjs.guide/popular-topics/collectors.html#message-collectors https://v12.discordjs.guide/additional-info/async-await.html#how-do-promises-work

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!