Skip to content Skip to sidebar Skip to footer

Create An Auto-roll For Each New User In The Dhscord.js Bot

I wrote a code that should create an automatic roll for me as soon as a new user is added to my server (feel in a roll system called member) There are errors in the code, I would l

Solution 1:

First, make sure you are finding the role 'member' from member.guild.roles not member.roles. Second, make sure you have declared all intents to send and receive the right data to Discord API.

Add any more intents that your other functions will need.

constDiscord = require('discord.js');
const client = Discord.Client({ ws: { intents: ['GUILDS', 'GUILD_MEMBERS'] } });

client.on('guildMemberAdd', (member)  => { 
    let welcomeRole = member.guild.roles.cache.find(role => role.name == 'member');
    member.roles.add(welcomeRole);
});

Post a Comment for "Create An Auto-roll For Each New User In The Dhscord.js Bot"