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

191
Views
ERR_INVALID_ARG_TYPE en Discord.js

Así que estoy creando un bot en Discord.js y mi salida es un tipo de argumento no válido. Aquí está mi código.

 const { Client, Intents } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }); client.on("ready", () => { console.log(`Logged in as ${client.user.tag}!`) }) client.on(() => { if (msg.content === "!test") { msg.reply("Hello world!"); } if (msg.content === "!purgec") { message.guild.channels.forEach(channel => channel.delete()) msg.reply("Deleting all channels..."); } }) client.login('token')

Mi salida en la consola termina siendo:

 TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined ←[90m at checkListener (node:events:128:3)←[39m ←[90m at _addListener (node:events:423:3)←[39m ←[90m at Client.addListener (node:events:487:10)←[39m at Object.<anonymous> (C:\Users\zen\Desktop\bot\main.js:8:8) ←[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)←[39m ←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)←[39m ←[90m at Module.load (node:internal/modules/cjs/loader:981:32)←[39m ←[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m ←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)←[39m ←[90m at node:internal/main/run_main_module:17:47←[39m { code: ←[32m'ERR_INVALID_ARG_TYPE'←[39m }

¿Alguien puede ayudarme?

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

0

No está escuchando el evento correctamente. Primero, pones el nombre del evento, luego la devolución de llamada. Haz esto en su lugar:

 client.on("messageCreate", (msg) => { if (msg.content === "!test") { msg.reply("Hello world!"); } if (msg.content === "!purgec") { message.guild.channels.forEach(channel => channel.delete()) msg.reply("Deleting all channels..."); } })
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!