I've seen a bunch of answers on Stack Overflow showing how to make a role with a colour but it doesn't show how to make it with permissions.
Any ideas?
I've seen a bunch of answers on Stack Overflow showing how to make a role with a colour but it doesn't show how to make it with permissions.
Any ideas?
You can create a role with permissions using this:
guild.roles.create({
name: 'Super Cool Blue People',
color: 'BLUE',
reason: 'we needed a role for Super Cool People',
permissions: ['ADMINISTRATOR', 'KICK_MEMBERS'],
})
I have added two examples above ADMINISTRATOR and KICK_MEMBERS.
Flag List: https://discord.js.org/#/docs/main/stable/class/Permissions?scrollTo=s-FLAGS
Please note that you're recommended to use Permissions.FLAGS.<FLAG-NAME> instead of hard-coding the permission name.
A guild's RoleManager#create takes a parameter of type CreateRoleOptions, which has a property permissions of type PermissionResolvable. Therefore, you can create a role with specific permissions by calling:
guild.roles.create({
permissions: "ADMINISTRATOR"
});