Role
Role ⇐ Base
Section titled “Role ⇐ Base”Represents a role in a guild.
Kind: global class
Extends: Base
- Role ⇐
Base- new Role([data], guildId, client)
- .guild ⇒
- .members ⇒
Collection.<Snowflake, GuildMember> - .fetch([options]) ⇒
Promise - .edit(options) ⇒
Promise - .delete(reason) ⇒
Promise.<void> - .clone() ⇒
Promise.<Role> - .setName(name, reason) ⇒
Promise - .setPermissions(permissions, reason) ⇒
Promise - .setColor(color, reason) ⇒
Promise - .setHoist(hoist, reason) ⇒
Promise - .setIcon(icon, reason) ⇒
Promise - .setUnicodeEmoji(unicodeEmoji, reason) ⇒
Promise - .setMentionable(mentionable, reason) ⇒
Promise.<void> - .setPosition(position, reason) ⇒
Promise.<Role> - .permissionsIn(channel) ⇒
Permissions - .deniedPermissionsIn(channel) ⇒
PermissionFlags|null - .iconURL(options) ⇒
string|null
new Role([data], guildId, client)
Section titled “new Role([data], guildId, client)”Constructs a new Role object.
| Param | Type | Description |
|---|---|---|
| [data] | Object | The data for the role. |
| guildId | string | The ID of the guild that the role belongs to. |
| client | Client | The client instance. |
role.guild ⇒
Section titled “role.guild ⇒”Retrieves the guild associated with this guildId.
Kind: instance property of Role
Returns: The guild object if found, otherwise null.
role.members ⇒ Collection.<Snowflake, GuildMember>
Section titled “role.members ⇒ Collection.<Snowflake, GuildMember>”Retrieves the members of the guild who have the specified role.
Kind: instance property of Role
Returns: Collection.<Snowflake, GuildMember> - A collection of guild members who have the role.
role.fetch([options]) ⇒ Promise
Section titled “role.fetch([options]) ⇒ Promise”Fetches the roles for the guild.
Kind: instance method of Role
Returns: Promise - A promise that resolves with the fetched roles.
| Param | Type | Description |
|---|---|---|
| [options] | Object | Optional parameters for the fetch operation. |
role.edit(options) ⇒ Promise
Section titled “role.edit(options) ⇒ Promise”Edits the role with the specified options.
Kind: instance method of Role
Returns: Promise - A promise that resolves when the role has been edited.
| Param | Type | Description |
|---|---|---|
| options | Object | The options to edit the role with. |
role.delete(reason) ⇒ Promise.<void>
Section titled “role.delete(reason) ⇒ Promise.<void>”Deletes the role from the guild.
Kind: instance method of Role
Returns: Promise.<void> - - A promise that resolves when the role is deleted.
| Param | Type | Description |
|---|---|---|
| reason | string | The reason for deleting the role. |
role.clone() ⇒ Promise.<Role>
Section titled “role.clone() ⇒ Promise.<Role>”Clones the current role.
Kind: instance method of Role
Returns: Promise.<Role> - A promise that resolves to the cloned role.
role.setName(name, reason) ⇒ Promise
Section titled “role.setName(name, reason) ⇒ Promise”Sets the name of an object and provides a reason for the change.
Kind: instance method of Role
Returns: Promise - A promise that resolves when the name is successfully set.
| Param | Type | Description |
|---|---|---|
| name | string | The new name to set. |
| reason | string | The reason for changing the name. |
role.setPermissions(permissions, reason) ⇒ Promise
Section titled “role.setPermissions(permissions, reason) ⇒ Promise”Sets the permissions for an entity with the given reason.
Kind: instance method of Role
Returns: Promise - - A promise that resolves when the permissions are set.
| Param | Type | Description |
|---|---|---|
| permissions | Object | The permissions to set for the entity. |
| reason | string | The reason for setting the permissions. |
role.setColor(color, reason) ⇒ Promise
Section titled “role.setColor(color, reason) ⇒ Promise”Sets the color of an object and provides a reason for the change.
Kind: instance method of Role
Returns: Promise - - A promise that resolves when the color is successfully set.
| Param | Type | Description |
|---|---|---|
| color | string | The new color to set. |
| reason | string | The reason for the color change. |
role.setHoist(hoist, reason) ⇒ Promise
Section titled “role.setHoist(hoist, reason) ⇒ Promise”Sets the hoist value and reason for a specific item.
Kind: instance method of Role
Returns: Promise - - A promise that resolves when the hoist value is set.
| Param | Type | Description |
|---|---|---|
| hoist | boolean | The hoist value to set. |
| reason | string | The reason for setting the hoist value. |
role.setIcon(icon, reason) ⇒ Promise
Section titled “role.setIcon(icon, reason) ⇒ Promise”Sets the icon of an object and provides a reason for the change.
Kind: instance method of Role
Returns: Promise - A promise that resolves when the icon is successfully set.
| Param | Type | Description |
|---|---|---|
| icon | any | The new icon to set. |
| reason | string | The reason for changing the icon. |
role.setUnicodeEmoji(unicodeEmoji, reason) ⇒ Promise
Section titled “role.setUnicodeEmoji(unicodeEmoji, reason) ⇒ Promise”Sets the unicode emoji for an entity.
Kind: instance method of Role
Returns: Promise - A promise that resolves when the unicode emoji is set.
| Param | Type | Description |
|---|---|---|
| unicodeEmoji | string | The unicode emoji to set. |
| reason | string | The reason for setting the unicode emoji. |
role.setMentionable(mentionable, reason) ⇒ Promise.<void>
Section titled “role.setMentionable(mentionable, reason) ⇒ Promise.<void>”Sets the mentionable status of an entity.
Kind: instance method of Role
Returns: Promise.<void> - - A promise that resolves when the mentionable status is set.
| Param | Type | Description |
|---|---|---|
| mentionable | boolean | Whether the entity should be mentionable or not. |
| reason | string | The reason for setting the mentionable status. |
role.setPosition(position, reason) ⇒ Promise.<Role>
Section titled “role.setPosition(position, reason) ⇒ Promise.<Role>”Sets the position of the role within the guild’s role hierarchy.
Kind: instance method of Role
Returns: Promise.<Role> - - A promise that resolves to the modified Role object.
| Param | Type | Description |
|---|---|---|
| position | number | The new position of the role. |
| reason | string | The reason for modifying the role’s position. |
role.permissionsIn(channel) ⇒ Permissions
Section titled “role.permissionsIn(channel) ⇒ Permissions”Retrieves the permissions of the bot in the specified channel.
Kind: instance method of Role
Returns: Permissions - - The permissions of the bot in the channel.
Throws:
RangeError- If the channel is not cached.
| Param | Type | Description |
|---|---|---|
| channel | string | Channel | The channel to check permissions in. |
role.deniedPermissionsIn(channel) ⇒ PermissionFlags | null
Section titled “role.deniedPermissionsIn(channel) ⇒ PermissionFlags | null”Retrieves the denied permissions for the specified channel.
Kind: instance method of Role
Returns: PermissionFlags | null - - The denied permissions for the channel, or null if no permissions are found.
Throws:
RangeError- If the channel is not cached.
| Param | Type | Description |
|---|---|---|
| channel | string | Channel | The channel or channel ID to retrieve the permissions from. |
role.iconURL(options) ⇒ string | null
Section titled “role.iconURL(options) ⇒ string | null”Returns the URL of the icon for this role.
Kind: instance method of Role
Returns: string | null - The URL of the icon, or null if no icon is available.
| Param | Type | Description |
|---|---|---|
| options | Object | An optional object containing additional options for the icon URL. |
| [options.dynamic] | boolean | Whether the icon should be dynamically generated. |
| [options.size] | number | The desired size of the icon. |
| [options.format] | string | The desired format of the icon. |