Sort guilds based on their respective position (#36)
* Sort guilds based on their respective position * Update README preview
This commit is contained in:
parent
efb9097eda
commit
9a2bc80e8d
2 changed files with 17 additions and 0 deletions
BIN
.github/preview.png
vendored
BIN
.github/preview.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 223 KiB After Width: | Height: | Size: 192 KiB |
17
discordo.go
17
discordo.go
|
|
@ -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).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue