diff --git a/GoBot/discord/backend/members.go b/GoBot/discord/backend/members.go index 38f088d..0a4af6c 100644 --- a/GoBot/discord/backend/members.go +++ b/GoBot/discord/backend/members.go @@ -12,24 +12,12 @@ import ( var ErrMemberNotFound = errors.New("discord/backend: the requested member was not found") func GetAllMembers(s *discordgo.Session) ([]*discordgo.Member, error) { - initial, err := s.GuildMembers(config.GuildID, "", 1000) - if err != nil { - return nil, err - } - next := initial[len(initial)-1].User.ID - for next != "" { - nextArray, err := s.GuildMembers(config.GuildID, next, 1000) - if err != nil { - return nil, err - } - if len(nextArray) == 0 { - next = "" - } else { - next = nextArray[len(nextArray)-1].User.ID - initial = append(initial, nextArray...) + for _, guild := range s.State.Guilds { + if guild.ID == config.GuildID { + return guild.Members, nil } } - return initial, nil + return nil, ErrMemberNotFound } func GetMemberFromUserFriendlyName(s *discordgo.Session, user string) (*discordgo.Member, error) { diff --git a/GoBot/discord/discord.go b/GoBot/discord/discord.go index 634bb7d..101bed1 100644 --- a/GoBot/discord/discord.go +++ b/GoBot/discord/discord.go @@ -19,6 +19,7 @@ func StartBot(token string, kill chan bool) { dg.AddHandler(ProcessCommand) dg.AddHandler(modules.CheckForReact) dg.AddHandler(modules.CheckForVote) + dg.StateEnabled = true if err := dg.Open(); err != nil { panic(err)