I want to send a welcome message to a new user but the code doesn't work. I tried defiant articles and video tutorials and already asked questions for help but it's not working. I already checked ( Privileged Gateway Intents > PRESENCE INTENT ) and ( Privileged Gateway Intents > SERVER MEMBERS INTENT ) here
here's my code
// Instantiate a new client with some necessary parameters.
const client = new Client(
{ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }
)
const channelId = "969129834682929212";
const rulesChannel = "969129988299304960";
client.on("guildMemberAdd", (member) => {
console.log(member);
const message = `Welcome <@${
member.id
}> to our server! Be sure to check out our ${member.guild.channels.cache
.get(rulesChannel)
.toString()}`;
const channel = member.guild.channels.cache.get(channelId);
channel.send(message);
});
I think you are facing this issue is because of recent gateway changes of the Discord Api that you need to enable the intents. Here is a fix for you –
bot section if you scroll a little bit down , you will see a section named Privileged Gateway IntentsSERVER MEMBERS INTENT and restart the bot and your bot will start recieving the guildMemberAdd event!Learn more about intents at Discord.js