Skip to content

Commit

Permalink
fix: add missing properties and update playerUpdate object
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Jan 22, 2025
1 parent 22f09ed commit 829d290
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 17 deletions.
6 changes: 6 additions & 0 deletions DisCatSharp.Lavalink/Entities/LavalinkTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public sealed class LavalinkTrack
/// </summary>
[JsonProperty("pluginInfo")]
public LavalinkPluginInfo PluginInfo { get; internal set; }

/// <summary>
/// Gets the user info.
/// </summary>
[JsonProperty("userData")]
public object? UserData { get; internal set; }
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion DisCatSharp.Lavalink/LavalinkGuildPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ public async Task<LavalinkGuildPlayer> UpdateAsync(Action<LavalinkPlayerUpdateMo
mdl.EncodedTrack, mdl.Identifier,
mdl.Position, mdl.EndTime,
mdl.Volume, mdl.Paused,
mdl.Filters
mdl.Filters,
mdl.UserData
).ConfigureAwait(false);
return this;
}
Expand Down
16 changes: 12 additions & 4 deletions DisCatSharp.Lavalink/LavalinkRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,26 +297,34 @@ internal async Task<LavalinkPlayer> GetPlayerAsync(string sessionId, ulong guild
/// <param name="volume">The volume.</param>
/// <param name="paused">Whether to pause the track.</param>
/// <param name="filters">The filters.</param>
/// <param name="userData">The user data.</param>
/// <returns>The updated <see cref="LavalinkPlayer" /> object.</returns>
internal async Task<LavalinkPlayer> UpdatePlayerAsync(
string sessionId,
ulong guildId,
bool noReplace = false,
Optional<string?> encodedTrack = default,
Optional<string> identifier = default,
Optional<string?> identifier = default,
Optional<int> position = default,
Optional<int?> endTime = default,
Optional<int> volume = default,
Optional<bool> paused = default,
Optional<LavalinkFilters> filters = default
Optional<LavalinkFilters> filters = default,
Optional<object?> userData = default
)
{
var queryDict = this.GetDefaultParams();
queryDict.Add("noReplace", noReplace.ToString().ToLower());
var pld = new LavalinkRestPlayerUpdatePayload(guildId.ToString())
{
EncodedTrack = encodedTrack,
Identifier = identifier,
Track = encodedTrack.HasValue || identifier.HasValue
? new LavalinkRestPlayerUpdatePlayerTrackPayload()
{
Encoded = encodedTrack,
Identifier = identifier,
UserData = userData
}
: Optional.None,
Position = position,
EndTime = endTime,
Volume = volume,
Expand Down
6 changes: 6 additions & 0 deletions DisCatSharp.Lavalink/Models/LavalinkPlayerUpdateModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@ internal LavalinkPlayerUpdateModel()
/// </summary>
[JsonProperty("filters")]
public Optional<LavalinkFilters> Filters { internal get; set; }

/// <summary>
/// Gets or sets the user data.
/// </summary>
[JsonProperty("userData")]
public Optional<object?> UserData { get; set; }
}
42 changes: 30 additions & 12 deletions DisCatSharp.Lavalink/Payloads/LavalinkRestPlayerUpdatePayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ internal LavalinkRestPlayerUpdatePayload(string guildId)
[JsonProperty("guildId")]
internal string GuildId { get; set; }

/// <summary>
/// Gets or sets the encoded track.
/// </summary>
[JsonProperty("encodedTrack")]
internal Optional<string?> EncodedTrack { get; set; }

/// <summary>
/// Gets or sets the identifier.
/// </summary>
[JsonProperty("identifier")]
internal Optional<string> Identifier { get; set; }

/// <summary>
/// Gets or sets the start or seek position.
/// </summary>
Expand Down Expand Up @@ -66,4 +54,34 @@ internal LavalinkRestPlayerUpdatePayload(string guildId)
/// </summary>
[JsonProperty("filters")]
internal Optional<LavalinkFilters> Filters { get; set; }

/// <summary>
/// Gets or sets the track.
/// </summary>
[JsonProperty("track")]
internal Optional<LavalinkRestPlayerUpdatePlayerTrackPayload> Track { get; set; }
}

/// <summary>
/// The lavalink rest player update player track payload.
/// </summary>
internal sealed class LavalinkRestPlayerUpdatePlayerTrackPayload
{
/// <summary>
/// Gets or sets the encoded track.
/// </summary>
[JsonProperty("encoded")]
internal Optional<string?> Encoded { get; set; }

/// <summary>
/// Gets or sets the identifier.
/// </summary>
[JsonProperty("identifier")]
internal Optional<string?> Identifier { get; set; }

/// <summary>
/// Gets or sets the user data.
/// </summary>
[JsonProperty("userData")]
public Optional<object?> UserData { get; set; }
}

0 comments on commit 829d290

Please sign in to comment.