I was trying to do a simple command using the clasic message event (now messageCreate event), so I programed a small code to test if the event is working righfully:
const Discord = require('discord.js')
const { Client, Intents, Message, MessageEmbed} = require('discord.js');
const { token, prefix } = require('./config.json')
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.once('ready', () => {
console.log(`${client.user.username} Se Ha Conectado Correctamente`)
})
client.on('messageCreate', (message) => {
console.log('Un Mensaje! :D');
console.log(message);
})
client.on('interactionCreate', interaction => {
console.log(interaction);
})
client.login(token);
But when I send the messages at the guild where I am testing the bot, he can't detect them for some reason.
as extra data, the console.log of the ready event works perfectly.
Fixes testings
Maybe permissions? It already have administrator but I moved the role to the top for testing, nothing happened.
Maybe add the GUILD_MESSAGES intent on the client? I also tried this one but the bot still can't detect the messages
Discord.js version: v13.3.1
Node.js version: v17.0.1
Like Worthly Alpaca has mentioned in the comments, it is required to use the GUILD_MESSAGES intent in order to be able to receive the messages. Your client will now look like:
const client = new Client({intents: [Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILDS]});
Please note that you now have to enable the GUILD_MESSAGES intent on the page of your Discord application.