Files
Discord.Net/src/Discord.Net.WebSocket/Entities/Users/SocketUnknownUser.cs
Chris Johnston 9da11b4184 [ifcbrk] feature: Implement Client Status Support (#1247)
* Implement Client Status Support

Adds support for using the client_status as sent as part of the Presence model. This value can be used to determine if a user is active on the native desktop app, the mobile app, or the website.

* lint: whitespace in IPresence

* Remove breaking change to IPresence interface with a note for 2.1

* update comment to not reference 2.1

* re-add interface break to IPresence

* add example payload for client_status

* use inline declaration for Enum.TryParse
2019-06-22 23:46:20 -04:00

49 lines
1.9 KiB
C#

using System;
using System.Diagnostics;
using Model = Discord.API.User;
namespace Discord.WebSocket
{
/// <summary>
/// Represents a WebSocket-based user that is yet to be recognized by the client.
/// </summary>
/// <remarks>
/// A user may not be recognized due to the user missing from the cache or failed to be recognized properly.
/// </remarks>
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketUnknownUser : SocketUser
{
/// <inheritdoc />
public override string Username { get; internal set; }
/// <inheritdoc />
public override ushort DiscriminatorValue { get; internal set; }
/// <inheritdoc />
public override string AvatarId { get; internal set; }
/// <inheritdoc />
public override bool IsBot { get; internal set; }
/// <inheritdoc />
public override bool IsWebhook => false;
/// <inheritdoc />
internal override SocketPresence Presence { get { return new SocketPresence(UserStatus.Offline, null, null); } set { } }
/// <inheritdoc />
/// <exception cref="NotSupportedException">This field is not supported for an unknown user.</exception>
internal override SocketGlobalUser GlobalUser =>
throw new NotSupportedException();
internal SocketUnknownUser(DiscordSocketClient discord, ulong id)
: base(discord, id)
{
}
internal static SocketUnknownUser Create(DiscordSocketClient discord, ClientState state, Model model)
{
var entity = new SocketUnknownUser(discord, model.Id);
entity.Update(state, model);
return entity;
}
private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")}, Unknown)";
internal new SocketUnknownUser Clone() => MemberwiseClone() as SocketUnknownUser;
}
}