Why isn't messageCreate getting triggered?

import { Client, GatewayIntentBits, Partials } from 'discord.js';
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});


client.once('ready', async c => {
console.log('bot is logged in');
});

client.on('messageCreate', async message => {
console.log('message received:', message.content);
});

client.login(process.env.DISCORD_BOT_TOKEN);

export default client;
import { Client, GatewayIntentBits, Partials } from 'discord.js';
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});


client.once('ready', async c => {
console.log('bot is logged in');
});

client.on('messageCreate', async message => {
console.log('message received:', message.content);
});

client.login(process.env.DISCORD_BOT_TOKEN);

export default client;
the on ready is getting logged, but when i send messages, there's no response. why not?
7 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
skeddles
skeddlesOP11mo ago
[email protected] node v16.17.0
xx_lavaboy_xx123
xx_lavaboy_xx12311mo ago
do u send the messages in dms?
skeddles
skeddlesOP11mo ago
no, in a channel
Kevinnnn
Kevinnnn11mo ago
I'm not able to recreate this, does the bot have access to view messages for the channel you're trying to send something in?
skeddles
skeddlesOP11mo ago
ah crap, I figured it out, i was using the wrong token so it was in different servers than i expected. the code is working as expected. i should have done client.guilds.cache.forEach(guild => {console.log('bot joined server:', guild.name);}); thanks for being my rubber duckies
Kevinnnn
Kevinnnn11mo ago
mmLol
Want results from more Discord servers?
Add your server