0

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');
joey dibbs
  • 131
  • 1
  • 2
  • 9
  • Does [this](https://stackoverflow.com/questions/64559390/none-of-my-discord-js-guildmember-events-are-emitting-my-user-caches-are-basica) help? – Arun Kumar Mohan Feb 18 '21 at 04:16
  • Hi, first of all, I'm assuming you changed the token with a token of your own in the last line. If not, get it from here: https://discord.com/developers/applications Secondly, the `member.send` returns a promise, maybe you can `member.send("Welcome to the server!").catch(console.error)` to check if there's an error on that execution? Docs: https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=send Good luck! – Paul Melero Feb 18 '21 at 05:19

1 Answers1

1

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! Also, if you want to add me on Discord, this is my username: Jellybee#4284.

Jellybee
  • 36
  • 1