Skip to content

Commit

Permalink
Add failsafe if song is less than 5 seconds remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Sella-GH committed Jun 20, 2024
1 parent d00ad62 commit dc4bf1f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions AzzyBot-Next/Commands/AzuraCastCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ public async ValueTask SkipSongAsync
string baseUrl = Crypto.Decrypt(azuraCast.BaseUrl);

AzuraNowPlayingDataRecord nowPlaying = await _azuraCast.GetNowPlayingAsync(new(baseUrl), stationId);
if (nowPlaying.NowPlaying.Duration - nowPlaying.NowPlaying.Elapsed <= 5)
{
await context.EditResponseAsync("This song is almost over - please wait!");
return;
}

await _azuraCast.SkipSongAsync(new(baseUrl), apiKey, stationId);

await context.EditResponseAsync($"I skipped **{nowPlaying.NowPlaying.Song.Title}** by **{nowPlaying.NowPlaying.Song.Artist}**.");
Expand Down

0 comments on commit dc4bf1f

Please sign in to comment.