Skip to content

Commit

Permalink
Hotfix for crash on Discord RPC off
Browse files Browse the repository at this point in the history
- Fixed crash when Discord RPC is turned off.
  • Loading branch information
TCNOco committed May 26, 2022
1 parent f754037 commit aed0d6d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion TcNo-Acc-Switcher-Globals/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class Globals
#pragma warning disable CA2211 // Non-constant fields should not be visible - This is necessary due to it being a launch parameter.
public static bool VerboseMode;
#pragma warning restore CA2211 // Non-constant fields should not be visible
public static readonly string Version = "2022-05-26_00";
public static readonly string Version = "2022-05-26_01";

#region INITIALISATION

Expand Down
12 changes: 8 additions & 4 deletions TcNo-Acc-Switcher-Server/Data/AppData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void FirstLaunchCheck()
new Thread(AppStats.UploadStats).Start();

// Discord integration
RefreshDiscordPresence();
RefreshDiscordPresenceAsync();

// Unused. Idk if I will use these, but they are here just in-case.
//DiscordClient.OnReady += (sender, e) => { Console.WriteLine("Received Ready from user {0}", e.User.Username); };
Expand All @@ -92,9 +92,13 @@ public static void RefreshDiscordPresence()

if (!AppSettings.DiscordRpc)
{
if (!DiscordClient.IsInitialized) return;
DiscordClient.Deinitialize();
DiscordClient = null;
if (DiscordClient != null)
{
if (!DiscordClient.IsInitialized) return;
DiscordClient.Deinitialize();
DiscordClient = null;
}

return;
}

Expand Down

0 comments on commit aed0d6d

Please sign in to comment.