Refactor Games, support reading Rich Presences (#877)
* 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
This commit is contained in:
@@ -8,20 +8,20 @@ namespace Discord.WebSocket
|
||||
public struct SocketPresence : IPresence
|
||||
{
|
||||
public UserStatus Status { get; }
|
||||
public Game? Game { get; }
|
||||
public IActivity Activity { get; }
|
||||
|
||||
internal SocketPresence(UserStatus status, Game? game)
|
||||
internal SocketPresence(UserStatus status, IActivity activity)
|
||||
{
|
||||
Status = status;
|
||||
Game = game;
|
||||
Activity= activity;
|
||||
}
|
||||
internal static SocketPresence Create(Model model)
|
||||
{
|
||||
return new SocketPresence(model.Status, model.Game != null ? model.Game.ToEntity() : (Game?)null);
|
||||
return new SocketPresence(model.Status, model.Game?.ToEntity());
|
||||
}
|
||||
|
||||
public override string ToString() => Status.ToString();
|
||||
private string DebuggerDisplay => $"{Status}{(Game != null ? $", {Game.Value.Name} ({Game.Value.StreamType})" : "")}";
|
||||
private string DebuggerDisplay => $"{Status}{(Activity != null ? $", {Activity.Name}": "")}";
|
||||
|
||||
internal SocketPresence Clone() => this;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Discord.WebSocket
|
||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||
public string Discriminator => DiscriminatorValue.ToString("D4");
|
||||
public string Mention => MentionUtils.MentionUser(Id);
|
||||
public Game? Game => Presence.Game;
|
||||
public IActivity Activity => Presence.Activity;
|
||||
public UserStatus Status => Presence.Status;
|
||||
|
||||
internal SocketUser(DiscordSocketClient discord, ulong id)
|
||||
|
||||
Reference in New Issue
Block a user