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