Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

526
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda