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

80
Views
how dose the bot.on('messageCreate') discord.js work? the bot wont detect a sent message, trying to make a discord chat bot

consts and requirements

require('dotenv').config();
const OpenAI = require('openai-api');

// Load your key from an environment variable or secret management service
// (do not include your key directly in your code)
const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const openai = new OpenAI(OPENAI_API_KEY);  

const Discord = require('discord.js');
const TOKEN = process.env.TOKEN;

const { Client, Intents } = require('discord.js');
const bot = new Discord.Client({ intents: [Intents.FLAGS.GUILDS] });

const prefix = 'w!';

*on ready*
bot.on('ready', async() => {
    console.log(`${bot.user.tag} is online!`);
    bot.user.setActivity('with the code', {type: 'PLAYING'});
});

this is the one being the problem, it won't detect sent messages I've tried a few different ways but nothing, got nothing to do with the server permissions I'm testing on a blank server and node is up to date

bot.on('messageCreate', message => {

    if (message.content === 'ping') {
        message.channel.send('pong');
    }
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

For the messageCreate event to fire you must have the DIRECT_MESSAGES Client intent enabled.

const bot = new Discord.Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.DIRECT_MESSAGES] });

Read more on intents 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!