feat(UserGuilds)!: support with_counts parameter (#1500)
--------- Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>
This commit is contained in:
parent
202785c50b
commit
33ee38cbf2
3 changed files with 17 additions and 5 deletions
12
restapi.go
12
restapi.go
|
@ -424,10 +424,11 @@ func (s *Session) UserGuildMember(guildID string, options ...RequestOption) (st
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserGuilds returns an array of UserGuild structures for all guilds.
|
// UserGuilds returns an array of UserGuild structures for all guilds.
|
||||||
// limit : The number guilds that can be returned. (max 100)
|
// limit : The number guilds that can be returned. (max 200)
|
||||||
// beforeID : If provided all guilds returned will be before given ID.
|
// beforeID : If provided all guilds returned will be before given ID.
|
||||||
// afterID : If provided all guilds returned will be after given ID.
|
// afterID : If provided all guilds returned will be after given ID.
|
||||||
func (s *Session) UserGuilds(limit int, beforeID, afterID string, options ...RequestOption) (st []*UserGuild, err error) {
|
// withCounts : Whether to include approximate member and presence counts or not.
|
||||||
|
func (s *Session) UserGuilds(limit int, beforeID, afterID string, withCounts bool, options ...RequestOption) (st []*UserGuild, err error) {
|
||||||
|
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
|
|
||||||
|
@ -440,6 +441,9 @@ func (s *Session) UserGuilds(limit int, beforeID, afterID string, options ...Req
|
||||||
if beforeID != "" {
|
if beforeID != "" {
|
||||||
v.Set("before", beforeID)
|
v.Set("before", beforeID)
|
||||||
}
|
}
|
||||||
|
if withCounts {
|
||||||
|
v.Set("with_counts", "true")
|
||||||
|
}
|
||||||
|
|
||||||
uri := EndpointUserGuilds("@me")
|
uri := EndpointUserGuilds("@me")
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ func TestUserGuilds(t *testing.T) {
|
||||||
t.Skip("Cannot TestUserGuilds, dg not set.")
|
t.Skip("Cannot TestUserGuilds, dg not set.")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := dg.UserGuilds(10, "", "")
|
_, err := dg.UserGuilds(10, "", "", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf(err.Error())
|
t.Errorf(err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1274,6 +1274,14 @@ type UserGuild struct {
|
||||||
Owner bool `json:"owner"`
|
Owner bool `json:"owner"`
|
||||||
Permissions int64 `json:"permissions,string"`
|
Permissions int64 `json:"permissions,string"`
|
||||||
Features []GuildFeature `json:"features"`
|
Features []GuildFeature `json:"features"`
|
||||||
|
|
||||||
|
// Approximate number of members in this guild.
|
||||||
|
// NOTE: this field is only filled when withCounts is true.
|
||||||
|
ApproximateMemberCount int `json:"approximate_member_count"`
|
||||||
|
|
||||||
|
// Approximate number of non-offline members in this guild.
|
||||||
|
// NOTE: this field is only filled when withCounts is true.
|
||||||
|
ApproximatePresenceCount int `json:"approximate_presence_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuildFeature indicates the presence of a feature in a guild
|
// GuildFeature indicates the presence of a feature in a guild
|
||||||
|
|
Loading…
Reference in a new issue