const Discord = require('discord.js');
const client = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers
]
});
// Get the guild (server) and role objects
const guild = client.guilds.cache.get(`${js.guildId}`);
const role = client.guild.roles.cache.find(role => role.name === `${roleName}`);
// Get the member object
const member = guild.members.cache.get(`${js.clientId}`);
// Add the role to the member
member.roles.add(role).catch(console.error);
this code give me this error, TypeError: Cannot read properties of undefined (reading ‘roles’).
What i can do?
i tried searching for answer but i didnt get anythibg