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

70
Views
Tengo este código a continuación. Quiero que el contador se restablezca a 0 después de enviar el mensaje.
let msgCount = 0; // This being outside the event in index.js // Event here client.on("messageCreate", async(message)=>{ if (message.author.bot) return; if (message.channel.id === "id here") { msgCount = msgCount + 1; } if (msgCount === 100) { const channel = await client.channels.cache.get("id here") channel.send("hi") } })

Pero solo envía el mensaje 1 vez y no restablece el contador a 0, por lo que solo funciona 1 vez, ¿cómo puedo solucionarlo?

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

0

Puede esperar a que se envíe el mensaje y luego establecer la variable msgCount en 0 .

 let msgCount = 0; // This being outside the event in index.js // Event here client.on("messageCreate", async (message) => { if (message.author.bot) return; if (message.channel.id === "id here") { msgCount = msgCount + 1; } if (msgCount === 100) { const channel = await client.channels.cache.get("id here") await channel.send("hi") msgCount = 0 } })
about 4 years ago · Juan Pablo Isaza Report

0

Nunca lo reinicias... solo lo incrementas. Simplemente use esto y lo cambiará nuevamente a 0 cuando se envíe el mensaje

 if (msgCount === 100) { const channel = await client.channels.cache.get("id here") channel.send("hi") msgCount = 0 }
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!