Carbon
Core/Classes

Role

Extends

  • Base

Type Parameters

Type ParameterDefault type
IsPartial extends booleanfalse

Constructors

Constructor

new Role<IsPartial>(client, rawDataOrId): Role<IsPartial>

Parameters

ParameterType
clientClient
rawDataOrIdIsPartial extends true ? string : APIRole

Returns

Role<IsPartial>

Overrides

Base.constructor

Properties

PropertyModifierTypeDescriptionInherited from
clientpublicClient-Base.client
idreadonlystringThe ID of the role.-

Accessors

color

Get Signature

get color(): IfPartial<IsPartial, number>

The color of the role.

Returns

IfPartial<IsPartial, number>


flags

Get Signature

get flags(): IfPartial<IsPartial, RoleFlags>

The flags of this role.

See

https://discord.com/developers/docs/topics/permissions#role-object-role-flags

Returns

IfPartial<IsPartial, RoleFlags>


hoisted

Get Signature

get hoisted(): IfPartial<IsPartial, boolean>

If this role is hoisted.

Returns

IfPartial<IsPartial, boolean>


icon

Get Signature

get icon(): IfPartial<IsPartial, null | string>

The icon hash of the role. You can use Role.iconUrl to get the URL of the icon.

Returns

IfPartial<IsPartial, null | string>


iconUrl

Get Signature

get iconUrl(): IfPartial<IsPartial, null | string>

Get the URL of the role's icon

Returns

IfPartial<IsPartial, null | string>


managed

Get Signature

get managed(): IfPartial<IsPartial, boolean>

If this role is managed by an integration.

Returns

IfPartial<IsPartial, boolean>


mentionable

Get Signature

get mentionable(): IfPartial<IsPartial, boolean>

If this role is mentionable.

Returns

IfPartial<IsPartial, boolean>


name

Get Signature

get name(): IfPartial<IsPartial, string>

The name of the role.

Returns

IfPartial<IsPartial, string>


partial

Get Signature

get partial(): IsPartial

Whether the role is a partial role (meaning it does not have all the data). If this is true, you should use Role.fetch to get the full data of the role.

Returns

IsPartial


permissions

Get Signature

get permissions(): IfPartial<IsPartial, string>

The permissions of the role.

Returns

IfPartial<IsPartial, string>


position

Get Signature

get position(): IfPartial<IsPartial, number>

The position of the role.

Returns

IfPartial<IsPartial, number>


tags

Get Signature

get tags(): IfPartial<IsPartial, undefined | APIRoleTags>

The tags of this role.

See

https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure

Returns

IfPartial<IsPartial, undefined | APIRoleTags>


unicodeEmoji

Get Signature

get unicodeEmoji(): IfPartial<IsPartial, null | string>

The unicode emoji for the role.

Returns

IfPartial<IsPartial, null | string>

Methods

delete()

delete(guildId): Promise<void>

Parameters

ParameterType
guildIdstring

Returns

Promise<void>


fetch()

fetch(guildId): Promise<Role<false>>

Fetch updated data for this role. If the role is partial, this will fetch all the data for the role and populate the fields. If the role is not partial, all fields will be updated with new values from Discord.

Parameters

ParameterType
guildIdstring

Returns

Promise<Role<false>>

A Promise that resolves to a non-partial Role


setColor()

setColor(guildId, color): Promise<void>

Set the color of the role

Parameters

ParameterType
guildIdstring
colornumber

Returns

Promise<void>


setHoisted()

setHoisted(guildId, hoisted): Promise<void>

Set the hoisted status of the role

Parameters

ParameterType
guildIdstring
hoistedboolean

Returns

Promise<void>


setIcon()

setIcon(guildId, icon): Promise<void>

Set the icon of the role

Parameters

ParameterTypeDescription
guildIdstring-
iconstringThe unicode emoji or icon URL to set

Returns

Promise<void>


setMentionable()

setMentionable(guildId, mentionable): Promise<void>

Set the mentionable status of the role

Parameters

ParameterType
guildIdstring
mentionableboolean

Returns

Promise<void>


setName()

setName(guildId, name): Promise<void>

Set the name of the role

Parameters

ParameterType
guildIdstring
namestring

Returns

Promise<void>


setPermissions()

setPermissions(guildId, permissions): Promise<void>

Set the permissions of the role

Parameters

ParameterTypeDescription
guildIdstring-
permissionsstringThe permissions to set as a BitField string, until a better permission structure is implemented

Returns

Promise<void>


setPosition()

setPosition(guildId, position): Promise<void>

Set the position of the role

Parameters

ParameterType
guildIdstring
positionnumber

Returns

Promise<void>

On this page