0

I want to send a welcome message to a new user but the code doesn't work. I tried defiant articles and video tutorials and already asked questions for help but it's not working. I already checked ( Privileged Gateway Intents > PRESENCE INTENT ) and ( Privileged Gateway Intents > SERVER MEMBERS INTENT ) here

here's my code

// Instantiate a new client with some necessary parameters.
const client = new Client(
    { intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }
)

const channelId = "969129834682929212";
  const rulesChannel = "969129988299304960";
  client.on("guildMemberAdd", (member) => {
    console.log(member);

    const message = `Welcome <@${
      member.id
    }> to our server! Be sure to check out our ${member.guild.channels.cache
      .get(rulesChannel)
      .toString()}`;

    const channel = member.guild.channels.cache.get(channelId);
    channel.send(message);
  });
I'M LEEBAN
  • 11
  • 4

1 Answers1

0

I think you are facing this issue is because of recent gateway changes of the Discord Api that you need to enable the intents. Here is a fix for you –

  • Head over to Discord Developers Portal
  • Choose your application
  • Inside the bot section if you scroll a little bit down , you will see a section named Privileged Gateway Intents
  • Enable the SERVER MEMBERS INTENT and restart the bot and your bot will start recieving the guildMemberAdd event!

Learn more about intents at Discord.js

ahsan
  • 312
  • 1
  • 6
  • (https://ibb.co/j562MxG) I already enable the options – I'M LEEBAN Apr 28 '22 at 10:36
  • and im also creating the Instantiate of new client with some necessary parameters `const client = new Client( { intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] } )` – I'M LEEBAN Apr 28 '22 at 10:44
  • This is most likely a privileged intents problem. Check out this [question](https://stackoverflow.com/questions/64739350/discord-js-bot-welcomes-member-assign-a-role-and-send-them-a-dm/64739684#64739684) to see if it solves it. – ahsan Apr 28 '22 at 17:51