Added Guild Members Search Function (#1150)
* Added Guild Members Search Function * Updated method name to be consistent with other endpoints * Refactored and moved GuildMembersSearch method for consistency
This commit is contained in:
parent
4ef1d502cd
commit
7e3d187823
2 changed files with 24 additions and 0 deletions
|
@ -72,6 +72,7 @@ var (
|
|||
EndpointGuildPreview = func(gID string) string { return EndpointGuilds + gID + "/preview" }
|
||||
EndpointGuildChannels = func(gID string) string { return EndpointGuilds + gID + "/channels" }
|
||||
EndpointGuildMembers = func(gID string) string { return EndpointGuilds + gID + "/members" }
|
||||
EndpointGuildMembersSearch = func(gID string) string { return EndpointGuildMembers(gID) + "/search" }
|
||||
EndpointGuildMember = func(gID, uID string) string { return EndpointGuilds + gID + "/members/" + uID }
|
||||
EndpointGuildMemberRole = func(gID, uID, rID string) string { return EndpointGuilds + gID + "/members/" + uID + "/roles/" + rID }
|
||||
EndpointGuildBans = func(gID string) string { return EndpointGuilds + gID + "/bans" }
|
||||
|
|
23
restapi.go
23
restapi.go
|
@ -696,6 +696,29 @@ func (s *Session) GuildMembers(guildID string, after string, limit int) (st []*M
|
|||
return
|
||||
}
|
||||
|
||||
// GuildMembersSearch returns a list of guild member objects whose username or nickname starts with a provided string
|
||||
// guildID : The ID of a Guild
|
||||
// query : Query string to match username(s) and nickname(s) against
|
||||
// limit : Max number of members to return (default 1, min 1, max 1000)
|
||||
func (s *Session) GuildMembersSearch(guildID, query string, limit int) (st []*Member, err error) {
|
||||
|
||||
uri := EndpointGuildMembersSearch(guildID)
|
||||
|
||||
queryParams := url.Values{}
|
||||
queryParams.Set("query", query)
|
||||
if limit > 1 {
|
||||
queryParams.Set("limit", strconv.Itoa(limit))
|
||||
}
|
||||
|
||||
body, err := s.RequestWithBucketID("GET", uri+"?"+queryParams.Encode(), nil, uri)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = unmarshal(body, &st)
|
||||
return
|
||||
}
|
||||
|
||||
// GuildMember returns a member of a guild.
|
||||
// guildID : The ID of a Guild.
|
||||
// userID : The ID of a User
|
||||
|
|
Loading…
Reference in a new issue