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

449
Visualizações
discord.js bot not responding to commands

I'm following a tutorial on YouTube: how on how to code a Discord bot

(I'm very new to coding and wanted to start somewhere, also I needed a bot).

The code was working fine until I started adding some more commands such as -play and -leave. After that the bot doesn't responds to any commands.

I've tried changing the prefixes, starting from scratch, and just copy-pasting his code to mine. The bot turns online, but its almost like the code that makes him respond isn't there.

Here's my code:

const Discord = require('discord.js');
const client = new Discord.Client({ intents: [] })

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('SaltSounds Is Online!');
});

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


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

if(command === 'ping'){
    message.channel.send('pong!')
    }
});

client.login('my token');
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need these two intents to receive messages: GUILDS, GUILD_MESSAGES. You can implement it like this

const Discord = require('discord.js');
const { Intents } = Discord;
const client = new Discord.Client({ 
  intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] 
})
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