Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

88
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda