0

I wanted to make the bot read messages and reply if the message contains a certain string, but every time I try to console.log() the message that the function received as a parameter it was a void string. What is the problem?

This is my code:

const Discord = require("discord.js")
const client = new Discord.Client(
    { intents: ["GUILDS", "GUILD_MEMBERS", "GUILD_MESSAGES"] }
)

client.login("")

client.on("ready", () => {
    console.log("Bot ONLINE");
})

client.on("messageCreate", (message) => {
    console.log(message)
    if( message.content == "the condition"){
        message.channel.send("the message");
    }
})

This is what the VSC terminal shows when i console.log(message)

enter image description here

Jakye
  • 6,440
  • 3
  • 19
  • 38
  • You need the MessageContent intent. – kelsny Feb 10 '23 at 20:58
  • See [Enabling Intents](https://discordjs.guide/popular-topics/intents.html#enabling-intents) in the guide. – kelsny Feb 10 '23 at 20:59
  • I tried and it still doesn't work. Now it also doesn't execute. Terminal gives me that message: Privileged intent provided is not enabled or whitelisted. at WebSocketManager.createShards – SAMUELE BERNARDI Feb 10 '23 at 21:36
  • 1
    It's because you haven't enabled the message content intent on the [developer portal](https://discord.com/developers/applications). – Zsolt Meszaros Feb 10 '23 at 22:46
  • Thanks I solved the problem. It was my mate that forgot to check the message content intent in discord dev dashboard. – SAMUELE BERNARDI Feb 11 '23 at 11:10

0 Answers0