Bot not responding to ping command in Discord.js v14

I’m working on a Discord bot using discord.js version 14.13.0 and having trouble with message responses. The bot should send “pong” when someone types “ping” but it’s not working at all.

Here’s my current code:

const { Client, Events, GatewayIntentBits } = require('discord.js');
const { botToken } = require('./settings.json');

const bot = new Client({ 
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] 
});

bot.once(Events.ClientReady, readyClient => {
    console.log(`Bot is online! Logged in as ${readyClient.user.tag}`);
});

bot.on('messageCreate', msg => {
    if (msg.content === 'ping') {
        msg.reply('pong');
    }
});

bot.on('error', console.error);

bot.login(botToken);

I’ve already given the bot administrator permissions in my server so permissions shouldn’t be the issue. When I type “ping” in chat nothing happens. The bot shows as online but just won’t respond to messages. What could be causing this problem?

hey, looks like you’re missing the MessageContent intent. you gotta add GatewayIntentBits.MessageContent to your intents, then your bot should start replying to ‘ping’ properly!

The issue is definitely related to privileged intents. Discord changed their API requirements and now bots need explicit permission to read message content. You’ll need to enable the Message Content Intent in your Discord Developer Portal under the Bot section, then add GatewayIntentBits.MessageContent to your client intents array. Without this intent, your bot can see that messages are sent but cannot access the actual content, which explains why the messageCreate event isn’t triggering your ping command. Make sure to save the changes in the developer portal and restart your bot after updating the code.

Had this exact same issue when I migrated from v13 to v14 last year. The problem is that Discord requires the Message Content Intent to be enabled in two places now. First, go to your application in the Discord Developer Portal and toggle on the “Message Content Intent” under the Bot section. Second, add GatewayIntentBits.MessageContent to your intents array in the code. Your intents should look like this: intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]. This change was implemented to give users more privacy control over what bots can access. After making both changes, restart your bot completely and it should work.