Add InviteComplex (#1163)

* feat: implement InviteComplex

* fix: typo

* fix(rest#InviteComplex): guildScheduledEventID
This commit is contained in:
Fedor Lapshin 2022-04-17 22:50:10 +03:00 committed by GitHub
parent eda859edc9
commit 9dc4ac5cac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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) {