| @@ -1,14 +1,15 @@ | |||||
| using System.Diagnostics; | |||||
| using System.Diagnostics; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| public class Game : IActivity | public class Game : IActivity | ||||
| { | { | ||||
| internal Game() { } | |||||
| public string Name { get; internal set; } | public string Name { get; internal set; } | ||||
| public ActivityType Type { get; internal set; } | public ActivityType Type { get; internal set; } | ||||
| internal Game() { } | |||||
| public Game(string name, ActivityType type = ActivityType.Playing) | public Game(string name, ActivityType type = ActivityType.Playing) | ||||
| { | { | ||||
| Name = name; | Name = name; | ||||
| @@ -1,4 +1,4 @@ | |||||
| using System.Diagnostics; | |||||
| using System.Diagnostics; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| @@ -7,8 +7,8 @@ namespace Discord | |||||
| { | { | ||||
| internal RichGame() { } | internal RichGame() { } | ||||
| public string Details { get; internal set;} | |||||
| public string State { get; internal set;} | |||||
| public string Details { get; internal set; } | |||||
| public string State { get; internal set; } | |||||
| public ulong ApplicationId { get; internal set; } | public ulong ApplicationId { get; internal set; } | ||||
| public GameAsset SmallAsset { get; internal set; } | public GameAsset SmallAsset { get; internal set; } | ||||
| public GameAsset LargeAsset { get; internal set; } | public GameAsset LargeAsset { get; internal set; } | ||||
| @@ -19,4 +19,4 @@ namespace Discord | |||||
| public override string ToString() => Name; | public override string ToString() => Name; | ||||
| private string DebuggerDisplay => $"{Name} (Rich)"; | private string DebuggerDisplay => $"{Name} (Rich)"; | ||||
| } | } | ||||
| } | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| using System.Diagnostics; | |||||
| namespace Discord | |||||
| { | |||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||||
| public class SpotifyGame : Game | |||||
| { | |||||
| internal SpotifyGame() { } | |||||
| public string TrackTitle { get; internal set; } | |||||
| public string TrackAlbum { get; internal set; } | |||||
| public string SyncId { get; internal set; } | |||||
| public string SessionId { get; internal set; } | |||||
| public override string ToString() => Name; | |||||
| private string DebuggerDisplay => $"{Name} (Spotify)"; | |||||
| } | |||||
| } | |||||
| @@ -1,4 +1,4 @@ | |||||
| #pragma warning disable CS1591 | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| using Newtonsoft.Json.Serialization; | using Newtonsoft.Json.Serialization; | ||||
| using System.Runtime.Serialization; | using System.Runtime.Serialization; | ||||
| @@ -29,6 +29,10 @@ namespace Discord.API | |||||
| public Optional<API.GameTimestamps> Timestamps { get; set; } | public Optional<API.GameTimestamps> Timestamps { get; set; } | ||||
| [JsonProperty("instance")] | [JsonProperty("instance")] | ||||
| public Optional<bool> Instance { get; set; } | public Optional<bool> Instance { get; set; } | ||||
| [JsonProperty("sync_id")] | |||||
| public Optional<string> SyncId { get; set; } | |||||
| [JsonProperty("session_id")] | |||||
| public Optional<string> SessionId { get; set; } | |||||
| [OnError] | [OnError] | ||||
| internal void OnError(StreamingContext context, ErrorContext errorContext) | internal void OnError(StreamingContext context, ErrorContext errorContext) | ||||
| @@ -1294,7 +1294,7 @@ namespace Discord.WebSocket | |||||
| case "PRESENCE_UPDATE": | case "PRESENCE_UPDATE": | ||||
| { | { | ||||
| await _gatewayLogger.DebugAsync("Received Dispatch (PRESENCE_UPDATE)").ConfigureAwait(false); | await _gatewayLogger.DebugAsync("Received Dispatch (PRESENCE_UPDATE)").ConfigureAwait(false); | ||||
| await _gatewayLogger.DebugAsync(payload.ToString()); | |||||
| var data = (payload as JToken).ToObject<API.Presence>(_serializer); | var data = (payload as JToken).ToObject<API.Presence>(_serializer); | ||||
| if (data.GuildId.IsSpecified) | if (data.GuildId.IsSpecified) | ||||
| @@ -4,6 +4,14 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| public static IActivity ToEntity(this API.Game model) | public static IActivity ToEntity(this API.Game model) | ||||
| { | { | ||||
| // Spotify Game | |||||
| if (model.SyncId.IsSpecified) | |||||
| { | |||||
| return new SpotifyGame() | |||||
| { | |||||
| }; | |||||
| } | |||||
| // Rich Game | // Rich Game | ||||
| if (model.ApplicationId.IsSpecified) | if (model.ApplicationId.IsSpecified) | ||||
| { | { | ||||