Table of Contents

Interface IGuildUser

Namespace
Discord
Assembly
Discord.Net.Core.dll

Represents a generic guild user.

public interface IGuildUser : IUser, ISnowflakeEntity, IEntity<ulong>, IMentionable, IPresence, IVoiceState
Inherited Members
Extension Methods

Properties

DisplayAvatarId

Gets the displayed avatar for this user.

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.

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.

GuildUserFlags Flags { get; }

Property Value

GuildUserFlags

Guild

Gets the guild for this user.

IGuild Guild { get; }

Property Value

IGuild

A guild object that this user belongs to.

GuildAvatarId

Gets the guild specific avatar for this user.

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.

string GuildBannerHash { get; }

Property Value

string

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

GuildId

Gets the ID of the guild for this user.

ulong GuildId { get; }

Property Value

ulong

An ulong representing the snowflake identifier of the guild that this user belongs to.

GuildPermissions

Gets the guild-level permissions for this user.

GuildPermissions GuildPermissions { get; }

Property Value

GuildPermissions

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

Hierarchy

Gets the users position within the role hierarchy.

int Hierarchy { get; }

Property Value

int

IsPending

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

bool? IsPending { get; }

Property Value

bool?

JoinedAt

Gets when this user joined the guild.

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.

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.

DateTimeOffset? PremiumSince { get; }

Property Value

DateTimeOffset?

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

RoleIds

Gets a collection of IDs for the roles that this user currently possesses in the guild.

IReadOnlyCollection<ulong> RoleIds { get; }

Property Value

IReadOnlyCollection<ulong>

A read-only collection of ulong, each representing a snowflake identifier for a role that this user possesses.

Remarks

This property returns a read-only collection of the identifiers of the roles that this user possesses. For WebSocket users, a Roles property can be found in place of this property. Due to the REST implementation, only a collection of identifiers can be retrieved instead of the full role objects.

TimedOutUntil

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

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.

Methods

AddRoleAsync(IRole, RequestOptions)

Adds the specified role to this user in the guild.

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.

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.

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.

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.

GetGuildAvatarUrl(ImageFormat, ushort)

Gets the guild-specific avatar URL for this user, if it is set.

string GetGuildAvatarUrl(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 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.

string GetGuildBannerUrl(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 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.

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.

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.

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.

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.

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.

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.

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.

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.

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.