Archived
0
0
Fork 0

feat: sorted users by role

This commit is contained in:
Daryl Ronningen 2021-12-16 18:44:44 -07:00
parent 5be86f13f4
commit dc416c085c
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
2 changed files with 22 additions and 6 deletions

View file

@ -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<int, TreeNode>();
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;
};

1
TODO
View file

@ -5,3 +5,4 @@
- DMs
- Loading Screen
- Hotkeys (Partially Done. Still some weird stuff that happens that idfk why happens)
- User roles sorting (DONE)