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:
@@ -1,4 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
src/Discord.Net.Core/Entities/Activities/SpotifyGame.cs
Normal file
23
src/Discord.Net.Core/Entities/Activities/SpotifyGame.cs
Normal 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)";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user