creating roles discord.js code example
Example 1: discord javascript how to create a role
guild.roles.create({
data: {
name: 'Super Cool People',
color: 'BLUE',
},
reason: 'we needed a role for Super Cool People',
})
.then(console.log)
.catch(console.error);
Example 2: how to give roles discord.js
let role = message.guild.roles.find(r => r.name === "Role Name");
let member = message.mentions.members.first();
member.roles.add(role)
Example 3: discord.js find role by name
let role = message.guild.roles.cache.find(role => role.name === "Rolename");