Receiving non slash command messages

I'm trying to receive regular guild messages that aren't slash commands. I'm aware of the privacy issues, it's just a private bot for my friends and I running a local AI model for fun. I used to use discord.js but it's obviously changed a lot over the years e.g. slash commands and I can't figure out receiving messages without a slash command. I've enabled all privileged gateway intents on the discord dev dashboard and here is my code.
import { Client, Events, GatewayIntentBits } from 'discord.js';
import 'dotenv/config';

const client = new Client({
verbose: true,
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessagePolls,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.DirectMessages
]
});

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

client.on(Events.MessageCreate, async (message) => {
console.log(message);
});

client.on(Events.InteractionCreate, async (interaction) => {
console.log(interaction);
});

client.login(process.env.TOKEN);
import { Client, Events, GatewayIntentBits } from 'discord.js';
import 'dotenv/config';

const client = new Client({
verbose: true,
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessagePolls,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.DirectMessages
]
});

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

client.on(Events.MessageCreate, async (message) => {
console.log(message);
});

client.on(Events.InteractionCreate, async (interaction) => {
console.log(interaction);
});

client.login(process.env.TOKEN);
Nothing is being logged when I send messages in the testing server (which the bot is in with full permissions).
3 Replies
d.js toolkit
d.js toolkit3w ago
TheeJoshhh
TheeJoshhhOP3w ago
discord.js@14.21.0 node v24.5.0 I figured it out. I was missing the GuildMessages intent lol. Closing the issue.
d.js toolkit
d.js toolkit3w ago
The thread owner has marked this issue as solved.

Did you find this page helpful?