feat: added discord rich presence
This commit is contained in:
parent
fd6d1830c5
commit
b9672f82d6
2 changed files with 16 additions and 1 deletions
16
Program.cs
16
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<string>());
|
||||
}
|
||||
|
@ -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();
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net.Labs" Version="3.5.0" />
|
||||
<PackageReference Include="DiscordRichPresence" Version="1.0.175" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
|
|
Reference in a new issue