Archived
0
0
Fork 0

feat: sorted channels by category

This commit is contained in:
Daryl Ronningen 2021-12-16 15:58:32 -07:00
parent d59c0181fa
commit 5be86f13f4
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
2 changed files with 35 additions and 7 deletions

View file

@ -5,6 +5,7 @@ using Discord.WebSocket;
using Microsoft.Extensions.Configuration;
using RestSharp;
using Terminal.Gui;
using Terminal.Gui.Trees;
using Attribute = Terminal.Gui.Attribute;
using Color = Terminal.Gui.Color;
@ -98,7 +99,7 @@ namespace chord
serverListList.SetSource(guildNames);
var channelListList = new ListView
var channelListTree = new TreeView
{
X = 0,
Y = 0,
@ -143,12 +144,39 @@ namespace chord
var channelNames = guilds.GetValueOrDefault(currentSelectedGuild)!
.Select(channel => client.GetGuild(currentSelectedGuild).GetTextChannel(channel).Name).ToList();
channelListList.SetSource(channelNames);
var categoryDict = new SortedDictionary<ulong, TreeNode>();
foreach (var categories in client.GetGuild(currentSelectedGuild).CategoryChannels)
{
var node = new TreeNode(categories.Name);
foreach(var channel in categories.Channels)
{
if (channel.GetType().Name == "SocketTextChannel")
{
var channelNode = new TreeNode(channel.Name);
channelNode.Tag = new { Id = channel.Id };
node.Children.Add(channelNode);
}
}
categoryDict.Add(categories.Id, node);
}
foreach (var category in categoryDict)
{
channelListTree.AddObject(category.Value);
}
};
channelListList.OpenSelectedItem += async args =>
channelListTree.SelectionChanged += async (arg1, arg2) =>
{
currentSelectedChannel = guilds.GetValueOrDefault(currentSelectedGuild)!.ToList()[args.Item];
try {
currentSelectedChannel = (ulong)arg2.NewValue.Tag.GetType().GetProperty("Id").GetValue(arg2.NewValue.Tag);
} catch {
return;
}
var restSharpClient = new RestClient("https://discord.com/api/v9");
var restSharpReq = new RestRequest($"channels/{currentSelectedChannel}/messages");
@ -233,7 +261,7 @@ namespace chord
serverListList.SetFocus();
break;
case Key.CtrlMask | Key.C:
channelListList.SetFocus();
channelListTree.SetFocus();
break;
case Key.CtrlMask | Key.AltMask | Key.C:
chatBoxList.SetFocus();
@ -257,7 +285,7 @@ namespace chord
Application.Top.Add(window, menuBar);
window.Add(serverList, channelList, messageBox, chatBox, userList);
serverList.Add(serverListList);
channelList.Add(channelListList);
channelList.Add(channelListTree);
chatBox.Add(chatBoxList);
messageBox.Add(messageBoxText, messageBoxSend);
userList.Add(userListList);

2
TODO
View file

@ -1,7 +1,7 @@
- Figure out how to bypass discord intents for user list (Currently just using Discord.NET cache)
- Message Conversion
- Convert message attachments to links (DONE)
- Sort Channels by catagories
- Sort Channels by catagories (DONE)
- DMs
- Loading Screen
- Hotkeys (Partially Done. Still some weird stuff that happens that idfk why happens)