diff --git a/restapi.go b/restapi.go index 97d030270..bb21ef21f 100644 --- a/restapi.go +++ b/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) {