V13 Discord.JS Bot is not sending messages

This’s my code below, I have tried enabling Intents from developer portal, and I’ve checked the channel permissions, and my node version is running on v16.14.2, and still it doesnt send any messages for some reason.

 const { Client, Intents } = require('discord.js');
        const { token } = require('./config.json');
        
        const client = new Client({
            intents: [
                Intents.FLAGS.GUILDS,
                Intents.FLAGS.GUILD_MEMBERS,
                Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
                Intents.FLAGS.GUILD_MESSAGES
            ]
        })
        client.on('ready', () => {
           console.log("Ready");
        })
        
        client.on('messageCreate', (message) => {
            if (message === 'ping') {
                message.reply({
                    content: 'pong',
                })
            }
        });
        
        client.login(token);

>Solution :

You are comparing an object with a string, the error is in your if() statement:

if(message.content=='ping'){
    message.reply('pong')
}

Leave a Reply