Role

class Role

A guild role, including its permission bitfield, hierarchy position, and display settings.

Implements:

Properties

Property

Type

Description

color

number | undefined

24-bit RGB color for this role. undefined when omitted; 0 only when Discord sent 0.

colors

RoleColors | undefined

Role colors. Prefer this over the legacy singular color field.

createdAt

Date

When this role was created.

guildId

string

Guild ID this role belongs to.

hoist

boolean | undefined

Indicates whether this role is displayed separately in the member list.

icon

string | null | undefined

Hash of the role’s icon, or null if not set.

id

string

Role ID.

managed

boolean | undefined

Indicates whether this role is managed by an integration.

mentionable

boolean | undefined

Indicates whether this role can be mentioned by anyone.

name

string

Role name.

permissions

bigint | undefined

Permission bitmask for this role.

position

number | undefined

Position in the role hierarchy (higher = higher priority).

unicodeEmoji

string | null | undefined

Unicode emoji displayed as the role icon, or null.

Methods

async Role.delete(reason: string) → Promise<void>

Delete this role.

Parameters:
  • reason: Reason for deletion, shown in audit log.

async Role.edit(options: RoleEditOptions) → Promise<Role>

Edit role properties.

Parameters:
  • options: Role properties to update.

Returns:

The updated role.

async Role.fetchMembers(options: FetchMembersOptions) → Promise<GuildMember[]>

Fetch guild members who have this role.

Role.toMention() → string

Get the mention string for this role.

Returns:

The role mention string (<@&roleId>).