Extends
Members
cache :Collection.<Snowflake, Role>
The role cache of this manager
Type:
- Overrides:
- Source:
cacheType :Collection
The type of Collection of the Manager
Type:
- Collection
- Overrides:
- Source:
(readonly) client :Client
The client that instantiated this Manager
Type:
- Overrides:
- Source:
(readonly) everyone :Role
The `@everyone` role of the guild
Type:
- Source:
guild :Guild
The guild belonging to this manager
Type:
- Source:
(readonly) highest :Role
The role with the highest position in the cache
Type:
- Source:
(private, readonly) holds :function
The data structure belonging to this manager
Type:
- function
- Overrides:
- Source:
Methods
create(optionsopt) → {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.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Options
Properties
|
- Source:
Returns:
- Type
- Promise.<Role>
Examples
// 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({
data: {
name: 'Super Cool People',
color: 'BLUE',
},
reason: 'we needed a role for Super Cool People',
})
.then(console.log)
.catch(console.error);
fetch(idopt, cacheopt, forceopt) → {Promise.<(Role|RoleManager)>}
Obtains one or more roles from Discord, or the role cache if they're already available.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
Snowflake |
<optional> |
ID or IDs of the role(s) | |
cache |
boolean |
<optional> |
true | Whether to cache the new roles objects if it weren't already |
force |
boolean |
<optional> |
false | Whether to skip the cache check and request the API |
- Source:
Returns:
- Type
- Promise.<(Role|RoleManager)>
Examples
// Fetch all roles from the guild
message.guild.roles.fetch()
.then(roles => console.log(`There are ${roles.cache.size} roles.`))
.catch(console.error);
// Fetch a single role
message.guild.roles.fetch('222078108977594368')
.then(role => console.log(`The role color is: ${role.color}`))
.catch(console.error);
resolve(role) → {Role}
Resolves a RoleResolvable to a Role object.
Parameters:
Name | Type | Description |
---|---|---|
role |
RoleResolvable | The role resolvable to resolve |
- Overrides:
- Source:
Returns:
- Type
- Role
resolveID(role) → {Snowflake}
Resolves a RoleResolvable to a role ID string.
Parameters:
Name | Type | Description |
---|---|---|
role |
RoleResolvable | The role resolvable to resolve |
- Overrides:
- Source:
Returns:
- Type
- Snowflake