Sort guilds based on their respective position (#36)

* Sort guilds based on their respective position

* Update README preview
This commit is contained in:
rigormorrtiss 2021-08-24 23:24:51 +04:00 • committed by GitHub
parent efb9097eda
commit 9a2bc80e8d
2 changed files with 17 additions and 0 deletions

BIN
.github/preview.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 KiB

After

Width:  |  Height:  |  Size: 192 KiB

View file

@ -126,6 +126,23 @@ func newSession() *discordgo.Session {
}
func onSessionReady(_ *discordgo.Session, r *discordgo.Ready) {
sort.Slice(r.Guilds, func(a, b int) bool {
found := false
for _, gID := range r.Settings.GuildPositions {
if found {
if gID == r.Guilds[b].ID {
return true
}
} else {
if gID == r.Guilds[a].ID {
found = true
}
}
}
return false
})
rootN := guildsTreeView.GetRoot()
for _, g := range r.Guilds {
gn := tview.NewTreeNode(g.Name).