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

188
Vistas
ERR_INVALID_ARG_TYPE on Discord.js

So I'm making a bot in Discord.js and my output is an invalid argument type. Here is my code.

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')

My output in the console ends up being:

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
}

Can anyone help me?

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

0

You are not listening to the event properly. First, you put the event name, then the callback. Do this instead:

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 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