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

319
Vistas
DiscordBot online but doesn't respond to command (js)

I have no experience with dc bots so I followed a yt tutorial but discord.js he used was an older version (v12) so I fixed the code for my version v14. The Bot goes online but when I type a command it won't respond. There are no errors it just goes online and gives the console message that's it. Maybe it's because of the version but I can't find any answers for this version. (Maybe it's something else as I said I've never done that before) This is my main.js:


const { Client, GatewayIntentBits } = require('discord.js');

const client = new Discord.Client({
    intents: [
      GatewayIntentBits.Guilds,
      GatewayIntentBits.GuildMessages,
    ]
  })

  const prefix ='!';

  const fs = require('fs');
  client.commands = new Discord.Collection();

  const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
  for (const file of commandFiles){
    const command = require(`./commands/${file}`);

    client.commands.set(command.name, command);
  };

client.once('ready', () => {
    console.log('Bot is online!');
});


client.on('message', message =>{
  console.log("1")
    if(!message.content.startsWith(prefix) || message.author.bot) return;
    console.log("2")

    const args = message.content.slice(prefix.length).split(/ +/);
    const command = args.shift().toLowerCase();

    if(command === 'ping'){
        client.commands.get('ping').execute(message, args);
    }
});

client.login('TOKEN');

The console.log() 1 and 2 are to check if it works but it won't show in the console just the "Bot is online". Then I have a folder /commands with ping.js:

module.exports = {
    name: 'ping',
    description: "this is a ping command!",
    execute(message, args){
        message.channel.send('pong!')
    }
}
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You should request the message content intent. See how:

const { Client, GatewayIntentBits } = require('discord.js');

const client = new Discord.Client({
    intents: [
      GatewayIntentBits.Guilds,
      GatewayIntentBits.GuildMessages,
      GatewayIntentBits.MessageContent
    ]
  })

Note that you may also need to enable it in the Discord Developer Portal: enter image description here

about 4 years ago · Santiago Trujillo 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