0

This is my code, seems nothing wrong with it but when i send "hello", it doesnt send one back (expected for it to say "hi" back) It doesnt give any error or anything, just doesn't work

const { Client, GatewayIntentBits } = require("discord.js");

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

client.on("ready", () => {
    console.log(`${client.user.tag} is online, ready for action! (Ping: ${Math.round(client.ws.ping)}ms)`)
});

//main code
client.on("messageCreate", (message) => {
    if (message.content === "hello") {
        message.reply("hi")
    }
})

client.login(token)

I expected it to reply to my message with hi in Discord but it doesn't, instead, it did nothing. I tried double equal but still doesn't work.

Michael M.
  • 10,486
  • 9
  • 18
  • 34
RavesDiary
  • 26
  • 3

1 Answers1

1

I think that is due to your intentions not being set properly. You are trying to access a message's content, but don't have the intent. You can fix this by adding it like this.

const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
    ]
});
Samy Rahmani
  • 320
  • 1
  • 7