feature: add StartedAt, EndsAt, Elapsed and Remaining to SpotifyGame. (#1414)
* Fixed GetUsersAsync to use MaxUsersPerBatch const as limit instead of MaxMessagesPerBatch. Requests are now returning up to 1000 guild user entities instead of the previous 100. * Added StartedAt and EndsAt timespans for SpotifyGame. They make it possible to expose track's Elapsed and Remaining properties. * Moved Duration to be initialized within model construction. * Updated StartedAt and EndsAt comments.
This commit is contained in:
committed by
Christopher F
parent
e627f0780a
commit
2bba324143
@@ -31,6 +31,23 @@ namespace Discord
|
||||
/// A string containing the name of the song (e.g. <c>Lonely Together (feat. Rita Ora)</c>).
|
||||
/// </returns>
|
||||
public string TrackTitle { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date when the track started playing.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="DateTimeOffset"/> containing the start timestamp of the song.
|
||||
/// </returns>
|
||||
public DateTimeOffset? StartedAt { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date when the track ends.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="DateTimeOffset"/> containing the finish timestamp of the song.
|
||||
/// </returns>
|
||||
public DateTimeOffset? EndsAt { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the duration of the song.
|
||||
/// </summary>
|
||||
@@ -39,6 +56,22 @@ namespace Discord
|
||||
/// </returns>
|
||||
public TimeSpan? Duration { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the elapsed duration of the song.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="TimeSpan"/> containing the elapsed duration of the song.
|
||||
/// </returns>
|
||||
public TimeSpan? Elapsed => DateTimeOffset.UtcNow - StartedAt;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the remaining duration of the song.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="TimeSpan"/> containing the remaining duration of the song.
|
||||
/// </returns>
|
||||
public TimeSpan? Remaining => EndsAt - DateTimeOffset.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the track ID of the song.
|
||||
/// </summary>
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace Discord.WebSocket
|
||||
AlbumTitle = albumText,
|
||||
TrackTitle = model.Details.GetValueOrDefault(),
|
||||
Artists = model.State.GetValueOrDefault()?.Split(';').Select(x=>x?.Trim()).ToImmutableArray(),
|
||||
StartedAt = timestamps?.Start,
|
||||
EndsAt = timestamps?.End,
|
||||
Duration = timestamps?.End - timestamps?.Start,
|
||||
AlbumArtUrl = albumArtId != null ? CDN.GetSpotifyAlbumArtUrl(albumArtId) : null,
|
||||
Type = ActivityType.Listening,
|
||||
|
||||
Reference in New Issue
Block a user