From aa104a9660d691131d5b9412a695d4bfb136b417 Mon Sep 17 00:00:00 2001 From: u4pak Date: Sun, 28 Jan 2024 12:07:22 -0800 Subject: [PATCH] discord rpc --- Partypacker/MainWindow.xaml.cs | 45 +++++++++++++++++++++++++++++++++- Partypacker/Partypacker.csproj | 1 + 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/Partypacker/MainWindow.xaml.cs b/Partypacker/MainWindow.xaml.cs index 795c07c..58551a7 100644 --- a/Partypacker/MainWindow.xaml.cs +++ b/Partypacker/MainWindow.xaml.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json; +using DiscordRPC; +using DiscordRPC.Logging; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Partypacker.Core; using Partypacker.Net; @@ -34,6 +36,7 @@ namespace Partypacker public MainWindow() { InitializeComponent(); + InitializeRPC(); Application.Current.Exit += OnApplicationExit; var DiscordURL = PartypackServer.GET("/api/discord/url"); @@ -207,5 +210,45 @@ namespace Partypacker Regex regex = new Regex("[^0-9]+"); e.Handled = regex.IsMatch(e.Text); } + + public DiscordRpcClient client; + void InitializeRPC() + { + client = new DiscordRpcClient("1198605718169858088"); + + client.Logger = new ConsoleLogger() { Level = LogLevel.Warning }; + + client.OnReady += (sender, e) => + { + Console.WriteLine("Received Ready from user {0}", e.User.Username); + }; + + client.OnPresenceUpdate += (sender, e) => + { + Console.WriteLine("Received Update! {0}", e.Presence); + }; + + client.Initialize(); + + client.SetPresence(new RichPresence() + { + Details = "Modding Fortnite Festival", + State = "Loading Custom Tracks", + Timestamps = new DiscordRPC.Timestamps() + { + Start = DateTime.UtcNow, + }, + Assets = new Assets() + { + LargeImageKey = "logo", + LargeImageText = "Partypacker - Alpha", + //SmallImageKey = "image_small" + }, + Buttons = new DiscordRPC.Button[] + { + new DiscordRPC.Button() {Label = "Check out Partypack!", Url = "https://partypack.mcthe.dev/"} + } + }); + } } } \ No newline at end of file diff --git a/Partypacker/Partypacker.csproj b/Partypacker/Partypacker.csproj index e80e321..73fc337 100644 --- a/Partypacker/Partypacker.csproj +++ b/Partypacker/Partypacker.csproj @@ -23,6 +23,7 @@ +