• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

172
Views
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.

about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

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

about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error