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

Discord.js bot not replying

I just started learning how to build a bot in JavaScript and I don’t understand why my bot isn’t replying to my message.
It has the Administrator role and it should be reading the message in chat.
What seems to be the problem here?

Thank you

const { GatewayIntentBits } = require("discord.js")
const Discord = require("discord.js")

const TOKEN = "..."

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

client.on("ready", () => {
    console.log(`Logged in as ${client.user.tag}`)
})

client.on("messageCreate", (message) => {
    if (message.content == "sup"){
        message.reply("Hello World!")
    }
})

client.login(TOKEN)

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

>Solution :

Discord.js v14

You need the MessageContent intent as well.

{
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent ]
}

If after this you get an error saying

Privileged intent provided is not enabled or whitelisted

Than you have to follow these steps :

Step 1
Step 2
Step 3

Make sure to not forget the last button as it is the most important of all 3.

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