Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
auto add role discord.js v12

I have made this welcome message for my discord bot:

 

client.on("guildMemberAdd", async member => {
  console.log(`Member join username: %s`, member.user.username);
  if(member.guild.id !== "951189437168091166") return; 
  
  const welcomeCard = new canvacord.Welcomer()
  
  welcomeCard.setUsername(member.user.username)
  welcomeCard.setDiscriminator(member.user.discriminator)
  
  welcomeCard.setAvatar(member.user.displayAvatarURL({format: "png"}))
  welcomeCard.setColor("title", "welcomeCard")
  welcomeCard.setColor("username-box", "welcomeCard")
  welcomeCard.setColor("discriminator-box", "welcomeCard")
  welcomeCard.setColor("message-box", "welcomeCard")
  welcomeCard.setColor("border", "welcomeCard")
  welcomeCard.setColor("avatar", "welcomeCard")
  welcomeCard.setBackground("https://img.freepik.com/vrije-vector/donker-papierlagenbehang-met-gouden-details_23-2148403401.jpg?w=360")
  welcomeCard.setMemberCount(member.guild.memberCount)
  let attachment = new Discord.MessageAttachment(await welcomeCard.build(), "welcome.png")
   member.guild.channels.cache.get("961943485315944508").send( member.toString(), attachment)
})

But i want the bot to add a role to the joined member when the member joins the server. I have tried multiple things, but i dont know if i can put it in this code. Can someone please help me?

Discord js (v12)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

let role = member.guild.roles.cache.find(r=> r.name === "your-role-name") 
member.roles.add(role)
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!