DiscordJS V 14 Not able to receive data for MessageCreate

const { Client, GatewayIntentBits, Message } = require('discord.js');
const { token } = require('./config.json');

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

client.on("ready", function(){
console.log(`the client becomes ready to start`);
console.log(`I am ready! Logged in as ${client.user.tag}!`);
});

client.on("messageCreate", function(message){
console.log(`a message was created`);
console.log({message});
});


client.login(token);
const { Client, GatewayIntentBits, Message } = require('discord.js');
const { token } = require('./config.json');

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

client.on("ready", function(){
console.log(`the client becomes ready to start`);
console.log(`I am ready! Logged in as ${client.user.tag}!`);
});

client.on("messageCreate", function(message){
console.log(`a message was created`);
console.log({message});
});


client.login(token);
I am able to get any other event but anything that has to do with messages just won't work.
18 Replies
Percy
Percy•6mo ago
Project ID: N/A
𖥂 PixelFire 𖥂
N/A I've tried to use Events.MessageCreate and other ways but nothing works and yes I enabled intents in the discord Developer Portal.
Attacler/Bart
Attacler/Bart•6mo ago
GitHub
discord.js/packages/discord.js/src/client/actions/MessageCreate.js ...
A powerful JavaScript library for interacting with the Discord API - discordjs/discord.js
𖥂 PixelFire 𖥂
The problem is I was originally using discord's example code. And I simplified it as much as possible too.
Attacler/Bart
Attacler/Bart•6mo ago
what was the original example code?
𖥂 PixelFire 𖥂
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);
And then I added the Events.MessageCreate which is refrenced somewhere else. that didn't work so I switched over from the Events of Discord.JS
lasse
lasse•6mo ago
@PixelZero You need GatewayIntentBits.GuildMessages
𖥂 PixelFire 𖥂
I had that earlier but let me try again.
lasse
lasse•6mo ago
MessageContent GuildMessages ... are required
𖥂 PixelFire 𖥂
oh yeah the code snippit has it at the top the first one
lasse
lasse•6mo ago
Does it work? :D
lasse
lasse•6mo ago
Hmm wierd
lasse
lasse•6mo ago
Try ask in the discord.js server.
𖥂 PixelFire 𖥂
okay the discord developers?
lasse
lasse•6mo ago
No .gg/djs
Want results from more Discord servers?
Add your server