Table of Contents

Class SocketThreadUser

Namespace
Discord.WebSocket
Assembly
Discord.Net.WebSocket.dll

Represents a thread user received over the gateway.

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

Properties

AvatarId

Gets the identifier of this user's avatar.

public override string AvatarId { get; }

Property Value

string

DiscriminatorValue

Gets the per-username unique ID for this user. This will return 0 for users who have migrated to new username system.

public override ushort DiscriminatorValue { get; }

Property Value

ushort

DisplayAvatarId

Gets the displayed avatar for this user.

public string DisplayAvatarId { get; }

Property Value

string

The users displayed avatar hash. If the user does not have a guild avatar, this will be the regular avatar. If the user also does not have a regular avatar, this will be null.

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.

Flags

Gets the public flags for this guild member.

public GuildUserFlags Flags { get; }

Property Value

GuildUserFlags

GlobalName

Gets the user's display name, if it is set. For bots, this will get the application name.

public override string GlobalName { get; }

Property Value

string

Remarks

This property will be null if user has no display name set.

Guild

Gets the guild this user is in.

public SocketGuild Guild { get; }

Property Value

SocketGuild

GuildAvatarId

Gets the guild specific avatar for this user.

public string GuildAvatarId { get; }

Property Value

string

The users guild avatar hash if they have one; otherwise null.

GuildBannerHash

Gets the guild specific banner for this user.

public string GuildBannerHash { get; }

Property Value

string

The user's guild banner hash if they have one; otherwise null.

GuildUser

Gets the IGuildUser on the server this thread was created in.

public SocketGuildUser GuildUser { get; }

Property Value

SocketGuildUser

Hierarchy

Gets the users position within the role hierarchy.

public int Hierarchy { get; }

Property Value

int

IsBot

Gets a value that indicates whether this user is identified as a bot.

public override bool IsBot { get; }

Property Value

bool

true if the user is a bot application; otherwise false.

Remarks

This property retrieves a value that indicates whether this user is a registered bot application (indicated by the blue BOT tag within the official chat client).

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.

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.

IsPending

Whether the user has passed the guild's Membership Screening requirements.

public bool? IsPending { get; }

Property Value

bool?

IsSelfDeafened

Gets a value that indicates whether this user has marked themselves as deafened.

public bool IsSelfDeafened { get; }

Property Value

bool

true if this user has deafened themselves (i.e. not permitted to listen to or speak to others); otherwise false.

IsSelfMuted

Gets a value that indicates whether this user has marked themselves as muted (i.e. not permitted to speak via voice).

public bool IsSelfMuted { get; }

Property Value

bool

true if this user has muted themselves; otherwise false.

IsStreaming

Gets a value that indicates if this user is streaming in a voice channel.

public bool IsStreaming { get; }

Property Value

bool

true if the user is streaming; otherwise false.

IsSuppressed

Gets a value that indicates whether the user is muted by the current user.

public bool IsSuppressed { get; }

Property Value

bool

true if the guild is temporarily blocking audio to/from this user; otherwise false.

IsVideoing

Gets a value that indicates if the user is videoing in a voice channel.

public bool IsVideoing { get; }

Property Value

bool

true if the user has their camera turned on; otherwise false.

IsWebhook

Gets a value that indicates whether this user is a webhook user.

public override bool IsWebhook { get; }

Property Value

bool

true if the user is a webhook; otherwise false.

JoinedAt

Gets when this user joined the guild.

public DateTimeOffset? JoinedAt { get; }

Property Value

DateTimeOffset?

A DateTimeOffset representing the time of which the user has joined the guild; null when it cannot be obtained.

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.

PremiumSince

Gets the date and time for when this user's guild boost began.

public DateTimeOffset? PremiumSince { get; }

Property Value

DateTimeOffset?

A DateTimeOffset for when the user began boosting this guild; null if they are not boosting the guild.

RequestToSpeakTimestamp

Gets the time on which the user requested to speak.

public DateTimeOffset? RequestToSpeakTimestamp { get; }

Property Value

DateTimeOffset?

Thread

Gets the SocketThreadChannel this user is in.

public SocketThreadChannel Thread { get; }

Property Value

SocketThreadChannel

ThreadJoinedAt

Gets the timestamp for when this user joined this thread.

public DateTimeOffset ThreadJoinedAt { get; }

Property Value

DateTimeOffset

TimedOutUntil

Gets the date and time that indicates if and for how long a user has been timed out.

public DateTimeOffset? TimedOutUntil { get; }

Property Value

DateTimeOffset?

A DateTimeOffset indicating how long the user will be timed out for.

Remarks

null or a timestamp in the past if the user is not timed out.

Username

Gets the username for this user.

public override string Username { get; }

Property Value

string

VoiceChannel

Gets the voice channel this user is currently in.

public IVoiceChannel VoiceChannel { get; }

Property Value

IVoiceChannel

A generic voice channel object representing the voice channel that the user is currently in; null if none.

VoiceSessionId

Gets the unique identifier for this user's voice session.

public string VoiceSessionId { get; }

Property Value

string

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(ulong, RequestOptions)

Adds the specified role to this user in the guild.

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

Parameters

roleId ulong

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<ulong>, RequestOptions)

Adds the specified roleIds to this user in the guild.

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

Parameters

roleIds IEnumerable<ulong>

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.

GetDisplayAvatarUrl(ImageFormat, ushort)

Gets the display avatar URL for this user.

public override string GetDisplayAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128)

Parameters

format ImageFormat

The format of the image.

size ushort

The size of the image that matches any power of two, ranging from 16 to 2048.

Returns

string

A string representing the user's display avatar URL.

Remarks

This method will return GetDefaultAvatarUrl() if the user has no avatar set.

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.

Examples

The following example checks if the current user has the ability to send a message with attachment in this channel; if so, uploads a file via SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags, PollProperties).

if (currentUser?.GetPermissions(targetChannel)?.AttachFiles)
    await targetChannel.SendFileAsync("fortnite.png");

KickAsync(string, RequestOptions)

Kicks this user from this guild.

public Task KickAsync(string reason = null, RequestOptions options = null)

Parameters

reason string

The reason for the kick which will be recorded in the audit log.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous kick operation.

ModifyAsync(Action<GuildUserProperties>, RequestOptions)

Modifies this user's properties in this guild.

public Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null)

Parameters

func Action<GuildUserProperties>

The delegate containing the properties 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 current guild user with the specified properties. To see an example of this method and what properties are available, please refer to GuildUserProperties.

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(ulong, RequestOptions)

Removes the specified roleId from this user in the guild.

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

Parameters

roleId ulong

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<ulong>, RequestOptions)

Removes the specified roleIds from this user in the guild.

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

Parameters

roleIds IEnumerable<ulong>

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.

RemoveTimeOutAsync(RequestOptions)

Removes the current timeout from the user in this guild if one exists.

public Task RemoveTimeOutAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous timeout removal operation.

SetTimeOutAsync(TimeSpan, RequestOptions)

Sets a timeout based on provided TimeSpan to this user in the guild.

public Task SetTimeOutAsync(TimeSpan span, RequestOptions options = null)

Parameters

span TimeSpan

The TimeSpan indicating how long a user should be timed out for.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous timeout creation operation.

Operators

explicit operator SocketGuildUser(SocketThreadUser)

Gets the guild user of this thread user.

public static explicit operator SocketGuildUser(SocketThreadUser user)

Parameters

user SocketThreadUser

Returns

SocketGuildUser