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

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

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 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