diff --git a/Program.cs b/Program.cs index ad46b04..d5d369c 100644 --- a/Program.cs +++ b/Program.cs @@ -3,11 +3,13 @@ using System.Text; using System.Text.RegularExpressions; using Discord; using Discord.WebSocket; +using DiscordRPC; using Microsoft.Extensions.Configuration; using RestSharp; using Terminal.Gui; using Terminal.Gui.Trees; using Attribute = Terminal.Gui.Attribute; +using Button = Terminal.Gui.Button; using Color = Terminal.Gui.Color; namespace chord @@ -48,6 +50,10 @@ namespace chord await client.LoginAsync(TokenType.Bot, settings.Token); await client.StartAsync(); + var rpcClient = new DiscordRpcClient("923436807297859625"); + rpcClient.Initialize(); + rpcClient.SetPresence(new RichPresence()); + Application.Init(); window = new Window("chord") @@ -174,6 +180,8 @@ namespace chord { channelListTree.AddObject(category.Value); } + + rpcClient.UpdateDetails($"Chatting in {client.GetGuild(currentSelectedGuild).Name}"); }; channelListTree.SelectionChanged += async (arg1, arg2) => @@ -244,6 +252,9 @@ namespace chord { userListTree.AddObject(role.Value); } + + rpcClient.UpdateState($"In channel {client.GetGuild(currentSelectedGuild).GetTextChannel(currentSelectedChannel).Name}"); + rpcClient.UpdateStartTime(); } catch { await chatBoxList.SetSourceAsync(new List()); } @@ -340,7 +351,10 @@ namespace chord chatBoxList.SelectedItem = currentChannelMessages.Count - 1; }; - Application.MainLoop.AddTimeout(TimeSpan.FromMilliseconds(100), caller => true); + Application.MainLoop.AddTimeout(TimeSpan.FromMilliseconds(100), caller => { + rpcClient.Invoke(); + return true; + }); Application.Run(); Application.Shutdown(); diff --git a/chord.csproj b/chord.csproj index ef0e070..10244a7 100644 --- a/chord.csproj +++ b/chord.csproj @@ -23,6 +23,7 @@ +