Skip to content

Commit

Permalink
A try to fix bot scrobbling (I have no idea what I do here)
Browse files Browse the repository at this point in the history
  • Loading branch information
fb-sean authored Dec 8, 2024
1 parent 696155c commit 08c5c29
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/FMBot.Bot/Models/MusicBot/BettyMusicBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,16 @@ public override string GetTrackQuery(IUserMessage msg)
{
var description = msg.Embeds.First().Description;

// Find the index of the newline character and truncate the string if it exists because this would display the next song which we dont need.
int newlineIndex = description.IndexOf('\n');
if (newlineIndex != -1)
{
description = description.Substring(0, newlineIndex);
}

// Find the start and end indices of the song info within **[ ]**.
int startIndex = description.IndexOf("**[", StringComparison.Ordinal) + 3;
int endIndex = description.IndexOf("](", StringComparison.Ordinal);
// Look for the start and end indices of the song info within **SONGTITLE - AUTHOR**.
int startIndex = description.IndexOf("Now Playing **", StringComparison.Ordinal) + "Now Playing **".Length;
int endIndex = description.IndexOf("**", startIndex, StringComparison.Ordinal);

if (startIndex < 0 || endIndex < 0 || endIndex <= startIndex)
if (startIndex < "Now Playing **".Length || endIndex < 0 || endIndex <= startIndex)
{
return string.Empty;
}

// Extract the song info "SONGTITLE - AUTHOR".
var songByArtist = description.Substring(startIndex, endIndex - startIndex);
return songByArtist;
}
Expand Down

0 comments on commit 08c5c29

Please sign in to comment.