Преглед изворни кода

Merge branch 'main' of https://github.com/rigormorrtiss/discordo

rigormorrtiss пре 4 година
родитељ
комит
7f949d2143
2 измењених фајлова са 17 додато и 0 уклоњено
  1. BIN
      .github/preview.png
  2. 17 0
      discordo.go

BIN
.github/preview.png


+ 17 - 0
discordo.go

@@ -128,6 +128,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).