Table of Contents

Class Role

Namespace
NetCord
Assembly
NetCord.dll

Represents a role in a guild.

public class Role : ClientEntity, IEntity, ISpanFormattable, IFormattable, IEquatable<Entity>, IJsonModel<JsonRole>
Inheritance
Role
Implements
Inherited Members

Constructors

Role(JsonRole, ulong, RestClient)

public Role(JsonRole jsonModel, ulong guildId, RestClient client)

Parameters

jsonModel JsonRole
guildId ulong
client RestClient

Properties

Colors

The Role's colors.

public RoleColors Colors { get; }

Property Value

RoleColors

Flags

The Role's flags combined as a bitfield.

public RoleFlags Flags { get; }

Property Value

RoleFlags

GuildId

The ID of the guild this Role belongs to.

public ulong GuildId { get; }

Property Value

ulong

Hoist

Whether this Role causes users with it to be displayed in a separate section in the guild users list.

public bool Hoist { get; }

Property Value

bool

IconHash

The Role's icon hash.

public string? IconHash { get; }

Property Value

string

Id

The Role's ID.

public override ulong Id { get; }

Property Value

ulong

Managed

Whether this Role is managed by an integration.

public bool Managed { get; }

Property Value

bool

Mentionable

Whether this Role is mentionable.

public bool Mentionable { get; }

Property Value

bool

Name

The name of the Role.

public string Name { get; }

Property Value

string

Permissions

The permission bit set for this Role.

public Permissions Permissions { get; }

Property Value

Permissions

Position

The position of this Role for sorting and comparing.

public RolePosition Position { get; }

Property Value

RolePosition

RawPosition

The raw position of this Role.

public int RawPosition { get; }

Property Value

int

Remarks

Use Position to get a properly comparable and sortable position value.

Tags

The tags this Role has.

public RoleTags? Tags { get; }

Property Value

RoleTags

UnicodeEmoji

The Role's Unicode emoji.

public string? UnicodeEmoji { get; }

Property Value

string

Methods

DeleteAsync(RestRequestProperties?, CancellationToken)

public Task DeleteAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task

GetIconUrl(ImageFormat)

Gets the ImageUrl of the Role's icon.

public ImageUrl? GetIconUrl(ImageFormat format)

Parameters

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the role's icon. If the role does not have one set, returns null.

ModifyAsync(Action<RoleOptions>, RestRequestProperties?, CancellationToken)

public Task<Role> ModifyAsync(Action<RoleOptions> action, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

action Action<RoleOptions>
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task<Role>

ToString()

public override string ToString()

Returns

string

TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)

public override bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)

Parameters

destination Span<char>
charsWritten int
format ReadOnlySpan<char>
provider IFormatProvider

Returns

bool