Skip to content

Commit

Permalink
Add InviteComplex (#1163)
Browse files Browse the repository at this point in the history
* feat: implement InviteComplex

* fix: typo

* fix(rest#InviteComplex): guildScheduledEventID
  • Loading branch information
FedorLap2006 committed Apr 17, 2022
1 parent eda859e commit 9dc4ac5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions restapi.go
Expand Up @@ -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) {
Expand Down

0 comments on commit 9dc4ac5

Please sign in to comment.