Class User
- Namespace
- DiscordRPC
- Assembly
- DiscordRPC.dll
Object representing a Discord user. This is used for join requests.
public class User
- Inheritance
-
User
- Inherited Members
Properties
Avatar
The hash of the user's avatar. To get a URL for the avatar, use the GetAvatarURL(AvatarFormat, AvatarSize).
[JsonProperty("avatar")]
public string Avatar { get; }
Property Value
Remarks
If the user has a default Discord avatar, this value will be null
. GetAvatarURL(AvatarFormat, AvatarSize) will still return the correct default avatar.
AvatarDecoration
The SKU and hash of the users avatar decoration. To get a URL for the decoration, use the GetAvatarDecorationURL().
[JsonProperty("avatar_decoration_data")]
public User.AvatarDecorationData? AvatarDecoration { get; }
Property Value
Bot
Whether the user belongs to an OAuth2 application.
[JsonProperty("bot")]
public bool Bot { get; }
Property Value
CdnEndpoint
The endpoint for the CDN. Normally cdn.discordapp.com.
public string CdnEndpoint { get; }
Property Value
Discriminator
The discriminator of the user.
[JsonProperty("discriminator")]
[Obsolete("Discord no longer uses discriminators.")]
public int Discriminator { get; }
Property Value
Remarks
If the user has migrated to unique a Username, the discriminator will always be 0.
DisplayName
The display name of the user
[JsonProperty("global_name")]
public string DisplayName { get; }
Property Value
Remarks
This will be empty if the user has not set a global display name.
Flags
The flags on a users account, often represented as a badge.
[JsonProperty("flags", NullValueHandling = NullValueHandling.Ignore)]
public User.Flag Flags { get; }
Property Value
ID
The snowflake ID of the user.
[JsonProperty("id")]
public ulong ID { get; }
Property Value
IsAvatarAnimated
The avatar is animated
public bool IsAvatarAnimated { get; }
Property Value
Premium
The premium type of the user.
[JsonProperty("premium_type", NullValueHandling = NullValueHandling.Ignore)]
public User.PremiumType Premium { get; }
Property Value
Username
The username of the player.
[JsonProperty("username")]
public string Username { get; }
Property Value
Methods
GetAvatarDecorationURL()
Gets a URL to the user's avatar decoration.
public string GetAvatarDecorationURL()
Returns
- string
URL to the discord CDN for the current avatar decoration, otherwise
null
.
Remarks
The Image will be a Animated PNG.
GetAvatarDecorationURL(AvatarFormat)
Gets a URL to the user's avatar decoration.
public string GetAvatarDecorationURL(User.AvatarFormat format)
Parameters
format
User.AvatarFormatThe format of the decoration
Returns
- string
URL to the discord CDN for the current avatar decoration, otherwise
null
.
Remarks
The avatar formats do not behave like User Avatars:
- PNG are Animated PNG
- GIF will respond with
415 Unsupported Media Type
- WebP are not animated
- JPEG do not have transparency
Additionally, size is not support and makes no difference to the resulting image.
GetAvatarExtension(AvatarFormat)
Returns the file extension of the specified format.
public string GetAvatarExtension(User.AvatarFormat format)
Parameters
format
User.AvatarFormatThe format to get the extention off
Returns
- string
Returns a period prefixed file extension.
GetAvatarURL()
Gets a URL to the user's avatar PNG.
If the user does not have an avatar, a URL to a default avatar is returned.
public string GetAvatarURL()
Returns
- string
URL to the discord CDN for the particular avatar
Remarks
The file returned will be 128x128px
.
GetAvatarURL(AvatarFormat)
Gets a URL to the user's avatar with the specified format.
If the user does not have an avatar, a URL to a default avatar is returned.
public string GetAvatarURL(User.AvatarFormat format)
Parameters
format
User.AvatarFormatThe format of the target avatar
Returns
- string
URL to the discord CDN for the particular avatar
Remarks
The file returned will be 128x128px
.
The default avatar only supports the PNG format.
Exceptions
- BadImageFormatException
The user has a default avatar but a format other than PNG is requested.
GetAvatarURL(AvatarFormat, AvatarSize)
Gets a URL to the user's avatar with the specified format and size.
If the user does not have an avatar, a URL to a default avatar is returned.
public string GetAvatarURL(User.AvatarFormat format, User.AvatarSize size)
Parameters
format
User.AvatarFormatThe format of the target avatar
size
User.AvatarSizeThe optional size of the avatar you wish for.
Returns
- string
URL to the discord CDN for the particular avatar
Remarks
The default avatar only supports the PNG format.
Exceptions
- BadImageFormatException
The user has a default avatar but a format other than PNG is requested.
ToString()
Formats the user into a displayable format. If the user has a DisplayName, then this will be used.
If the user still has a discriminator, then this will return the form of `Username#Discriminator`.
public override string ToString()
Returns
- string
String of the user that can be used for display.