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

87
Vistas
Discord.js messageCollector bug?

i have a problem with the messageCollector

const msgFilter = (msg) => msg.author.id == message.author.id;
      const collector = message.channel.createMessageCollector(msgFilter);
      collector.on("collect", (msg) => {
        
        Health = 100

        if(msg.content === "punch") {
           Health -= 10 
        }
        console.log(Health)

when i type punch the result is 90 but when i type punch again the result is also 90, but it should be 80 I don't have this problem if i create the variable Health outside the messageCollector, but for my usage it must be inside of the messageCollector how can i make it, that every time i type punch 10 get removed?

It must be messagecollector and no other function, because it has to repeat every code inside the messagecollector

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

A message collector doesn't take an argument of a filter; it takes an argument of MessageCollectorOptions, which includes the filter. You would have to do something like this:

 const collector = message.channel.createMessageCollector({
      filter: msgFilter
 });
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