Class SocketGuildUser
Represents a WebSocket-based guild user.
public class SocketGuildUser : SocketUser, IGuildUser, IUser, ISnowflakeEntity, IEntity<ulong>, IMentionable, IPresence, IVoiceState
- Inheritance
-
SocketGuildUser
- Implements
- Inherited Members
- Extension Methods
Properties
AudioStream
public AudioInStream AudioStream { get; }
Property Value
AvatarId
Gets the identifier of this user's avatar.
public override string AvatarId { get; }
Property Value
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
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
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
Remarks
This property will be null if user has no display name set.
Guild
Gets the guild the user is in.
public SocketGuild Guild { get; }
Property Value
GuildAvatarId
Gets the guild specific avatar for this user.
public string GuildAvatarId { get; }
Property Value
GuildBannerHash
Gets the guild specific banner for this user.
public string GuildBannerHash { get; }
Property Value
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.
Hierarchy
Returns the position of the user within the role hierarchy.
public int Hierarchy { get; }
Property Value
Remarks
The returned value equal to the position of the highest role the user has, or MaxValue if user is the server owner.
IsBot
Gets a value that indicates whether this user is identified as a bot.
public override bool IsBot { get; }
Property Value
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
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
IsStreaming
Gets a value that indicates if this user is streaming in a voice channel.
public bool IsStreaming { get; }
Property Value
IsSuppressed
Gets a value that indicates whether the user is muted by the current user.
public bool IsSuppressed { get; }
Property Value
IsVideoing
Gets a value that indicates if the user is videoing in a voice channel.
public bool IsVideoing { get; }
Property Value
IsWebhook
Gets a value that indicates whether this user is a webhook user.
public override bool IsWebhook { get; }
Property Value
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
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
Roles
Returns a collection of roles that the user possesses.
public IReadOnlyCollection<SocketRole> Roles { get; }
Property Value
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
VoiceChannel
Returns the voice channel the user is in, or null if none.
public SocketVoiceChannel VoiceChannel { get; }
Property Value
VoiceSessionId
Gets the unique identifier for this user's voice session.
public string VoiceSessionId { get; }
Property Value
VoiceState
Gets the voice connection 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 not connected to a voice channel.
Methods
AddRoleAsync(IRole, RequestOptions)
Adds the specified role to this user in the guild.
public Task AddRoleAsync(IRole role, RequestOptions options = null)
Parameters
role
IRoleThe role to be added to the user.
options
RequestOptionsThe 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
ulongThe role to be added to the user.
options
RequestOptionsThe 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
RequestOptionsThe 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
RequestOptionsThe 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
ImageFormatThe format of the image.
size
ushortThe 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.
GetGuildAvatarUrl(ImageFormat, ushort)
Gets the guild-specific avatar URL for this user, if it is set.
public string GetGuildAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128)
Parameters
format
ImageFormatThe format of the image.
size
ushortThe size of the image that matches any power of two, ranging from 16 to 2048.
Returns
- string
A string representing the user's guild-specific avatar URL; null if the user has no guild avatar set.
Remarks
tip
If you wish to retrieve the display avatar for this user, consider using GetDisplayAvatarUrl(ImageFormat, ushort).
GetGuildBannerUrl(ImageFormat, ushort)
Gets the guild-specific banner URL for this user, if it is set.
public string GetGuildBannerUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128)
Parameters
format
ImageFormatThe format of the image.
size
ushortThe size of the image that matches any power of two, ranging from 16 to 2048.
Returns
- string
A string representing the user's guild-specific banner URL; null if the user has no guild banner set.
GetPermissions(IGuildChannel)
Gets the level permissions granted to this user to a given channel.
public ChannelPermissions GetPermissions(IGuildChannel channel)
Parameters
channel
IGuildChannelThe 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
stringThe reason for the kick which will be recorded in the audit log.
options
RequestOptionsThe 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
RequestOptionsThe 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
IRoleThe role to be removed from the user.
options
RequestOptionsThe 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
ulongThe role to be removed from the user.
options
RequestOptionsThe 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
RequestOptionsThe 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
RequestOptionsThe 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
RequestOptionsThe 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
TimeSpanThe TimeSpan indicating how long a user should be timed out for.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous timeout creation operation.