Fix log spam by disabling Discord when callbacks fail

This commit is contained in:
NGnius (Graham) 2020-08-11 19:20:43 -04:00
parent c292f4e4a8
commit 83229c70d9

View file

@ -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 = "")