Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

355
Vistas
TypeError: async is not a function

I'm doing a slash command handler using discord.js, and I'm getting the "not a function" error. I saw other questions here and some videos on YouTube but I still couldn't solve the problem

This is the code

client.on('interactionCreate', async (interaction => {
    if (!interaction.isCommand()) return

    const command = client.commands.get(interaction.commandName)

    if (!command) return
}))

And this is the 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

I have tried: npm i async and var async = require('async')

Before I created the variable the error was that async was not defined but now it shows this new error

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You misplaced a ")"

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 Denunciar

0

You are calling client.on('interactionCreate', f ) where f is represented as:

async (interaction => {
    if (!interaction.isCommand()) return

    const command = client.commands.get(interaction.commandName)

    if (!command) return
})

JavaScript is interpreting this as async( ... ).

You can either remove the parentheses surrounding your function, or move the closing parentheses to the end of the arguments of your arrow function.

client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return

    const command = client.commands.get(interaction.commandName)

    if (!command) return
})

OR

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda