Reputation: 45
I am currently developing a discord bot and was just testing it out to make sure it works only to find that it does no read message content. Whenever a user types a message in my server it returns an empty string and not whatever the user typed.
I am using discord.js 14.3.0 with NodeJS. I have all privilege intents enabled on my bot page aswell as making sure to have all the intents included in the client declaration in my code.
My Code:
import {Client, GatewayIntentBits} from 'discord.js';
const token = "token"
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.GuildVoiceStates
]
})
client.login(token);
client.on('ready', () => {
console.log(`Ready and logged on as ${client.user.tag}`);
});
client.on('messageCreate', message => {
console.log(message)
});
I tried to print the message object to try to see what the content was and it always turned out the content would equals an empty string no matter who sent the message, or when. I have no clue why this is happening and would appreciate any help.
Upvotes: 0
Views: 1421
Reputation: 11
Go to https://discord.com/developers, select your application and go to bot section then open "MESSAGE CONTENT INTENT" from Privileged Gateway Intents.
If your bot is in 100 or more than 100 guilds, you need to apply for it. If not, you can open it directly.
Edit: You need to add the required partials and intents to your client. https://discordjs.guide/popular-topics/partials.html#partial-structures https://discordjs.guide/popular-topics/intents.html#gateway-intents
Upvotes: 1