From 02ef25b825c88b2716503fcf879d9d6864c7be7a Mon Sep 17 00:00:00 2001 From: nitroflap Date: Sun, 17 Apr 2022 22:28:13 +0300 Subject: [PATCH 1/3] feat: implement InviteComplex --- restapi.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/restapi.go b/restapi.go index 97d030270..f2890e823 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 parameters. +// inviteID : The invite code +// withCounts : Whether to include approximate member counts or not +// withExpiration : Whether to include expiration time or not +// withGuildScheduledEventID : Whether to include id of a scheduled id or not +func (s *Session) InviteComplex(inviteID string, withCounts, withExpiration, withGuildScheduledEventID bool) (st *Invite, err error) { + endpoint := EndpointInvite(inviteID) + v := url.Values{} + if withCounts { + v.Set("with_counts", "true") + } + if withExpiration { + v.Set("with_expiration", "true") + } + if withGuildScheduledEventID { + v.Set("with_guild_scheduled_event_id", "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) { From 57cd07030251662387c1094f71c71dc802974231 Mon Sep 17 00:00:00 2001 From: nitroflap Date: Sun, 17 Apr 2022 22:32:26 +0300 Subject: [PATCH 2/3] fix: typo --- restapi.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/restapi.go b/restapi.go index f2890e823..d3ecf12c3 100644 --- a/restapi.go +++ b/restapi.go @@ -1992,11 +1992,11 @@ func (s *Session) InviteWithCounts(inviteID string) (st *Invite, err error) { return } -// InviteComplex returns an Invite structure of the given invite including specified parameters. +// InviteComplex returns an Invite structure of the given invite including specified fields. // inviteID : The invite code // withCounts : Whether to include approximate member counts or not // withExpiration : Whether to include expiration time or not -// withGuildScheduledEventID : Whether to include id of a scheduled id or not +// withGuildScheduledEventID : Whether to include id of a scheduled event or not func (s *Session) InviteComplex(inviteID string, withCounts, withExpiration, withGuildScheduledEventID bool) (st *Invite, err error) { endpoint := EndpointInvite(inviteID) v := url.Values{} From df49014a69c6d442945362d7dec18cc703c18c9e Mon Sep 17 00:00:00 2001 From: nitroflap Date: Sun, 17 Apr 2022 22:43:55 +0300 Subject: [PATCH 3/3] fix(rest#InviteComplex): guildScheduledEventID --- restapi.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/restapi.go b/restapi.go index d3ecf12c3..bb21ef21f 100644 --- a/restapi.go +++ b/restapi.go @@ -1994,21 +1994,21 @@ func (s *Session) InviteWithCounts(inviteID string) (st *Invite, err error) { // 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 -// withGuildScheduledEventID : Whether to include id of a scheduled event or not -func (s *Session) InviteComplex(inviteID string, withCounts, withExpiration, withGuildScheduledEventID bool) (st *Invite, err error) { +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 withGuildScheduledEventID { - v.Set("with_guild_scheduled_event_id", "true") - } if len(v) != 0 { endpoint += "?" + v.Encode()