Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda