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

243
Views
Discord bot not responding Node.js V16.5

I tried all the tutorials, but my bot just does not respond to my commands in a Discord chat

Index.js

const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');


const rest = new REST({ version: '9' }).setToken('[bot token]');

(async () => {
  try {
    console.log('Started refreshing application (/) commands.');

    await rest.put(
      Routes.applicationGuildCommands([clinent id], [guild id]),
      { body: commands },
    );

    console.log('Successfully reloaded application (/) commands.');
  } catch (error) {
    console.error(error);
  }
})();

bot.js

const { DiscordAPIError } = require('@discordjs/rest');
const { Client, Intents } = require('discord.js');
const Discord = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const token = 'token';
const prefix = '!';

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  console.log(``);
});

client.on('messageCreate', (message) => {
    if(message.content.toLowerCase().includes('hey bot') || message.content.toLowerCase().includes('general kenobi')){
        message.channel.send('Hello there!');
    }
});

client.on('messageCreate', (message) => {
    if(message.content.toLowerCase().includes('fudge') || message.content.toLowerCase().includes('pudding')){
        message.channel.send('Such language is prohibited!');
    }
});

client.login(token);

When I type any of the commands, the Discord bot just stays silent. I added bot.js as main in package.json.

I get no errors in the console.

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

0

Those intents cover only operations with guild, not messages if I'm not wrong. You need GUILD_MESSAGES, and maybe even DIRECT_MESSAGES intent as well.

https://discord.com/developers/docs/topics/gateway#list-of-intents

about 4 years ago · Juan Pablo Isaza Report

0

I find the cause. Apparently i had to check all the permissions my bot needed from developers section in discord. No tutorial showed that. And after that, I put more intents: Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES

enter image description here

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!