Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

79
Vistas
How do I get my Discord bot to send a welcome message?

I've watched numerous videos, and followed examples online, and still can't get my discord bot to simply send a message upon a member joining. Maybe I'm missing out on an important update?

//require the necessary discord.js classes
const { Client, Intents } = require("discord.js");
const { token } = require("./config.json");

//create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

//when the client is ready, run this code (only once)
client.on('ready', () => {
    console.log("Online");
});

//sends user a welcome message upon joining
client.on('guildMemberAdd', member => {
    const channel = member.guild.channels.cache.get('921490782958014576');    
    channel.send("Welcome to the server!!")
});

client.login(token);

I get nothing. Nada. I've tried several different pieces of code. I've TRIPLE checked the permissions. This is very frustrating. I've tried unadding and readding the bot to the server. I checked up on the discord.js documentation and nothing seems to be wrong with my code. To me it seems as if the guildMemberAdd isn't emitting anything. I'm using notepad++ to edit my code. I feel I could be using something better for debugging purposes possibly.

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The issue may be due to missing intents. Try adding the GUILD_MEMBERS intent to your list of intents like so.

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS] });

discord.js docs: https://discord.js.org/#/docs/main/stable/class/Intents?scrollTo=s-FLAGS

Developer docs: https://discord.com/developers/docs/topics/gateway#gateway-intents

7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.