|
|
|
@ -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
|
|
|
|
|
for _, guild := range s.State.Guilds {
|
|
|
|
|
if guild.ID == config.GuildID {
|
|
|
|
|
return guild.Members, nil
|
|
|
|
|
}
|
|
|
|
|
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...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return initial, nil
|
|
|
|
|
return nil, ErrMemberNotFound
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetMemberFromUserFriendlyName(s *discordgo.Session, user string) (*discordgo.Member, error) {
|
|
|
|
|