Guilds are now being sorted correctly.
ADD
internal/discordgoplus/guilds.go
+package discordgoplus
+
+import (
+ "sort"
+
+ "github.com/Bios-Marcel/discordgo"
+)
+
+// SortGuilds sorts the guilds according to the users settings.
+func SortGuilds(settings *discordgo.Settings, guilds []*discordgo.UserGuild) {
+ sort.Slice(guilds, func(a, b int) bool {
+ aFound := false
+ for _, guild := range settings.GuildPositions {
+ if aFound {
+ if guild == guilds[b].ID {
+ return true
+ }
+ } else {
+ if guild == guilds[a].ID {
+ aFound = true
+ }
+ }
+ }
+
+ return false
+ })
+}

MODIFY
internal/ui/window.go
internal/ui/window.go
@@ -168,6 +168,8 @@ func NewWindow(app *tview.Application, discord *discordgo.Session) (*Window, err
var selectedGuildNode *tview.TreeNode
+ discordgoplus.SortGuilds(window.session.State.Settings, guilds)
+
for _, tempGuild := range guilds {
guild := tempGuild
guildNode := tview.NewTreeNode(guild.Name)

Guilds are now being sorted correctly.