Skip to content

guildMemberAdd and guildMemberRemove Embeds not sending anymore (Discord.js)

I’m very confused about this because they were once working, but now I don’t even get any error messages. Here’s the code:

(Welcome Embed)

bot.on("guildMemberAdd", (member) => {
    let welcomembed = new Discord.MessageEmbed()
        .setAuthor(`${member.user.tag} just joined!`, member.user.avatarURL())
        .setDescription("Welcome to Angry Birds Economy Server! Don't forget to read the <#748333038294794241>! <:WelcomePigHappy:777683105863041054>")
        .setColor("FF0000");
    member.guild.channels.cache.get("channelid").send(welcomembed)

        .catch((err) => console.log(err));
});

(Goodbye Embed)

bot.on("guildMemberRemove", (member) => {
    let goodbyembed = new Discord.MessageEmbed()
.setAuthor(`${member.user.tag} just left!`, member.user.avatarURL())
.setDescription("Sad! Let's just hope that they enjoyed their stay <:WelcomePigSad:777683637830680586>")
.setColor("FF0000");
member.guild.channels.cache.get("samechannelid").send(goodbyembed)

        .catch((err) => console.log(err));
});

Screenshot of it working: enter image description here

I also have a guildCreate and guildRemove underneath it as well, but I don’t know if that’s the reason why.

Answer

The issue is most likely Discord API’s relatively new intents feature. You need to subscribe to specific intents in order to reliably receive the affiliated events. guildMemberAdd and guildMemberRemove are on the list of events that will require subscription to an intent.

Here’s one possible fix you’ll need to implement wherever you are defining your client:

const intents = ["GUILDS", "GUILD_MEMBERS"];
const bot = new Discord.Client({intents: intents, ws:{intents: intents}});

Note that you must use discord.js v12.x.x to use intents, so if you’re using an older version you’ll need to update to fix your issue.

You will also need to enable the below setting for your bot on its discord developers page, since the guild member join/leave events are a privileged intent: enter image description here

Relevant resources:
List of intents and associated events
General info about intents