Answer the question
In order to leave comments, you need to log in
Role assignment not working, what's the problem?
When a person enters the discord server, he is not given a role, but everything seems to be written correctly.
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.on('guildMemberAdd', (member) => {
let role = member.guild.roles.find('name', "Candidat");
member.addRole(role);
});
bot.login('*******')
Answer the question
In order to leave comments, you need to log in
in Discord Developer Portal , select your app, go to Bot tab => Privileged Gateway Intents => enable Presence Intent and Server Members Intent.
In DiscordJs v12, the way roles are assigned has changed.
member.roles.add(role)
I advise you to use the official guide and use only relevant video tutorials
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question