Add Spotify track support (#970)

* Initial Spotify support

* Remove GameAsset#ToEntity

- appId doesn't seem to be necessary, and Spotify Game doesn't return appId either.

* Implement SpotifyGame details

* Implement song Duration prop

* Add album art CDN

* Fix ActivityType

* Remove payload debug

* Add changes according to review

+ Make `ApplicationId` nullable
+ Move ctor after props
This commit is contained in:
Still Hsu
2018-03-19 04:06:53 +08:00
committed by Christopher F
parent b9be6deb4f
commit 64b9cc7a53
6 changed files with 59 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
namespace Discord
{

View File

@@ -1,15 +1,15 @@
namespace Discord
namespace Discord
{
public class GameAsset
{
internal GameAsset() { }
internal ulong ApplicationId { get; set; }
internal ulong? ApplicationId { get; set; }
public string Text { get; internal set; }
public string ImageId { get; internal set; }
public string GetImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128)
=> CDN.GetRichAssetUrl(ApplicationId, ImageId, size, format);
=> ApplicationId.HasValue ? CDN.GetRichAssetUrl(ApplicationId.Value, ImageId, size, format) : null;
}
}
}

View File

@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
namespace Discord
{
@@ -7,8 +7,8 @@ namespace Discord
{
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 GameAsset SmallAsset { get; internal set; }
public GameAsset LargeAsset { get; internal set; }
@@ -19,4 +19,4 @@ namespace Discord
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} (Rich)";
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Discord
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SpotifyGame : Game
{
public string[] Artists { get; internal set; }
public string AlbumArt { get; internal set; }
public string AlbumTitle { get; internal set; }
public string TrackTitle { get; internal set; }
public string SyncId { get; internal set; }
public string SessionId { get; internal set; }
public TimeSpan? Duration { get; internal set; }
internal SpotifyGame() { }
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} (Spotify)";
}
}