Add InviteComplex (#1163)
* feat: implement InviteComplex * fix: typo * fix(rest#InviteComplex): guildScheduledEventID
This commit is contained in:
parent
eda859edc9
commit
9dc4ac5cac
1 changed files with 31 additions and 0 deletions
31
restapi.go
31
restapi.go
|
@ -1992,6 +1992,37 @@ func (s *Session) InviteWithCounts(inviteID string) (st *Invite, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// InviteComplex returns an Invite structure of the given invite including specified fields.
|
||||
// inviteID : The invite code
|
||||
// guildScheduledEventID : If specified, includes specified guild scheduled event.
|
||||
// withCounts : Whether to include approximate member counts or not
|
||||
// withExpiration : Whether to include expiration time or not
|
||||
func (s *Session) InviteComplex(inviteID, guildScheduledEventID string, withCounts, withExpiration bool) (st *Invite, err error) {
|
||||
endpoint := EndpointInvite(inviteID)
|
||||
v := url.Values{}
|
||||
if guildScheduledEventID != "" {
|
||||
v.Set("guild_scheduled_event_id", guildScheduledEventID)
|
||||
}
|
||||
if withCounts {
|
||||
v.Set("with_counts", "true")
|
||||
}
|
||||
if withExpiration {
|
||||
v.Set("with_expiration", "true")
|
||||
}
|
||||
|
||||
if len(v) != 0 {
|
||||
endpoint += "?" + v.Encode()
|
||||
}
|
||||
|
||||
body, err := s.RequestWithBucketID("GET", endpoint, nil, EndpointInvite(""))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = unmarshal(body, &st)
|
||||
return
|
||||
}
|
||||
|
||||
// InviteDelete deletes an existing invite
|
||||
// inviteID : the code of an invite
|
||||
func (s *Session) InviteDelete(inviteID string) (st *Invite, err error) {
|
||||
|
|
Loading…
Reference in a new issue