From dc416c085ca37b6104044e331d74dffb71f82b5c Mon Sep 17 00:00:00 2001 From: Daryl Ronningen Date: Thu, 16 Dec 2021 18:44:44 -0700 Subject: [PATCH] feat: sorted users by role --- Program.cs | 27 +++++++++++++++++++++------ TODO | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Program.cs b/Program.cs index d645881..9638302 100644 --- a/Program.cs +++ b/Program.cs @@ -129,7 +129,7 @@ namespace chord Y = 0 }; - var userListList = new ListView + var userListTree = new TreeView { X = 0, Y = 0, @@ -216,9 +216,24 @@ namespace chord chatBoxList.ScrollDown(currentChannelMessages.Count - chatBoxList.Bounds.Height); chatBoxList.SelectedItem = currentChannelMessages.Count - 1; - await userListList.SetSourceAsync(client.GetGuild(currentSelectedGuild).GetTextChannel(currentSelectedChannel) - .Users - .ToList()); + var rolesDict = new SortedDictionary(); + + foreach (var roles in client.GetGuild(currentSelectedGuild).Roles) + { + var node = new TreeNode(roles.Name); + + foreach (var users in roles.Members) + { + node.Children.Add(new TreeNode($"{users.Username}#{users.Discriminator} ({users.Nickname})")); + } + + rolesDict.Add(roles.Position, node); + } + + foreach (var role in rolesDict) + { + userListTree.AddObject(role.Value); + } }; messageBoxSend.Clicked += async () => @@ -267,7 +282,7 @@ namespace chord chatBoxList.SetFocus(); break; case Key.CtrlMask | Key.U: - userListList.SetFocus(); + userListTree.SetFocus(); break; case Key.CtrlMask | Key.Enter: var restSharpClient = new RestClient("https://discord.com/api/v9"); @@ -288,7 +303,7 @@ namespace chord channelList.Add(channelListTree); chatBox.Add(chatBoxList); messageBox.Add(messageBoxText, messageBoxSend); - userList.Add(userListList); + userList.Add(userListTree); return Task.CompletedTask; }; diff --git a/TODO b/TODO index 5fadd6e..cb488d4 100644 --- a/TODO +++ b/TODO @@ -5,3 +5,4 @@ - DMs - Loading Screen - Hotkeys (Partially Done. Still some weird stuff that happens that idfk why happens) + - User roles sorting (DONE)