Class RestUser
Represents a REST-based user.
Inherited Members
Namespace: Discord.Rest
Assembly: Discord.Net.Rest.dll
Syntax
public class RestUser : RestEntity<ulong>, IUser, ISnowflakeEntity, IEntity<ulong>, IMentionable, IPresence, IUpdateable
Properties
| Improve this Doc View SourceActiveClients
Gets the set of clients where this user is currently active.
Declaration
public virtual IImmutableSet<ClientType> ActiveClients { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Immutable.IImmutableSet<ClientType> |
Activity
Gets the activity this user is currently doing.
Declaration
public virtual IActivity Activity { get; }
Property Value
| Type | Description |
|---|---|
| IActivity |
AvatarId
Gets the identifier of this user's avatar.
Declaration
public string AvatarId { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
CreatedAt
Gets when the snowflake was created.
Declaration
public DateTimeOffset CreatedAt { get; }
Property Value
| Type | Description |
|---|---|
| System.DateTimeOffset | A System.DateTimeOffset representing when the entity was first created. |
Discriminator
Gets the per-username unique ID for this user.
Declaration
public string Discriminator { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
DiscriminatorValue
Gets the per-username unique ID for this user.
Declaration
public ushort DiscriminatorValue { get; }
Property Value
| Type | Description |
|---|---|
| System.UInt16 |
IsBot
Gets a value that indicates whether this user is identified as a bot.
Declaration
public bool IsBot { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
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).
IsWebhook
Gets a value that indicates whether this user is a webhook user.
Declaration
public virtual bool IsWebhook { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
Mention
Returns a special string used to mention this object.
Declaration
public string Mention { get; }
Property Value
| Type | Description |
|---|---|
| System.String | A string that is recognized by Discord as a mention (e.g. <@168693960628371456>). |
Status
Gets the current status of this user.
Declaration
public virtual UserStatus Status { get; }
Property Value
| Type | Description |
|---|---|
| UserStatus |
Username
Gets the username for this user.
Declaration
public string Username { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
| Improve this Doc View SourceGetAvatarUrl(ImageFormat, UInt16)
Gets the avatar URL for this user.
Declaration
public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128)
Parameters
| Type | Name | Description |
|---|---|---|
| ImageFormat | format | The format to return. |
| System.UInt16 | size | The size of the image to return in. This can be any power of two between 16 and 2048. |
Returns
| Type | Description |
|---|---|
| System.String | A string representing the user's avatar URL; |
Remarks
This property retrieves a URL for this user's avatar. In event that the user does not have a valid avatar
(i.e. their avatar identifier is not set), this property will return null. If you wish to
retrieve the default avatar for this user, consider using GetDefaultAvatarUrl() (see
example).
GetDefaultAvatarUrl()
Gets the default avatar URL for this user.
Declaration
public string GetDefaultAvatarUrl()
Returns
| Type | Description |
|---|---|
| System.String | A string representing the user's avatar URL. |
Remarks
This property retrieves a URL for this user's default avatar generated by Discord (Discord logo followed
by a random color as its background). This property will always return a value as it is calculated based
on the user's DiscriminatorValue (discriminator % 5).
GetOrCreateDMChannelAsync(RequestOptions)
Returns a direct message channel to this user, or create one if it does not already exist.
Declaration
public Task<RestDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<RestDMChannel> | A task that represents the asynchronous get operation. The task result contains a rest DM channel where the user is the recipient. |
ToString()
Gets the Username#Discriminator of the user.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A string that resolves to Username#Discriminator of the user. |
Overrides
UpdateAsync(RequestOptions)
Updates this object's properties with its current state.
Declaration
public virtual Task UpdateAsync(RequestOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
Explicit Interface Implementations
| Improve this Doc View SourceIUser.GetOrCreateDMChannelAsync(RequestOptions)
Gets the direct message channel of this user, or create one if it does not already exist.
Declaration
Task<IDMChannel> IUser.GetOrCreateDMChannelAsync(RequestOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| RequestOptions | options | The options to be used when sending the request. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<IDMChannel> | A task that represents the asynchronous operation for getting or creating a DM channel. The task result contains the DM channel associated with this user. |
Remarks
This method is used to obtain or create a channel used to send a direct message.
warning
In event that the current user cannot send a message to the target user, a channel can and will still be created by Discord. However, attempting to send a message will yield a Discord.Net.HttpException with a 403 as its Discord.Net.HttpException.HttpCode. There are currently no official workarounds by Discord.