Skip to content

Commit

Permalink
potential fix for crashes during song requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Inzaniity committed Aug 1, 2024
1 parent 2996855 commit c17660d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
30 changes: 15 additions & 15 deletions Songify Slim/Util/General/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,22 @@ public static void LogExc(Exception exception)
// ignored
}
}
public static void LogStr(string s)
{
AppendConsole(s);

// Writes a log file with exceptions in it
string logFile = GetLogFilePath();
try
{
File.AppendAllText(logFile, DateTime.Now.ToString("HH:mm:ss") + @": " + s + Environment.NewLine);
//Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss") + @": " + s);
}
catch
{
// ignored
}
}
private static void AppendConsole(string s)
{
if (s == null) return;
Expand Down Expand Up @@ -148,21 +163,6 @@ private static Color GetForegroundColor(string s)
return Colors.White;
}

public static void LogStr(string s)
{
AppendConsole(s);

// Writes a log file with exceptions in it
string logFile = GetLogFilePath();
try
{
File.AppendAllText(logFile, DateTime.Now.ToString("HH:mm:ss") + @": " + s + Environment.NewLine);
//Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss") + @": " + s);
}
catch
{
// ignored
}
}
}
}
4 changes: 3 additions & 1 deletion Songify Slim/Util/Songify/TwitchHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1754,9 +1754,11 @@ private static string CreateSuccessResponse(FullTrack track, string displayName)
{
string response = Settings.Settings.BotRespSuccess;
string artists = "";
string singleArtist = "";
try
{
artists = string.Join(", ", track.Artists.Select(o => o.Name).ToList());
singleArtist = track.Artists.FirstOrDefault()?.Name;
}
catch (Exception e)
{
Expand All @@ -1766,7 +1768,7 @@ private static string CreateSuccessResponse(FullTrack track, string displayName)

response = response.Replace("{user}", displayName);
response = response.Replace("{artist}", artists);
response = response.Replace("{single_artist}", track.Artists.FirstOrDefault()?.Name);
response = response.Replace("{single_artist}", singleArtist);
response = response.Replace("{title}", track.Name);
response = response.Replace("{maxreq}", "");
response = response.Replace("{position}", $"{GlobalObjects.ReqList.Count}");
Expand Down

0 comments on commit c17660d

Please sign in to comment.