* Add API-level support for Rich Presences * Add library-level support for Game presences * Add model conversions for outgoing+incoming rich presences * Refactored Game into Activities * Integrated Activities with user entities rebase hell from 5f3cb947a92f4fd01cc4df47ca548180036b47f3 * Fix JSON converters for Activities * Finish rebase, activity should be set on BaseSocketClient * Use ApplicationId to define a rich presence * Added SetActivityAsync to Base and Sharded Socket clients * Remove public parameterless Game constructor * Remove GameAssets, refactored to GameAsset * Hide constructors for types that should be read-only * Revert changes to Discord.Net.sln got damned visual studio caching * Refactor GameParty to use dedicated current/capacity values Per feedback from @khionu
29 lines
855 B
C#
29 lines
855 B
C#
using System.Diagnostics;
|
|
using Model = Discord.API.Presence;
|
|
|
|
namespace Discord.WebSocket
|
|
{
|
|
//TODO: C#7 Candidate for record type
|
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
|
public struct SocketPresence : IPresence
|
|
{
|
|
public UserStatus Status { get; }
|
|
public IActivity Activity { get; }
|
|
|
|
internal SocketPresence(UserStatus status, IActivity activity)
|
|
{
|
|
Status = status;
|
|
Activity= activity;
|
|
}
|
|
internal static SocketPresence Create(Model model)
|
|
{
|
|
return new SocketPresence(model.Status, model.Game?.ToEntity());
|
|
}
|
|
|
|
public override string ToString() => Status.ToString();
|
|
private string DebuggerDisplay => $"{Status}{(Activity != null ? $", {Activity.Name}": "")}";
|
|
|
|
internal SocketPresence Clone() => this;
|
|
}
|
|
}
|