Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

413
Views
discord.js 13 | How do i DM a member a message when they join the server?

I've been trying to find a way to DM a member a welcome message when they join the server. I have a way to DM the member, but I can't find a way to trigger it when someone joins. here's the code that will DM the member a message: message.author.send('message content here')

Here's the code that doesn't seem to work:

bot.on("guildMemberAdd", member => {
    log("new member joined the server")
    member.send("Welcome to the server!");
});

Note: I have a function called log, this is not what's causing the issue (i think), it's declared before this

Thanks for any help :)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your code isn't working, most likely, because you haven't requested the GUILD_MEMBERS intent which is necessary for the guildMemberAdd event.

Here is a simple example on how to request the GUILD_MEMBERS intent.

const { Client, Intents } = require("discord.js");
const bot = new Client({
    intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS],
});

Make sure you have also enabled it in your bot's settings. (Bot -> Privileged Gateway Intents -> SERVER MEMBERS INTENT)

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!