From aed0d6dab77b4b708fc34458547f2c4f08ef706f Mon Sep 17 00:00:00 2001 From: "Wesley Pyburn (TechNobo)" <10319195+TcNobo@users.noreply.github.com> Date: Thu, 26 May 2022 21:06:23 +0200 Subject: [PATCH] Hotfix for crash on Discord RPC off - Fixed crash when Discord RPC is turned off. --- TcNo-Acc-Switcher-Globals/Globals.cs | 2 +- TcNo-Acc-Switcher-Server/Data/AppData.cs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/TcNo-Acc-Switcher-Globals/Globals.cs b/TcNo-Acc-Switcher-Globals/Globals.cs index bbfffb270..c53c4b91e 100644 --- a/TcNo-Acc-Switcher-Globals/Globals.cs +++ b/TcNo-Acc-Switcher-Globals/Globals.cs @@ -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 diff --git a/TcNo-Acc-Switcher-Server/Data/AppData.cs b/TcNo-Acc-Switcher-Server/Data/AppData.cs index e6846614d..724e585c8 100644 --- a/TcNo-Acc-Switcher-Server/Data/AppData.cs +++ b/TcNo-Acc-Switcher-Server/Data/AppData.cs @@ -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); }; @@ -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; }