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

360
Views
TypeError: asíncrono no es una función

Estoy haciendo un controlador de comando de barra inclinada usando discord.js, y recibo el error "no es una función". Vi otras preguntas aquí y algunos videos en YouTube pero aún no pude resolver el problema

este es el codigo

 client.on('interactionCreate', async (interaction => { if (!interaction.isCommand()) return const command = client.commands.get(interaction.commandName) if (!command) return }))

y este es el error

 client.on('interactionCreate', async (interaction => { ^ TypeError: async is not a function at Object.<anonymous> (C:\Users\...\Desktop\...\...\...\index.js:60:32) at Module._compile (node:internal/modules/cjs/loader:1103:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47

Lo he intentado: npm i async y var async = require('async')

Antes de crear la variable, el error era que async no estaba definido, pero ahora muestra este nuevo error

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

0

Perdiste un ")"

 client.on("interactionCreate", async (interaction) => { if (!interaction.isCommand()) return; const command = client.commands.get(interaction.commandName); if (!command) return; });
about 4 years ago · Juan Pablo Isaza Report

0

Estás llamando a client.on('interactionCreate', f ) donde f se representa como:

 async (interaction => { if (!interaction.isCommand()) return const command = client.commands.get(interaction.commandName) if (!command) return })

JavaScript está interpretando esto como async( ... ) .

Puede eliminar los paréntesis que rodean su función o mover los paréntesis de cierre al final de los argumentos de su función de flecha.

 client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return const command = client.commands.get(interaction.commandName) if (!command) return })

O

 client.on('interactionCreate', async (interaction) => { if (!interaction.isCommand()) return const command = client.commands.get(interaction.commandName) if (!command) return })
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!