feat(rest): add pagination params for GuildBans

This commit is contained in:
nitroflap 2022-04-01 00:08:25 +03:00
parent 9356a844d9
commit 4637c5b7e8
No known key found for this signature in database
GPG key ID: 810F53DB0E0F81A8

View file

@ -577,12 +577,30 @@ func (s *Session) GuildLeave(guildID string) (err error) {
return
}
// GuildBans returns an array of GuildBan structures for all bans of a
// given guild.
// guildID : The ID of a Guild.
func (s *Session) GuildBans(guildID string) (st []*GuildBan, err error) {
// GuildBans returns an array of GuildBan structures for bans in the given guild.
// guildID : The ID of a Guild
// limit : Max number of bans to return (max 1000)
// beforeID : If not empty all returned users will be after the given id
// afterID : If not empty all returned users will be before the given id
func (s *Session) GuildBans(guildID string, limit int, beforeID, afterID string) (st []*GuildBan, err error) {
uri := EndpointGuildBans(guildID)
body, err := s.RequestWithBucketID("GET", EndpointGuildBans(guildID), nil, EndpointGuildBans(guildID))
v := url.Values{}
if limit != 0 {
v.Set("limit", strconv.Itoa(limit))
}
if beforeID != "" {
v.Set("before", beforeID)
}
if afterID != "" {
v.Set("after", afterID)
}
if len(v) > 0 {
uri += "?" + v.Encode()
}
body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildBans(guildID))
if err != nil {
return
}