Table of Contents

Class SocketGuildUser

Namespace
Kook.WebSocket
Assembly
Kook.Net.WebSocket.dll

Represents a WebSocket-based guild user.

public class SocketGuildUser : SocketUser, IGuildUser, IUser, IEntity<ulong>, IMentionable, IPresence, IVoiceState, IUpdateable
Inheritance
SocketGuildUser
Implements
Inherited Members
Extension Methods

Properties

ActiveAt

Gets when this user was activated.

public DateTimeOffset ActiveAt { get; }

Property Value

DateTimeOffset

The time of which the user was activated.

Avatar

Gets the link to this user's avatar.

public override string Avatar { get; }

Property Value

string

Banner

Gets the link to this user's banner.

public override string Banner { get; }

Property Value

string

BoostSubscriptions

Gets a collection of all boost subscriptions of this user for this guild.

public IReadOnlyCollection<BoostSubscriptionMetadata> BoostSubscriptions { get; }

Property Value

IReadOnlyCollection<BoostSubscriptionMetadata>

A read-only collection of boost subscription metadata of this user for this guild; or null if the boost subscription data has never been cached.

Remarks

warning

Only when AlwaysDownloadBoostSubscriptions is set to true will this property be populated upon startup. Due to the lack of event support for boost subscriptions, this property may be not up-to-date. The changes of BoostSubscriptionCount will trigger the update of this property, but KOOK gateway will not publish this event resulting from the changes of total boost subscription count. To fetch the latest boost subscription data, use DownloadBoostSubscriptionsAsync(RequestOptions) upon SocketGuild or DownloadBoostSubscriptionsAsync(IEnumerable<IGuild>, RequestOptions) upon a KookSocketClient to manually download the latest boost subscription data, or GetBoostSubscriptionsAsync(RequestOptions).

See Also

BuffAvatar

Gets the link to this user's BUFF avatar.

public override string BuffAvatar { get; }

Property Value

string

Color

Gets the color the user's displayed name is being displayed in.

public Color Color { get; }

Property Value

Color

A Color struct representing the color the user's display name is being displayed in.

Remarks

warning

At present, the color of a role may be a solid color or a gradient. See ColorType, which is guaranteed due to the fact that the guild's user list API endpoint returns the color type and the gradient color information if exists. However, the value of this property is fetched from the guild's user list API endpoint, which does not return the color type and the gradient color information. Hence, the value of this property may be incorrect if the color of a role is a gradient.

DisplayName

Gets the displayed name for this user.

public string DisplayName { get; }

Property Value

string

A string representing the display name of the user; If the nickname is null, this will be the username.

Guild

Gets the guild the user is in.

public SocketGuild Guild { get; }

Property Value

SocketGuild

GuildPermissions

Gets the guild-level permissions for this user.

public GuildPermissions GuildPermissions { get; }

Property Value

GuildPermissions

A GuildPermissions structure for this user, representing what permissions this user has in the guild.

HasAnnualBuff

Gets whether this user's BUFF subscription is annual; null if unknown.

public override bool? HasAnnualBuff { get; }

Property Value

bool?

HasBuff

Gets whether this user has subscribed to BUFF; null if unknown.

public override bool? HasBuff { get; }

Property Value

bool?

IdentifyNumberValue

Gets the per-username unique ID for this user.

public override ushort? IdentifyNumberValue { get; }

Property Value

ushort?

IsBanned

Gets whether this user is banned; null if unknown.

public override bool? IsBanned { get; }

Property Value

bool?

IsBot

Gets whether this user is a bot; null if unknown.

public override bool? IsBot { get; }

Property Value

bool?

IsDeafened

Gets a value that indicates whether this user is deafened by the guild.

public bool? IsDeafened { get; }

Property Value

bool?

true if the user is deafened (i.e. not permitted to listen to or speak to others) by the guild; otherwise false; null if unknown.

IsDenoiseEnabled

Gets whether this user enabled denoise feature; null if unknown.

public override bool? IsDenoiseEnabled { get; }

Property Value

bool?

IsMobileVerified

Gets whether the mobile number has been verified for this user.

public bool IsMobileVerified { get; }

Property Value

bool

true if the mobile number has been verified; false otherwise.

IsMuted

Gets a value that indicates whether this user is muted (i.e. not permitted to speak via voice) by the guild.

public bool? IsMuted { get; }

Property Value

bool?

true if this user is muted by the guild; otherwise false; null if unknown.

IsOwner

Gets whether this user owns the current guild.

public bool? IsOwner { get; }

Property Value

bool?

true if this user owns the current guild; false otherwise.

IsSystemUser

Gets whether this user is a system user.

public override bool? IsSystemUser { get; }

Property Value

bool?

JoinedAt

Gets when this user joined the guild.

public DateTimeOffset JoinedAt { get; }

Property Value

DateTimeOffset

The time of which the user has joined the guild.

Nameplates

Gets the nameplates this user has.

public override IReadOnlyCollection<Nameplate> Nameplates { get; }

Property Value

IReadOnlyCollection<Nameplate>

Nickname

Gets the nickname for this user.

public string Nickname { get; }

Property Value

string

A string representing the nickname of the user; null if none is set.

PlainTextMention

Returns a special string used to mention this object in plain text formatted text.

public string PlainTextMention { get; }

Property Value

string

A string that is recognized by Kook as a mention in plain text formatted text.

Roles

Returns a collection of roles that the user possesses.

public IReadOnlyCollection<SocketRole> Roles { get; }

Property Value

IReadOnlyCollection<SocketRole>

Remarks

