Skip to content

Role

Role ⇐ Base

Represents a role in a guild.

Kind: global class
Extends: Base

new Role([data], guildId, client)

Constructs a new Role object.

ParamTypeDescription
[data]ObjectThe data for the role.
guildIdstringThe ID of the guild that the role belongs to.
clientClientThe client instance.

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>

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

Fetches the roles for the guild.

Kind: instance method of Role
Returns: Promise - A promise that resolves with the fetched roles.

ParamTypeDescription
[options]ObjectOptional parameters for the fetch operation.

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.

ParamTypeDescription
optionsObjectThe options to edit the role with.

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.

ParamTypeDescription
reasonstringThe reason for deleting the role.

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

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.

ParamTypeDescription
namestringThe new name to set.
reasonstringThe reason for changing the name.

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.

ParamTypeDescription
permissionsObjectThe permissions to set for the entity.
reasonstringThe reason for setting the permissions.

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.

ParamTypeDescription
colorstringThe new color to set.
reasonstringThe reason for the color change.

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.

ParamTypeDescription
hoistbooleanThe hoist value to set.
reasonstringThe reason for setting the hoist value.

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.

ParamTypeDescription
iconanyThe new icon to set.
reasonstringThe reason for changing the icon.

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.

ParamTypeDescription
unicodeEmojistringThe unicode emoji to set.
reasonstringThe reason for setting the unicode emoji.

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.

ParamTypeDescription
mentionablebooleanWhether the entity should be mentionable or not.
reasonstringThe reason for setting the mentionable status.

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.

ParamTypeDescription
positionnumberThe new position of the role.
reasonstringThe reason for modifying the role’s position.

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.
ParamTypeDescription
channelstring | ChannelThe channel to check permissions in.

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.
ParamTypeDescription
channelstring | ChannelThe channel or channel ID to retrieve the permissions from.

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.

ParamTypeDescription
optionsObjectAn optional object containing additional options for the icon URL.
[options.dynamic]booleanWhether the icon should be dynamically generated.
[options.size]numberThe desired size of the icon.
[options.format]stringThe desired format of the icon.