TheComputerWizard
TheComputerWizard

Reputation: 148

How to make a discord.js welcome user function?

I am trying to use the GuildMemberAdd thingy, and it's not working. I've tried a lot of stack overflow question answers, none work. Can someone help???

My code right now:

client.on('guildMemberAdd', async member => {
    let welcomes = await memeber.guild.channels.fetch('796153454686896208')
    welcomes.send('**' + member.user.username + '** has joined the server!'); 
});

Help please!

Upvotes: 1

Views: 64

Answers (2)

TheComputerWizard
TheComputerWizard

Reputation: 148

I fixed it. Here's the code:

client.on('guildMemberAdd', async member => {
    let welcomes = await client.channels.fetch('816066665913385032') // get channel
    welcomes.send('**' + member.user.username + '** has joined the server!') // send message
    logging.send('**' + member.user.username + '** has joined the server') // send in logging channel idk
    let role = await member.guild.roles.fetch('800055283962478592') // add member role part 1
    member.roles.add('804163518525210682') // part 2 here
})

Sorry about the bad question!!!

Upvotes: 0

LouieBouie
LouieBouie

Reputation: 260

Do you have intents enabled? You need to check it on.

https://discord.com/developers/applications Go to here and select your bot app and go to the bot tab and scroll down and turn on the intents.

Upvotes: 2

Related Questions