warning

Due to the lack of events which should be raised when a role is added or removed from a user, this property may not be completely accurate. To ensure the most accurate results, it is recommended to call UpdateAsync(RequestOptions) before this property is used.

UserTag

Get the tag this user has.

public override UserTag UserTag { get; }

Property Value

UserTag

Username

Gets the username for this user.

public override string Username { get; }

Property Value

string

VoiceChannel

Returns the voice channel the user is in, or null if none or unknown.

warning

If a user connects to a voice channel before the bot has connected to the gateway, this property will be null until DownloadVoiceStatesAsync(RequestOptions) or DownloadVoiceStatesAsync(IEnumerable<IGuild>, RequestOptions) is called. To ensure whether the user is in a voice channel or not, use those methods above, or GetConnectedVoiceChannelsAsync(RequestOptions).

public SocketVoiceChannel VoiceChannel { get; }

Property Value

SocketVoiceChannel

VoiceState

Gets the voice status of the user if any.

public SocketVoiceState? VoiceState { get; }

Property Value

SocketVoiceState?

A SocketVoiceState representing the user's voice status; null if the user is neither connected to a voice channel nor is muted or deafened by the guild.

Methods

AddRoleAsync(IRole, RequestOptions)

Adds the specified role to this user in the guild.

public Task AddRoleAsync(IRole role, RequestOptions options = null)

Parameters

role IRole

The role to be added to the user.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous role addition operation.

AddRoleAsync(uint, RequestOptions)

Adds the specified role to this user in the guild.

public Task AddRoleAsync(uint roleId, RequestOptions options = null)

Parameters

roleId uint

The role to be added to the user.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous role addition operation.

AddRolesAsync(IEnumerable<IRole>, RequestOptions)

Adds the specified roles to this user in the guild.

public Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null)

Parameters

roles IEnumerable<IRole>

The roles to be added to the user.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous role addition operation.

AddRolesAsync(IEnumerable<uint>, RequestOptions)

Adds the specified roleIds to this user in the guild.

public Task AddRolesAsync(IEnumerable<uint> roleIds, RequestOptions options = null)

Parameters

roleIds IEnumerable<uint>

The roles to be added to the user.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous role addition operation.

DeafenAsync(RequestOptions)

Deafen this user in this guild.

public Task DeafenAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous deafening operation.

GetBoostSubscriptionsAsync(RequestOptions)

Gets all subscriptions of this user for this guild.

public Task<IReadOnlyCollection<BoostSubscriptionMetadata>> GetBoostSubscriptionsAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task<IReadOnlyCollection<BoostSubscriptionMetadata>>

A task that represents the asynchronous retrieval operation. The task result contains a collection of BoostSubscriptionMetadata, each representing the subscriptions information.

GetConnectedVoiceChannelsAsync(RequestOptions)

Gets a collection of voice channels a user.

public Task<IReadOnlyCollection<SocketVoiceChannel>> GetConnectedVoiceChannelsAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task<IReadOnlyCollection<SocketVoiceChannel>>

A task that represents the asynchronous get operation. The task result contains a collection of voice channels the user is connected to.

GetPermissions(IGuildChannel)

Gets the level permissions granted to this user to a given channel.

public ChannelPermissions GetPermissions(IGuildChannel channel)

Parameters

channel IGuildChannel

The channel to get the permission from.

Returns

ChannelPermissions

A ChannelPermissions structure representing the permissions that a user has in the specified channel.

KickAsync(RequestOptions)

Kicks this user from this guild.

public Task KickAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous kick operation.

ModifyNicknameAsync(string, RequestOptions)

Modifies this user's nickname in this guild.

public Task ModifyNicknameAsync(string name, RequestOptions options = null)

Parameters

name string

The nickname to modify the user with.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous modification operation.

Remarks

This method modifies the nickname of current guild user.

warning

The KOOK API will clear the nickname if the nickname is set to the same as the username at present. Hence either setting the nickname to the same as the username or setting the nickname to null will clear the nickname.

MuteAsync(RequestOptions)

Mute this user in this guild.

public Task MuteAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous muting operation.

RemoveRoleAsync(IRole, RequestOptions)

Removes the specified role from this user in the guild.

public Task RemoveRoleAsync(IRole role, RequestOptions options = null)

Parameters

role IRole

The role to be removed from the user.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous role removal operation.

RemoveRoleAsync(uint, RequestOptions)

Removes the specified roleId from this user in the guild.

public Task RemoveRoleAsync(uint roleId, RequestOptions options = null)

Parameters

roleId uint

The role to be removed from the user.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous role removal operation.

RemoveRolesAsync(IEnumerable<IRole>, RequestOptions)

Removes the specified roles from this user in the guild.

public Task RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null)

Parameters

roles IEnumerable<IRole>

The roles to be removed from the user.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous role removal operation.

RemoveRolesAsync(IEnumerable<uint>, RequestOptions)

Removes the specified roleIds from this user in the guild.

public Task RemoveRolesAsync(IEnumerable<uint> roleIds, RequestOptions options = null)

Parameters

roleIds IEnumerable<uint>

The roles to be removed from the user.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous role removal operation.

UndeafenAsync(RequestOptions)

Undeafen this user in this guild.

public Task UndeafenAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous undeafening operation.

UnmuteAsync(RequestOptions)

Unmute this user in this guild.

public Task UnmuteAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous unmuting operation.

UpdateAsync(RequestOptions)

Fetches the users data from the REST API to update this object, especially the Roles property.

public Task UpdateAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous reloading operation.