0

So I am learning discord.Js and I am trying to figure out why my message.reply function is not working. I created an event for the bot to listen to messages and when a message with the content of "hello" is sent it should reply with "hello buddy" here is the code :

// Require the necessary discord.js classes
    const { Client, GatewayIntentBits } = require('discord.js');
    const { token } = require('./config.json');
    
    // Create a new client instance
    const client = new Client({ intents: [GatewayIntentBits.Guilds] });
    
    // When the client is ready, run this code (only once)
    client.once('ready', () => {
        console.log('The Bot is ready');
    
    
    
    
    });
    
    
    client.on('messageCreate', (message) => {
        if(message.content === 'hello') {
            console.log('hello buddy')
        }
    })
    
    // Login to Discord with your client's token
    client.login(token);
Mido
  • 33
  • 5
  • Does this answer your question? [message.content doesn't have any value in Discord.js v14](https://stackoverflow.com/questions/73036854/message-content-doesnt-have-any-value-in-discord-js-v14) – Zsolt Meszaros Jul 28 '22 at 16:04

1 Answers1

0

You need the GuildMessages intent. Remplace this line :

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

by :

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

PS : I suggest you add the GuildMembers event too

Staxlinou
  • 1,351
  • 1
  • 5
  • 20