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

296
Views
SyntaxError: await solo es válido en funciones asíncronas y los cuerpos de nivel superior de los módulos. Discordia, js

Error:

SyntaxError: await solo es válido en funciones asíncronas y los cuerpos de módulos de nivel superior

[Error de foto] https://i.stack.imgur.com/a0hWM.png

 const client = require('../index.js'); client.on('ready', () => { let servers = await client.guilds.cache.size let servercount = await client.guilds.cache.reduce((a,b) => a+b.memberCount, 0) const activites = [ `?help | ${servers} servers`, `Invite me now! | Watching ${servercount} members` ] setInterval(()=>{ const status = activities[Math.floor(Math.random()*activities.length)] client.user.setPresence({ activities : [{name : `${status}`}]}) }, 5000) console.log(`✅ ${client.user.tag} is ready`) })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar await solo con funciones asíncronas. Consulte el siguiente código donde he cambiado su función de devolución de llamada client.on a asíncrona.

 const client = require('../index.js'); client.on('ready', async() => { let servers = await client.guilds.cache.size let servercount = await client.guilds.cache.reduce((a,b) => a+b.memberCount, 0) const activites = [ `?help | ${servers} servers`, `Invite me now! | Watching ${servercount} members` ] setInterval(()=>{ const status = activities[Math.floor(Math.random()*activities.length)] client.user.setPresence({ activities : [{name : `${status}`}]}) }, 5000) console.log(`✅ ${client.user.tag} is ready`) })

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!