forked from pothtonswer/discordmuffin
Updated userguilds to new api (#296)
* Updated userguilds to new api * Fixed typos
This commit is contained in:
parent
8b24e88bc5
commit
86a21ea94b
2 changed files with 24 additions and 3 deletions
25
restapi.go
25
restapi.go
|
@ -370,9 +370,30 @@ func (s *Session) UserChannelCreate(recipientID string) (st *Channel, err error)
|
|||
}
|
||||
|
||||
// UserGuilds returns an array of UserGuild structures for all guilds.
|
||||
func (s *Session) UserGuilds() (st []*UserGuild, err error) {
|
||||
// limit : The number guilds that can be returned. (max 100)
|
||||
// beforeID : If provided all guilds returned will be before given ID.
|
||||
// afterID : If provided all guilds returned will be after given ID.
|
||||
func (s *Session) UserGuilds(limit int, beforeID, afterID string) (st []*UserGuild, err error) {
|
||||
|
||||
body, err := s.RequestWithBucketID("GET", EndpointUserGuilds("@me"), nil, EndpointUserGuilds(""))
|
||||
v := url.Values{}
|
||||
|
||||
if limit > 0 {
|
||||
v.Set("limit", strconv.Itoa(limit))
|
||||
}
|
||||
if afterID != "" {
|
||||
v.Set("after", afterID)
|
||||
}
|
||||
if beforeID != "" {
|
||||
v.Set("before", beforeID)
|
||||
}
|
||||
|
||||
uri := EndpointUserGuilds("@me")
|
||||
|
||||
if len(v) > 0 {
|
||||
uri = fmt.Sprintf("%s?%s", uri, v.Encode())
|
||||
}
|
||||
|
||||
body, err := s.RequestWithBucketID("GET", uri, nil, EndpointUserGuilds(""))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ func TestUserGuilds(t *testing.T) {
|
|||
t.Skip("Cannot TestUserGuilds, dg not set.")
|
||||
}
|
||||
|
||||
_, err := dg.UserGuilds()
|
||||
_, err := dg.UserGuilds(10, "", "")
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue