1

I'm currently making a discord bot using a node.js and I found a problem when I make welcome message.

This is the code :

client.on("guildMemberAdd", async member => {
    let chx = db.get(`welchannel_${member.guild.id}`);
    if (chx === null)
        return;
    let data = await canva.welcome(member, { link: "https://i.pinimg.com/originals/f3/1c/39/f31c39d56512dc8fbf30f9d0fb3ee9d3.jpg" })

    const attachment = new discord.MessageAttachment(data, "welcome-image.png");

  client.channels.cache.get(chx).send("Welcome to our Server " + member.user.username, attachment);
});

If I run them, nothing happens when a member joins the server.

Ruli
  • 2,592
  • 12
  • 30
  • 40
Sinomaru
  • 19
  • 1
  • See [this answer](https://stackoverflow.com/questions/64559390/none-of-my-discord-js-guildmember-events-are-emitting-my-user-caches-are-basica/64559391#64559391) to learn more about privileged intents – Tyler2P Jun 20 '21 at 13:13
  • No errors either? – D J Jun 27 '21 at 11:03

2 Answers2

1

Go to https://discord.com/developers/applications and select your application go to the bot tab and scroll down to Privileged Gateway Intents and enable Server Members Intent, that should fix your problem

Patriot
  • 45
  • 1
  • 1
  • 7
1

To add to what @Patriot said about setting up your bot registration with Discord, You also need to set up the intent when you make the Client.

An easy way to do this is

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

More here on this if you want to be more specific in requesting intents

fclinton
  • 25
  • 7