Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

421
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda