|
|
@@ -4,6 +4,27 @@ namespace Discord.WebSocket |
|
|
|
{ |
|
|
|
public static IActivity ToEntity(this API.Game model) |
|
|
|
{ |
|
|
|
// Spotify Game |
|
|
|
if (model.SyncId.IsSpecified) |
|
|
|
{ |
|
|
|
var assets = model.Assets.GetValueOrDefault()?.ToEntity(); |
|
|
|
string albumText = assets?[1]?.Text; |
|
|
|
string albumArtId = assets?[1]?.ImageId?.Replace("spotify:",""); |
|
|
|
var timestamps = model.Timestamps.IsSpecified ? model.Timestamps.Value.ToEntity() : null; |
|
|
|
return new SpotifyGame |
|
|
|
{ |
|
|
|
Name = model.Name, |
|
|
|
SessionId = model.SessionId.GetValueOrDefault(), |
|
|
|
SyncId = model.SyncId.Value, |
|
|
|
AlbumTitle = albumText, |
|
|
|
TrackTitle = model.Details.GetValueOrDefault(), |
|
|
|
Artists = model.State.GetValueOrDefault()?.Split(';'), |
|
|
|
Duration = timestamps?.End - timestamps?.Start, |
|
|
|
AlbumArt = albumArtId != null ? $"https://i.scdn.co/image/{albumArtId}" : null, |
|
|
|
Type = ActivityType.Listening |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
// Rich Game |
|
|
|
if (model.ApplicationId.IsSpecified) |
|
|
|
{ |
|
|
@@ -34,7 +55,7 @@ namespace Discord.WebSocket |
|
|
|
} |
|
|
|
|
|
|
|
// (Small, Large) |
|
|
|
public static GameAsset[] ToEntity(this API.GameAssets model, ulong appId) |
|
|
|
public static GameAsset[] ToEntity(this API.GameAssets model, ulong? appId = null) |
|
|
|
{ |
|
|
|
return new GameAsset[] |
|
|
|
{ |
|
|
|