From 83229c70d9cba1843799ec50e6a7bf6891bdf65a Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Tue, 11 Aug 2020 19:20:43 -0400 Subject: [PATCH] Fix log spam by disabling Discord when callbacks fail --- GameSDKcraft/Plugin.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/GameSDKcraft/Plugin.cs b/GameSDKcraft/Plugin.cs index f1ec486..c456515 100644 --- a/GameSDKcraft/Plugin.cs +++ b/GameSDKcraft/Plugin.cs @@ -246,7 +246,18 @@ namespace GamecraftRPC public void OnUpdate() // called once per rendered frame (frame update) { - if (DiscordRPC != null ) DiscordRPC.RunCallbacks(); + if (DiscordRPC != null) + { + try + { + DiscordRPC.RunCallbacks(); + } + catch (ResultException e) + { + GamecraftModdingAPI.Utility.Logging.LogWarning($"Discord integration has been disabled due to the exception " + e); + DiscordRPC = null; + } + } } public static void SetDiscordActivity(string state = null, string details = null, long start = 0, long end = 0, string largeImg = "gamecraft-logo-g", string largeTxt = "Gamecraft", string smallImg = "exmods-logo-xm2", string smallTxt = null, string partyId = null, int partyCurrentSize = 0, int partyMaxSize = 0, string matchSecret = null, string joinSecret = null, string spectateSecret = null, bool instance = true, string debug = "")