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

86
Views
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 answers
Answer question

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 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!