message.content doesn’t have any value in Discord.js

Make sure you enable the message content intent on your developer portal and add the GatewayIntentBits.MessageContent enum to your intents array. Applications ↦ Settings ↦ Bot ↦ Privileged Gateway Intents You’ll also need to add the MessageContent intent: const client = new Client({ intents: [ GatewayIntentBits.DirectMessages, GatewayIntentBits.Guilds, GatewayIntentBits.GuildBans, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, ], partials: [Partials.Channel], }); If … Read more

message.content doesn’t have any value in Discord.js v14

Make sure you enable the message content intent on your developer portal and add the GatewayIntentBits.MessageContent enum to your intents array. Applications ↦ Settings ↦ Bot ↦ Privileged Gateway Intents You’ll also need to add the MessageContent intent: const client = new Client({ intents: [ GatewayIntentBits.DirectMessages, GatewayIntentBits.Guilds, GatewayIntentBits.GuildBans, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, ], partials: [Partials.Channel], });

Error [ERR_REQUIRE_ESM]: require() of ES Module not supported [duplicate]

The node-fetch latest version doesn’t use the require() syntax to import the package. You need to go to your package.json and type { “type”: “module”, } to use the import syntax and import node-fetch, but then you can’t use require for any other packages. You need to work with import statement only. Or you can … Read more

Discord API valid intents must be provided for the client [duplicate]

First of all, never show a token of your bot, or try to change it later. Second of all: Try using this. Since the new updated version of discord.js, like version ^13.0, you have to specify client intents: const { Client, Intents } = require(‘discord.js’); const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }); And … Read more

Find out if someone has a role

The discord.js api has been updated and there is a better way since .exists() has been deprecated. if (message.member.roles.cache.some(role => role.name === ‘Whatever’)) {} This is better than .find() because .find() returns the role object (or undefined) which is then converted into a boolean. The .some() method returns a boolean by default.

Discord.js Bot Welcomes Member, Assign a Role and send them a DM

Your code looks fine, the problem is that the event isn’t triggered. Thats because discord turned off “privileged intents” by default. Some intents are defined as “Privileged” due to the sensitive nature of the data. Those intents are: GUILD_PRESENCES GUILD_MEMBERS One effect of that is what you are experiencing, the not working guildMemberAdd event. The … Read more

How do I use a local image on a discord.js rich embed?

Updated Luke’s code to Discord.js v12 for anyone else in 2020 who has this same problem const attachment = new Discord .MessageAttachment(‘./card_images/sample.png’, ‘sample.png’); const embed = new Discord.MessageEmbed() .setTitle(‘Wicked Sweet Title’) .attachFiles(attachment) .setImage(‘attachment://sample.png’); message.channel.send({embed});