forked from pothtonswer/discordmuffin
feat(rest): add pagination params for GuildBans
This commit is contained in:
parent
9356a844d9
commit
4637c5b7e8
1 changed files with 23 additions and 5 deletions
28
restapi.go
28
restapi.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue