The application now loads more than jsut the first 100 guilds.
MODIFY
internal/discordgoplus/guilds.go
internal/discordgoplus/guilds.go
@@ -6,6 +6,29 @@ import (
"github.com/Bios-Marcel/discordgo"
)
+func LoadGuilds(session *discordgo.Session) ([]*discordgo.UserGuild, error) {
+ guilds := make([]*discordgo.UserGuild, 0)
+ var beforeID string
+
+ for {
+ newGuilds, discordError := session.UserGuilds(100, beforeID, "")
+ if discordError != nil {
+ return nil, discordError
+ }
+
+ if len(newGuilds) != 0 {
+ guilds = append(newGuilds, guilds...)
+ if len(newGuilds) == 100 {
+ beforeID = newGuilds[0].ID
+ } else {
+ return guilds, nil
+ }
+ } else {
+ return guilds, nil
+ }
+ }
+}
+
// 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 {

MODIFY
internal/ui/window.go
internal/ui/window.go
@@ -105,8 +105,7 @@ func NewWindow(app *tview.Application, discord *discordgo.Session) (*Window, err
return nil, err
}
- //FIXME Bug: If you are in more than 100 guilds, you won't see a lot of them!
- guilds, discordError := discord.UserGuilds(100, "", "")
+ guilds, discordError := discordgoplus.LoadGuilds(window.session)
if discordError != nil {
return nil, discordError
}

The application now loads more than jsut the first 100 guilds.