icannotunsee
icannotunsee

Reputation: 25

guildMemberAdd event not working even with intents enabled. (discord.js)

I'm trying to set up a welcome message function on my discord bot, but no matter what I do, the bot doesn't seem to be able to use guildMemberAdd. I'm aware of the new update, and as suggested I've turned on both options under Private Giveaway Intents. But it still does not work. Here is my code:

client.on('guildMemberAdd', member => {
    const emb = new MessageEmbed()
          .setColor('#FFBCC9')
          .setTitle("new member")
          .setDescription("welcome to the server!")
    member.guild.channels.get('780902470657376298').send(emb);
});

I have also found an answer online suggesting to use this:

const { Client, Intents } = require("discord.js");

const client = new Discord.Client({ ws: { intents: new Discord.Intents(Discord.Intents.ALL) }});

But no matter how I write that, my bot just won't even come online unless I use const client = new Discord.Client(); with nothing in the parentheses.

Upvotes: 0

Views: 1139

Answers (2)

Mafia7777
Mafia7777

Reputation: 11

You passed in the intents params wrong. Here is the correct way to do it.


const { Client, Intents } = require("discord.js");

const client = new Discord.Client({ ws: { intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MEMBERS', 'GUILD_PRESENCES'] } });

If you use this the guildMemberAdd event will emit.

Make sure you have intents turned on in the developer portal. As Shown in this image https://i.sstatic.net/MDdxT.png.

Upvotes: 1

Itamar S
Itamar S

Reputation: 1565

With v12 coming along, in order to get your full channels list you're only able to get the cached ones in your server. Hence why you should change this line:

member.guild.channels.get('780902470657376298').send(emb);

to:

member.guild.channels.cache.get('780902470657376298').send(emb);

Upvotes: 2

Related Questions