Class DiscordUser
Represents a Discord user.
Namespace: DisCatSharp.Entities
Assembly: DisCatSharp.dll
Syntax
public class DiscordUser : SnowflakeObject, IEquatable<DiscordUser>
Properties
| Improve this Doc View SourceAvatarHash
Gets the user's avatar hash.
Declaration
public virtual string AvatarHash { get; }
Property Value
Type | Description |
---|---|
System.String |
AvatarUrl
Gets the user's avatar URL.s
Declaration
public string AvatarUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
BannerColor
Gets the user's banner color, if set. Mutually exclusive with BannerHash.
Declaration
public virtual DiscordColor? BannerColor { get; }
Property Value
Type | Description |
---|---|
System.Nullable<DiscordColor> |
BannerHash
Gets the user's profile banner hash. Mutually exclusive with BannerColor.
Declaration
public virtual string BannerHash { get; }
Property Value
Type | Description |
---|---|
System.String |
BannerUrl
Gets the user's banner url
Declaration
public string BannerUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
Bio
Gets the users bio. This is not available to bots tho.
Declaration
public virtual string Bio { get; }
Property Value
Type | Description |
---|---|
System.String |
DefaultAvatarUrl
Gets the URL of default avatar for this user.
Declaration
public string DefaultAvatarUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
Discriminator
Gets the user's 4-digit discriminator.
Declaration
public virtual string Discriminator { get; }
Property Value
Type | Description |
---|---|
System.String |
Gets the user's email address.
This is only present in OAuth.
Declaration
public virtual string Email { get; }
Property Value
Type | Description |
---|---|
System.String |
Flags
Gets the user's flags.
Declaration
public virtual UserFlags? Flags { get; }
Property Value
Type | Description |
---|---|
System.Nullable<UserFlags> |
IsBot
Gets whether the user is a bot.
Declaration
public virtual bool IsBot { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsBotDev
Whether this member is a VerifiedDeveloper
Declaration
public bool IsBotDev { get; }
Property Value
Type | Description |
---|---|
System.Boolean | System.Boolean |
IsCurrent
Gets whether this user is the Client which created this object.
Declaration
public bool IsCurrent { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsMod
Whether this member is a CertifiedModerator
Declaration
public bool IsMod { get; }
Property Value
Type | Description |
---|---|
System.Boolean | System.Boolean |
IsPartner
Whether this member is a Partner
Declaration
public bool IsPartner { get; }
Property Value
Type | Description |
---|---|
System.Boolean | System.Boolean |
IsStaff
Whether this member is a Staff
Declaration
public bool IsStaff { get; }
Property Value
Type | Description |
---|---|
System.Boolean | System.Boolean |
IsSystem
Gets whether the user is an official Discord system user.
Declaration
public bool? IsSystem { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Boolean> |
IsVerifiedBot
Whether this member is a VerifiedBot
Declaration
public bool IsVerifiedBot { get; }
Property Value
Type | Description |
---|---|
System.Boolean | System.Boolean |
Locale
Gets the user's chosen language
Declaration
public virtual string Locale { get; }
Property Value
Type | Description |
---|---|
System.String |
Mention
Gets the user's mention string.
Declaration
public string Mention { get; }
Property Value
Type | Description |
---|---|
System.String |
MfaEnabled
Gets whether the user has multi-factor authentication enabled.
Declaration
public virtual bool? MfaEnabled { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Boolean> |
OAuthFlags
Gets the user's flags for OAuth.
Declaration
public virtual UserFlags? OAuthFlags { get; }
Property Value
Type | Description |
---|---|
System.Nullable<UserFlags> |
PremiumType
Gets the user's premium type.
Declaration
public virtual PremiumType? PremiumType { get; }
Property Value
Type | Description |
---|---|
System.Nullable<PremiumType> |
Presence
Gets this user's presence.
Declaration
public DiscordPresence Presence { get; }
Property Value
Type | Description |
---|---|
DiscordPresence |
ProfileUri
Returns a uri to this users profile.
Declaration
public Uri ProfileUri { get; }
Property Value
Type | Description |
---|---|
System.Uri |
ProfileUrl
Returns a string representing the direct URL to this users profile.
Declaration
public string ProfileUrl { get; }
Property Value
Type | Description |
---|---|
System.String | The URL of this users profile. |
Pronouns
Gets the user's pronouns.
Declaration
public virtual string Pronouns { get; }
Property Value
Type | Description |
---|---|
System.String |
Username
Gets this user's username.
Declaration
public virtual string Username { get; }
Property Value
Type | Description |
---|---|
System.String |
UsernameWithDiscriminator
Gets this user's username with the discriminator. Example: Discord#0000
Declaration
public virtual string UsernameWithDiscriminator { get; }
Property Value
Type | Description |
---|---|
System.String |
Verified
Gets whether the user is verified.
This is only present in OAuth.
Declaration
public virtual bool? Verified { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Boolean> |
Methods
| Improve this Doc View SourceConvertToMember(DiscordGuild)
Returns the DiscordMember in the specified DiscordGuild
Declaration
public async Task<DiscordMember> ConvertToMember(DiscordGuild guild)
Parameters
Type | Name | Description |
---|---|---|
DiscordGuild | guild | The DiscordGuild to get this user on. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordMember> | The DiscordMember. |
Exceptions
Type | Condition |
---|---|
NotFoundException | Thrown when the user is not part of the guild. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
Equals(DiscordUser)
Checks whether this DiscordUser is equal to another DiscordUser.
Declaration
public bool Equals(DiscordUser e)
Parameters
Type | Name | Description |
---|---|---|
DiscordUser | e | DiscordUser to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the DiscordUser is equal to this DiscordUser. |
Equals(Object)
Checks whether this DiscordUser is equal to another object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Object to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the object is equal to this DiscordUser. |
Overrides
GetAvatarUrl(ImageFormat, UInt16)
Gets the user's avatar URL, in requested format and size.
Declaration
public string GetAvatarUrl(ImageFormat fmt, ushort size = 1024)
Parameters
Type | Name | Description |
---|---|---|
ImageFormat | fmt | Format of the avatar to get. |
System.UInt16 | size | Maximum size of the avatar. Must be a power of two, minimum 16, maximum 2048. |
Returns
Type | Description |
---|---|
System.String | URL of the user's avatar. |
GetFromApiAsync()
Fetches the user from the API.
Declaration
public async Task<DiscordUser> GetFromApiAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordUser> | The user with fresh data from the API. |
GetHashCode()
Gets the hash code for this DiscordUser.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | The hash code for this DiscordUser. |
Overrides
IsInGuild(DiscordGuild)
Whether this user is in a DiscordGuild
Declaration
public async Task<bool> IsInGuild(DiscordGuild guild)
Parameters
Type | Name | Description |
---|---|---|
DiscordGuild | guild | DiscordGuild |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | System.Boolean |
Examples
DiscordGuild guild = await Client.GetGuildAsync(806675511555915806);
DiscordUser user = await Client.GetUserAsync(469957180968271873);
Console.WriteLine($"{user.Username} {(user.IsInGuild(guild) ? "is a" : "is not a")} member of {guild.Name}");
results to J_M_Lutra is a member of Project Nyaw~
.
IsNotInGuild(DiscordGuild)
Whether this user is not in a DiscordGuild
Declaration
public async Task<bool> IsNotInGuild(DiscordGuild guild)
Parameters
Type | Name | Description |
---|---|---|
DiscordGuild | guild | DiscordGuild |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | System.Boolean |
ToString()
Returns a string representation of this user.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | String representation of this user. |
Overrides
UnbanAsync(DiscordGuild, String)
Unbans this user from a guild.
Declaration
public Task UnbanAsync(DiscordGuild guild, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordGuild | guild | Guild to unban this user from. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the BanMembers permission. |
NotFoundException | Thrown when the user does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
Operators
| Improve this Doc View SourceEquality(DiscordUser, DiscordUser)
Gets whether the two DiscordUser objects are equal.
Declaration
public static bool operator ==(DiscordUser e1, DiscordUser e2)
Parameters
Type | Name | Description |
---|---|---|
DiscordUser | e1 | First user to compare. |
DiscordUser | e2 | Second user to compare. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the two users are equal. |
Inequality(DiscordUser, DiscordUser)
Gets whether the two DiscordUser objects are not equal.
Declaration
public static bool operator !=(DiscordUser e1, DiscordUser e2)
Parameters
Type | Name | Description |
---|---|---|
DiscordUser | e1 | First user to compare. |
DiscordUser | e2 | Second user to compare. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the two users are not equal. |