Browse Source

Initial commit

pull/1039/head
Still Hsu 7 years ago
parent
commit
384b14a84b
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
2 changed files with 8 additions and 5 deletions
  1. +3
    -3
      src/Discord.Net.Core/Entities/Activities/SpotifyGame.cs
  2. +5
    -2
      src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs

+ 3
- 3
src/Discord.Net.Core/Entities/Activities/SpotifyGame.cs View File

@@ -7,17 +7,17 @@ namespace Discord
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SpotifyGame : Game public class SpotifyGame : Game
{ {
public IEnumerable<string> Artists { get; internal set; }
public IReadOnlyCollection<string> Artists { get; internal set; }
public string AlbumArt { get; internal set; } public string AlbumArt { get; internal set; }
public string AlbumTitle { get; internal set; } public string AlbumTitle { get; internal set; }
public string TrackTitle { get; internal set; } public string TrackTitle { get; internal set; }
public string SyncId { get; internal set; }
public string TrackId { get; internal set; }
public string SessionId { get; internal set; } public string SessionId { get; internal set; }
public TimeSpan? Duration { get; internal set; } public TimeSpan? Duration { get; internal set; }


internal SpotifyGame() { } internal SpotifyGame() { }


public override string ToString() => Name;
public override string ToString() => $"{string.Join(", ", Artists)} - {TrackTitle} ({Duration})";
private string DebuggerDisplay => $"{Name} (Spotify)"; private string DebuggerDisplay => $"{Name} (Spotify)";
} }
} }

+ 5
- 2
src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs View File

@@ -1,3 +1,6 @@
using System.Collections.Immutable;
using System.Linq;

namespace Discord.WebSocket namespace Discord.WebSocket
{ {
internal static class EntityExtensions internal static class EntityExtensions
@@ -15,10 +18,10 @@ namespace Discord.WebSocket
{ {
Name = model.Name, Name = model.Name,
SessionId = model.SessionId.GetValueOrDefault(), SessionId = model.SessionId.GetValueOrDefault(),
SyncId = model.SyncId.Value,
TrackId = model.SyncId.Value,
AlbumTitle = albumText, AlbumTitle = albumText,
TrackTitle = model.Details.GetValueOrDefault(), TrackTitle = model.Details.GetValueOrDefault(),
Artists = model.State.GetValueOrDefault()?.Split(';'),
Artists = model.State.GetValueOrDefault()?.Split(';').Select(x=>x?.Trim()).ToImmutableArray(),
Duration = timestamps?.End - timestamps?.Start, Duration = timestamps?.End - timestamps?.Start,
AlbumArt = albumArtId != null ? CDN.GetSpotifyAlbumArtUrl(albumArtId) : null, AlbumArt = albumArtId != null ? CDN.GetSpotifyAlbumArtUrl(albumArtId) : null,
Type = ActivityType.Listening Type = ActivityType.Listening


Loading…
Cancel
Save