Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading