From 4b26fcdfe11a0e758348a28df0bf28e95ba1014f Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sat, 4 Jun 2022 22:20:23 +0200 Subject: [PATCH] Update RichPresence class --- .../Classes/Misc/RichPresenceClient.cs | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/MinecraftUSkinEditor/Classes/Misc/RichPresenceClient.cs b/MinecraftUSkinEditor/Classes/Misc/RichPresenceClient.cs index 8fa66b4d..f10c552b 100644 --- a/MinecraftUSkinEditor/Classes/Misc/RichPresenceClient.cs +++ b/MinecraftUSkinEditor/Classes/Misc/RichPresenceClient.cs @@ -7,38 +7,40 @@ namespace RichPresenceClient public static class RPC { - public static DiscordRpcClient client; + public static DiscordRpcClient client = null; public static void Initialize(string ClientID) { - //client = new DiscordRpcClient(ClientID); - //if (!client.Initialize()) - //{ - // throw new Exception("ERROR initializing Discord RPC"); - //} + client = new DiscordRpcClient(ClientID); + if (!client.Initialize()) + { + throw new Exception("ERROR initializing Discord RPC"); + } } public static void SetRPC(string details, string state, string imageLarge, string imageLargeText, string imageSmall) { - //if (client == null) return; - //client.SetPresence(new RichPresence() - //{ - // Details = details, - // State = state, - // Assets = new Assets() - // { - // LargeImageKey = imageLarge, - // LargeImageText = imageLargeText, - // SmallImageKey = imageSmall - // } - //}); + if (client == null) return; + client.SetPresence(new RichPresence() + { + Details = details, + State = state, + Assets = new Assets() + { + LargeImageKey = imageLarge, + LargeImageText = imageLargeText, + SmallImageKey = imageSmall + } + }); } public static void CloseRPC() { - //if (client != null) - // client.Deinitialize(); - // client.Dispose(); + if (client != null && client.IsInitialized) + { + client.Deinitialize(); + } + client.Dispose(); } }