class RoleManager
extends
CachedManager<Snowflake, Role, RoleResolvable>export class RoleManager extends CachedManager<Snowflake, Role, RoleResolvable>Manages API methods for roles and stores their cache.
readonlycache : Collection<Key, Holds> 
The cache of items for this manager.
Inherited from: DataManager
readonlyeveryone : Role 
The @everyone role of the guild
guild : Guild
The guild belonging to this manager
readonlyhighest : Role 
The role with the highest position in the cache
readonlyholds : Constructable<Holds> 
The data structure belonging to this manager.
Inherited from: DataManager
 botRoleFor(user: UserResolvable) : Role | null
Gets the managed role a user created when joining the guild, if any Only ever available for bots
 comparePositions(role1: RoleResolvablerole2: RoleResolvable) : number
Compares the positions of two roles.
Returns: Negative number if the first role's position is lower (second role's is higher), positive number if the first's is higher (second's is lower), 0 if equal
 create(options?: RoleCreateOptions) : Promise<Role>
Creates a new role in the guild with given information. The position will silently reset to 1 if an invalid one is provided, or none.
// Create a new role
guild.roles.create()
  .then(console.log)
  .catch(console.error);// Create a new role with data and a reason
guild.roles.create({
  name: 'Super Cool Blue People',
  reason: 'we needed a role for Super Cool People',
  colors: {
    primaryColor: Colors.Blue,
  },
})
  .then(console.log)
  .catch(console.error);// Create a role with holographic colors
guild.roles.create({
  name: 'Holographic Role',
  reason: 'Creating a role with holographic effect',
  colors: {
    primaryColor: Constants.HolographicStyle.Primary,
    secondaryColor: Constants.HolographicStyle.Secondary,
    tertiaryColor: Constants.HolographicStyle.Tertiary,
  },
})
  .then(console.log)
  .catch(console.error); delete(role: RoleResolvablereason?: string) : Promise<void>
Deletes a role.
// Delete a role
guild.roles.delete('222079219327434752', 'The role needed to go')
  .then(() => console.log('Deleted the role'))
  .catch(console.error); edit(role: RoleResolvableoptions: RoleEditOptions) : Promise<Role>
Edits a role of the guild.
// Edit a role
guild.roles.edit('222079219327434752', { name: 'buddies' })
  .then(updated => console.log(`Edited role name to ${updated.name}`))
  .catch(console.error); fetch(id: Snowflakeoptions?: BaseFetchOptions) : Promise<Role | null>
Obtains a role from Discord, or the role cache if they're already available.
// Fetch all roles from the guild
message.guild.roles.fetch()
  .then(roles => console.log(`There are ${roles.size} roles.`))
  .catch(console.error);// Fetch a single role
message.guild.roles.fetch('222078108977594368')
  .then(role => console.log(`The role color is: ${role.colors.primaryColor}`))
  .catch(console.error); resolve(role: RoleResolvable) : Role | null
Resolves a RoleResolvable to a Role object.
 resolveId(role: RoleResolvable) : Snowflake | null
Resolves a RoleResolvable to a Role id.
Sets the new position of the role.
// Set the position of the role
guild.roles.setPosition('222197033908436994', 1)
  .then(updated => console.log(`Role position: ${updated.position}`))
  .catch(console.error); setPositions(rolePositions: readonly RolePosition[]) : Promise<Guild>
Batch-updates the guild's role positions
guild.roles.setPositions([{ role: roleId, position: updatedRoleIndex }])
 .then(guild => console.log(`Role positions updated for ${guild}`))
 .catch(console.error);valueOf() : Collection<Key, Holds>
Inherited from: DataManager