go: discord/backend: Add temporary workaround to discordgo's duplication issue

master
Luther Wen Xu 2019-10-19 22:54:18 +07:00
parent b6feb6a0a2
commit 0bec62f96c
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 11 additions and 1 deletions

@ -24,7 +24,17 @@ func GetAllMembers(s *discordgo.Session) ([]*discordgo.Member, error) {
if err != nil {
return nil, err
}
return guild.Members, nil
//TODO Deduplication hack until discordgo fixes this.
deduplicationCache := make(map[string]bool)
dedupedArray := make([]*discordgo.Member, 0)
for _, v := range guild.Members {
if deduplicationCache[v.User.ID] {
continue
}
dedupedArray = append(dedupedArray, v)
deduplicationCache[v.User.ID] = true
}
return dedupedArray, nil
}
func GetMemberFromUserFriendlyName(s *discordgo.Session, user string) (*discordgo.Member, error) {