discordbots

Trying to make a discord bot direct message new members. What am I doing wrong?


Trying to make a discord bot direct message new members. What am I doing wrong?

const Discord = require('discord.js');
const bot = new Discord.Client();


bot.on('guildMemberAdd', member => {
    member.send("Welcome to the server!");
});
    
bot.login('TOKEN_HERE');

Solution

  • Everything is correct. The only thing you have to do is to enable some settings to make it work. First, go to the Developer Portal. Second, go to your application and go to "Bot". Third, click the 2 buttons in the "Privileged Gateway Intents" and you are good to go!