From e42474c875c14d31f4a85a674d74f314dd5a696e Mon Sep 17 00:00:00 2001 From: Earlopain Date: Thu, 29 Jun 2023 23:16:30 +0200 Subject: [PATCH 01/20] feat(guild): add onboarding --- endpoints.go | 1 + restapi.go | 15 +++++++++++ structs.go | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) diff --git a/endpoints.go b/endpoints.go index a2a05fe3e..ac130c4bf 100644 --- a/endpoints.go +++ b/endpoints.go @@ -104,6 +104,7 @@ var ( EndpointGuildScheduledEvents = func(gID string) string { return EndpointGuilds + gID + "/scheduled-events" } EndpointGuildScheduledEvent = func(gID, eID string) string { return EndpointGuilds + gID + "/scheduled-events/" + eID } EndpointGuildScheduledEventUsers = func(gID, eID string) string { return EndpointGuildScheduledEvent(gID, eID) + "/users" } + EndpointGuildOnboarding = func(gID string) string { return EndpointGuilds + gID + "/onboarding" } EndpointGuildTemplate = func(tID string) string { return EndpointGuilds + "/templates/" + tID } EndpointGuildTemplates = func(gID string) string { return EndpointGuilds + gID + "/templates" } EndpointGuildTemplateSync = func(gID, tID string) string { return EndpointGuilds + gID + "/templates/" + tID } diff --git a/restapi.go b/restapi.go index b2d69598f..17c700cf2 100644 --- a/restapi.go +++ b/restapi.go @@ -3250,6 +3250,21 @@ func (s *Session) GuildScheduledEventUsers(guildID, eventID string, limit int, w return } +// GuildOnboarding returns the onboarding flow for a guild +// guildID : The ID of a Guild +func (s *Session) GuildOnboarding(guildID string, options ...RequestOption) (onboarding GuildOnboarding, err error) { + endpoint := EndpointGuildOnboarding(guildID) + + var body []byte + body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...) + if err != nil { + return + } + + err = unmarshal(body, &onboarding) + return +} + // ---------------------------------------------------------------------- // Functions specific to auto moderation // ---------------------------------------------------------------------- diff --git a/structs.go b/structs.go index 78fe4b224..f0b88ae29 100644 --- a/structs.go +++ b/structs.go @@ -1070,6 +1070,79 @@ type GuildScheduledEventUser struct { Member *Member `json:"member"` } +// GuildOnboarding represents the onboarding flow for a guild +// https://discord.com/developers/docs/resources/guild#guild-onboarding-object +type GuildOnboarding struct { + // ID of the guild this onboarding is part of + GuildID string `json:"guild_id"` + + // Prompts shown during onboarding and in customize community + Prompts []GuildOnboardingPrompt `json:"prompts"` + + // Channel IDs that members get opted into automatically + DefaultChannelIDs []string `json:"default_channel_ids"` + + // Whether onboarding is enabled in the guild + Enabled bool `json:"enabled"` +} + +// GuildOnboardingPrompt is a prompt shown during onboarding and in customize community +// https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-prompt-structure +type GuildOnboardingPrompt struct { + // ID of the prompt + ID string `json:"id"` + + // Type of prompt + Type GuildOnboardingPromptType `json:"type"` + + // Options available within the prompt + Options []GuildOnboardingPromptOption `json:"options"` + + // Title of the prompt + Title string `json:"title"` + + // Indicates whether users are limited to selecting one option for the prompt + SingleSelect bool `json:"single_select"` + + // Indicates whether the prompt is required before a user completes the onboarding flow + Required bool `json:"required"` + + // Indicates whether the prompt is present in the onboarding flow. If false, the prompt will only appear in the Channels & Roles tab + InOnboarding bool `json:"in_onboarding"` +} + +// GuildOnboardingPromptType is the type of prompt during onboarding +// https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-types +type GuildOnboardingPromptType int + +// Block containing known GuildOnboardingPromptType values +const ( + GuildOnboardingPromptTypeMultipleChoice GuildOnboardingPromptType = 0 + GuildOnboardingPromptTypeDropdown GuildOnboardingPromptType = 1 +) + +// GuildOnboardingPromptOption is an option available within an onboarding prompt +// https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-option-structure +type GuildOnboardingPromptOption struct { + // ID of the prompt option + ID string `json:"id"` + + // IDs for channels a member is added to when the option is selected + ChannelIDs []string `json:"channel_ids"` + + // IDs for roles assigned to a member when the option is selected + RoleIDs []string `json:"role_ids"` + + // Emoji of the option + Emoji Emoji `json:"emoji"` + + // Title of the option + Title string `json:"title"` + + // Description of the option + Description string `json:"description,omitempty"` +} + // A GuildTemplate represents a replicable template for guild creation type GuildTemplate struct { // The unique code for the guild template From 1b46ab78a098bba57d129004d484101c97142a2e Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sat, 15 Jul 2023 18:31:58 +0300 Subject: [PATCH 02/20] feat: add onboarding modes Add constants defining onboarding modes and Mode field to GuildOnboarding. --- structs.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/structs.go b/structs.go index f0b88ae29..124443142 100644 --- a/structs.go +++ b/structs.go @@ -1070,6 +1070,17 @@ type GuildScheduledEventUser struct { Member *Member `json:"member"` } +// GuildOnboardingMode defines the criteria used to satisfy constraints that are required for enabling onboarding. +// https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-mode +type GuildOnboardingMode int + +const ( + // GuildOnboardingModeDefault counts default channels towards constraints + GuildOnboardingModeDefault = 0 + // GuildOnboardingModeDefault counts default channels and questions towards constraints + GuildOnboardingModeAdvanced = 1 +) + // GuildOnboarding represents the onboarding flow for a guild // https://discord.com/developers/docs/resources/guild#guild-onboarding-object type GuildOnboarding struct { @@ -1082,8 +1093,11 @@ type GuildOnboarding struct { // Channel IDs that members get opted into automatically DefaultChannelIDs []string `json:"default_channel_ids"` - // Whether onboarding is enabled in the guild + // Whether onboarding is enabled in the guild Enabled bool `json:"enabled"` + + // Current mode of onboarding + Mode GuildOnboardingMode `json:"mode"` } // GuildOnboardingPrompt is a prompt shown during onboarding and in customize community From 8dc250a106051adc00c5c14e9af5903c99f9d5eb Mon Sep 17 00:00:00 2001 From: Earlopain Date: Mon, 24 Jul 2023 13:23:32 +0200 Subject: [PATCH 03/20] Adress review comments --- restapi.go | 4 ++-- structs.go | 49 +++++++++++++++++++++++++------------------------ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/restapi.go b/restapi.go index 17c700cf2..0b53c4718 100644 --- a/restapi.go +++ b/restapi.go @@ -3250,9 +3250,9 @@ func (s *Session) GuildScheduledEventUsers(guildID, eventID string, limit int, w return } -// GuildOnboarding returns the onboarding flow for a guild +// GuildOnboarding returns the onboarding flow for a guild. // guildID : The ID of a Guild -func (s *Session) GuildOnboarding(guildID string, options ...RequestOption) (onboarding GuildOnboarding, err error) { +func (s *Session) GuildOnboarding(guildID string, options ...RequestOption) (onboarding *GuildOnboarding, err error) { endpoint := EndpointGuildOnboarding(guildID) var body []byte diff --git a/structs.go b/structs.go index 124443142..4e37d3f0c 100644 --- a/structs.go +++ b/structs.go @@ -1074,58 +1074,59 @@ type GuildScheduledEventUser struct { // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-mode type GuildOnboardingMode int +// Block containing known GuildOnboardingMode values const ( // GuildOnboardingModeDefault counts default channels towards constraints GuildOnboardingModeDefault = 0 - // GuildOnboardingModeDefault counts default channels and questions towards constraints + // GuildOnboardingModeAdvanced counts default channels and questions towards constraints GuildOnboardingModeAdvanced = 1 ) -// GuildOnboarding represents the onboarding flow for a guild +// GuildOnboarding represents the onboarding flow for a guild. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object type GuildOnboarding struct { - // ID of the guild this onboarding is part of + // ID of the guild this onboarding is part of. GuildID string `json:"guild_id"` - // Prompts shown during onboarding and in customize community + // Prompts shown during onboarding and in customize community. Prompts []GuildOnboardingPrompt `json:"prompts"` - // Channel IDs that members get opted into automatically + // Channel IDs that members get opted into automatically. DefaultChannelIDs []string `json:"default_channel_ids"` - // Whether onboarding is enabled in the guild + // Whether onboarding is enabled in the guild. Enabled bool `json:"enabled"` - // Current mode of onboarding + // Current mode of onboarding. Mode GuildOnboardingMode `json:"mode"` } -// GuildOnboardingPrompt is a prompt shown during onboarding and in customize community +// GuildOnboardingPrompt is a prompt shown during onboarding and in customize community. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-prompt-structure type GuildOnboardingPrompt struct { - // ID of the prompt + // ID of the prompt. ID string `json:"id"` - // Type of prompt + // Type of prompt. Type GuildOnboardingPromptType `json:"type"` - // Options available within the prompt + // Options available within the prompt. Options []GuildOnboardingPromptOption `json:"options"` - // Title of the prompt + // Title of the prompt. Title string `json:"title"` - // Indicates whether users are limited to selecting one option for the prompt + // Indicates whether users are limited to selecting one option for the prompt. SingleSelect bool `json:"single_select"` - // Indicates whether the prompt is required before a user completes the onboarding flow + // Indicates whether the prompt is required before a user completes the onboarding flow. Required bool `json:"required"` - // Indicates whether the prompt is present in the onboarding flow. If false, the prompt will only appear in the Channels & Roles tab + // Indicates whether the prompt is present in the onboarding flow. If false, the prompt will only appear in the Channels & Roles tab. InOnboarding bool `json:"in_onboarding"` } -// GuildOnboardingPromptType is the type of prompt during onboarding +// GuildOnboardingPromptType is the type of prompt during onboarding. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-types type GuildOnboardingPromptType int @@ -1135,26 +1136,26 @@ const ( GuildOnboardingPromptTypeDropdown GuildOnboardingPromptType = 1 ) -// GuildOnboardingPromptOption is an option available within an onboarding prompt +// GuildOnboardingPromptOption is an option available within an onboarding prompt. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-option-structure type GuildOnboardingPromptOption struct { - // ID of the prompt option + // ID of the prompt option. ID string `json:"id"` - // IDs for channels a member is added to when the option is selected + // IDs for channels a member is added to when the option is selected. ChannelIDs []string `json:"channel_ids"` - // IDs for roles assigned to a member when the option is selected + // IDs for roles assigned to a member when the option is selected. RoleIDs []string `json:"role_ids"` - // Emoji of the option + // Emoji of the option. Emoji Emoji `json:"emoji"` - // Title of the option + // Title of the option. Title string `json:"title"` - // Description of the option - Description string `json:"description,omitempty"` + // Description of the option. + Description *string `json:"description"` } // A GuildTemplate represents a replicable template for guild creation From f245bdfd4abb0c278649bc55890855b7cc396eb0 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:41:02 +0200 Subject: [PATCH 04/20] Update structs.go Co-authored-by: Fedor Lapshin --- structs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/structs.go b/structs.go index 4e37d3f0c..0cb653336 100644 --- a/structs.go +++ b/structs.go @@ -1088,7 +1088,7 @@ type GuildOnboarding struct { // ID of the guild this onboarding is part of. GuildID string `json:"guild_id"` - // Prompts shown during onboarding and in customize community. + // Prompts shown during onboarding and in the Channel & Roles tab. Prompts []GuildOnboardingPrompt `json:"prompts"` // Channel IDs that members get opted into automatically. From 34f0fa558d623aa41523e331ba7461bda14a2821 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Thu, 10 Aug 2023 12:32:27 +0200 Subject: [PATCH 05/20] add update endpoint --- restapi.go | 16 ++++++++++++++++ structs.go | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/restapi.go b/restapi.go index 0b53c4718..85ca2eee2 100644 --- a/restapi.go +++ b/restapi.go @@ -3265,6 +3265,22 @@ func (s *Session) GuildOnboarding(guildID string, options ...RequestOption) (onb return } +// GuildOnboardingEdit edits Onboarding for a Guild. +// guildID : The ID of a Guild. +// o : A GuildOnboardingParams struct. +func (s *Session) GuildOnboardingEdit(guildID string, o *GuildOnboardingParams, options ...RequestOption) (onboarding *GuildOnboarding, err error) { + endpoint := EndpointGuildOnboarding(guildID) + + var body []byte + body, err = s.RequestWithBucketID("PUT", endpoint, o, endpoint, options...) + if err != nil { + return + } + + err = unmarshal(body, &onboarding) + return +} + // ---------------------------------------------------------------------- // Functions specific to auto moderation // ---------------------------------------------------------------------- diff --git a/structs.go b/structs.go index 0cb653336..253f4674b 100644 --- a/structs.go +++ b/structs.go @@ -1101,6 +1101,22 @@ type GuildOnboarding struct { Mode GuildOnboardingMode `json:"mode"` } +// GuildOnboardingParams stores all the data needed to update discord onboarding settings. +// https://discord.com/developers/docs/resources/guild#modify-guild-onboarding-json-params +type GuildOnboardingParams struct { + // Prompts shown during onboarding and in the Channel & Roles tab. + Prompts []GuildOnboardingPrompt `json:"prompts,omitempty"` + + // Channel IDs that members get opted into automatically. + DefaultChannelIDs []string `json:"default_channel_ids,omitempty"` + + // Whether onboarding is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // Mode of onboarding. + Mode GuildOnboardingMode `json:"mode,omitempty"` +} + // GuildOnboardingPrompt is a prompt shown during onboarding and in customize community. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-prompt-structure type GuildOnboardingPrompt struct { @@ -2442,6 +2458,9 @@ const ( ErrCodeCannotUpdateAFinishedEvent = 180000 ErrCodeFailedToCreateStageNeededForStageEvent = 180002 + + ErrCodeCannotEnableOnboardingRequirementsAreNotMet = 350000 + ErrCodeCannotUpdateOnboardingWhileBelowRequirements = 350001 ) // Intent is the type of a Gateway Intent From 753405987262ddeb41517aac73454aaf49bd87b9 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 14 Aug 2023 11:52:29 +0200 Subject: [PATCH 06/20] Reuse GuildOnboarding struct --- restapi.go | 4 ++-- structs.go | 22 +++------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/restapi.go b/restapi.go index 85ca2eee2..a1c415c9e 100644 --- a/restapi.go +++ b/restapi.go @@ -3267,8 +3267,8 @@ func (s *Session) GuildOnboarding(guildID string, options ...RequestOption) (onb // GuildOnboardingEdit edits Onboarding for a Guild. // guildID : The ID of a Guild. -// o : A GuildOnboardingParams struct. -func (s *Session) GuildOnboardingEdit(guildID string, o *GuildOnboardingParams, options ...RequestOption) (onboarding *GuildOnboarding, err error) { +// o : A GuildOnboarding struct. +func (s *Session) GuildOnboardingEdit(guildID string, o *GuildOnboarding, options ...RequestOption) (onboarding *GuildOnboarding, err error) { endpoint := EndpointGuildOnboarding(guildID) var body []byte diff --git a/structs.go b/structs.go index 253f4674b..c4ea9aa27 100644 --- a/structs.go +++ b/structs.go @@ -1086,35 +1086,19 @@ const ( // https://discord.com/developers/docs/resources/guild#guild-onboarding-object type GuildOnboarding struct { // ID of the guild this onboarding is part of. - GuildID string `json:"guild_id"` - - // Prompts shown during onboarding and in the Channel & Roles tab. - Prompts []GuildOnboardingPrompt `json:"prompts"` - - // Channel IDs that members get opted into automatically. - DefaultChannelIDs []string `json:"default_channel_ids"` + GuildID string `json:"guild_id,omitempty"` - // Whether onboarding is enabled in the guild. - Enabled bool `json:"enabled"` - - // Current mode of onboarding. - Mode GuildOnboardingMode `json:"mode"` -} - -// GuildOnboardingParams stores all the data needed to update discord onboarding settings. -// https://discord.com/developers/docs/resources/guild#modify-guild-onboarding-json-params -type GuildOnboardingParams struct { // Prompts shown during onboarding and in the Channel & Roles tab. Prompts []GuildOnboardingPrompt `json:"prompts,omitempty"` // Channel IDs that members get opted into automatically. DefaultChannelIDs []string `json:"default_channel_ids,omitempty"` - // Whether onboarding is enabled. + // Whether onboarding is enabled in the guild. Enabled *bool `json:"enabled,omitempty"` // Mode of onboarding. - Mode GuildOnboardingMode `json:"mode,omitempty"` + Mode *GuildOnboardingMode `json:"mode,omitempty"` } // GuildOnboardingPrompt is a prompt shown during onboarding and in customize community. From e0403343ad49ebfe502836722847ba5d31603ce2 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 12 Oct 2023 21:23:35 +0300 Subject: [PATCH 07/20] feat(GuildOnboarding): allow empty prompt array Make Prompts field a pointer to allow removing all the prompts. --- structs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/structs.go b/structs.go index c4ea9aa27..d9880aa74 100644 --- a/structs.go +++ b/structs.go @@ -1089,7 +1089,7 @@ type GuildOnboarding struct { GuildID string `json:"guild_id,omitempty"` // Prompts shown during onboarding and in the Channel & Roles tab. - Prompts []GuildOnboardingPrompt `json:"prompts,omitempty"` + Prompts *[]GuildOnboardingPrompt `json:"prompts,omitempty"` // Channel IDs that members get opted into automatically. DefaultChannelIDs []string `json:"default_channel_ids,omitempty"` From c628c3ea14e35dc67646ea79af6bd8a7825d93fc Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Thu, 12 Oct 2023 21:30:14 +0300 Subject: [PATCH 08/20] fix: use GuildOnboardingMode in mode values Use GuildOnboardingMode type in GuildOnboardingModeDefault and GuildOnboardingModeAdvanced. --- structs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/structs.go b/structs.go index d9880aa74..2e3de8608 100644 --- a/structs.go +++ b/structs.go @@ -1077,9 +1077,9 @@ type GuildOnboardingMode int // Block containing known GuildOnboardingMode values const ( // GuildOnboardingModeDefault counts default channels towards constraints - GuildOnboardingModeDefault = 0 + GuildOnboardingModeDefault GuildOnboardingMode = 0 // GuildOnboardingModeAdvanced counts default channels and questions towards constraints - GuildOnboardingModeAdvanced = 1 + GuildOnboardingModeAdvanced GuildOnboardingMode = 1 ) // GuildOnboarding represents the onboarding flow for a guild. From 0170114bba93cbafea3634065270e03a9fe1b347 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sat, 14 Oct 2023 13:44:12 +0300 Subject: [PATCH 09/20] feat(GuildOnboardingPromptOption): omit empty id --- structs.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/structs.go b/structs.go index 2e3de8608..2e3dd5157 100644 --- a/structs.go +++ b/structs.go @@ -1105,7 +1105,9 @@ type GuildOnboarding struct { // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-prompt-structure type GuildOnboardingPrompt struct { // ID of the prompt. - ID string `json:"id"` + // NOTE: always requires to be a valid snowflake (e.g. "0"), see + // https://github.com/discord/discord-api-docs/issues/6320 for more information. + ID string `json:"id,omitempty"` // Type of prompt. Type GuildOnboardingPromptType `json:"type"` @@ -1140,7 +1142,7 @@ const ( // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-option-structure type GuildOnboardingPromptOption struct { // ID of the prompt option. - ID string `json:"id"` + ID string `json:"id,omitempty"` // IDs for channels a member is added to when the option is selected. ChannelIDs []string `json:"channel_ids"` From c3e6b88739f3830b6fa915e10e4c2638c4bdfaf0 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sat, 14 Oct 2023 13:59:12 +0300 Subject: [PATCH 10/20] docs(rest): reword descriptions of GuildOnboarding and GuildOnboardingEdit --- restapi.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/restapi.go b/restapi.go index a1c415c9e..8b9ae6c3f 100644 --- a/restapi.go +++ b/restapi.go @@ -3250,8 +3250,8 @@ func (s *Session) GuildScheduledEventUsers(guildID, eventID string, limit int, w return } -// GuildOnboarding returns the onboarding flow for a guild. -// guildID : The ID of a Guild +// GuildOnboarding returns onboarding configuration of a guild. +// guildID : The ID of the guild func (s *Session) GuildOnboarding(guildID string, options ...RequestOption) (onboarding *GuildOnboarding, err error) { endpoint := EndpointGuildOnboarding(guildID) @@ -3265,9 +3265,9 @@ func (s *Session) GuildOnboarding(guildID string, options ...RequestOption) (onb return } -// GuildOnboardingEdit edits Onboarding for a Guild. -// guildID : The ID of a Guild. -// o : A GuildOnboarding struct. +// GuildOnboardingEdit edits onboarding configuration of a guild. +// guildID : The ID of the guild +// o : New GuildOnboarding data func (s *Session) GuildOnboardingEdit(guildID string, o *GuildOnboarding, options ...RequestOption) (onboarding *GuildOnboarding, err error) { endpoint := EndpointGuildOnboarding(guildID) From ea7e003909de392d91be30a5ab1f827d59c6343e Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sat, 14 Oct 2023 14:04:40 +0300 Subject: [PATCH 11/20] docs(GuildOnboardingEdit): fix indentation in parameter comments --- restapi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/restapi.go b/restapi.go index 8b9ae6c3f..87f2e50da 100644 --- a/restapi.go +++ b/restapi.go @@ -3267,7 +3267,7 @@ func (s *Session) GuildOnboarding(guildID string, options ...RequestOption) (onb // GuildOnboardingEdit edits onboarding configuration of a guild. // guildID : The ID of the guild -// o : New GuildOnboarding data +// o : New GuildOnboarding data func (s *Session) GuildOnboardingEdit(guildID string, o *GuildOnboarding, options ...RequestOption) (onboarding *GuildOnboarding, err error) { endpoint := EndpointGuildOnboarding(guildID) From 2748b5883e422b9ea8ad208d966a17eb443cb49e Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sat, 21 Oct 2023 23:02:33 +0300 Subject: [PATCH 12/20] feat(GuildOnboardingPromptOption): make description not nullable The related endpoint ignores the null value for this field. Thus the pointer can be dropped. --- structs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/structs.go b/structs.go index 2e3dd5157..b4011b433 100644 --- a/structs.go +++ b/structs.go @@ -1157,7 +1157,7 @@ type GuildOnboardingPromptOption struct { Title string `json:"title"` // Description of the option. - Description *string `json:"description"` + Description string `json:"description"` } // A GuildTemplate represents a replicable template for guild creation From 081d4af76af716db13bebc425cdd3aa9644608d9 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sat, 21 Oct 2023 23:43:45 +0300 Subject: [PATCH 13/20] style: add missing periods --- structs.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/structs.go b/structs.go index b4011b433..55443276e 100644 --- a/structs.go +++ b/structs.go @@ -1074,11 +1074,11 @@ type GuildScheduledEventUser struct { // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-mode type GuildOnboardingMode int -// Block containing known GuildOnboardingMode values +// Block containing known GuildOnboardingMode values. const ( - // GuildOnboardingModeDefault counts default channels towards constraints + // GuildOnboardingModeDefault counts default channels towards constraints. GuildOnboardingModeDefault GuildOnboardingMode = 0 - // GuildOnboardingModeAdvanced counts default channels and questions towards constraints + // GuildOnboardingModeAdvanced counts default channels and questions towards constraints. GuildOnboardingModeAdvanced GuildOnboardingMode = 1 ) From 265dac50e1cdfcaa75205c3aefd0fa54b81ce423 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sat, 21 Oct 2023 23:45:36 +0300 Subject: [PATCH 14/20] docs(GuildOnboardingPrompt): clarify customize community tab name --- structs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/structs.go b/structs.go index 55443276e..109a4cedb 100644 --- a/structs.go +++ b/structs.go @@ -1088,7 +1088,7 @@ type GuildOnboarding struct { // ID of the guild this onboarding is part of. GuildID string `json:"guild_id,omitempty"` - // Prompts shown during onboarding and in the Channel & Roles tab. + // Prompts shown during onboarding and in the customize community (Channels & Roles) tab. Prompts *[]GuildOnboardingPrompt `json:"prompts,omitempty"` // Channel IDs that members get opted into automatically. @@ -1101,7 +1101,7 @@ type GuildOnboarding struct { Mode *GuildOnboardingMode `json:"mode,omitempty"` } -// GuildOnboardingPrompt is a prompt shown during onboarding and in customize community. +// GuildOnboardingPrompt is a prompt shown during onboarding and in the customize community (Channels & Roles) tab. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-prompt-structure type GuildOnboardingPrompt struct { // ID of the prompt. From b4d6804cbbaf8dfa4e8aba9d55f58b601bdc7f38 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sun, 29 Oct 2023 08:01:16 +0300 Subject: [PATCH 15/20] docs(GuildOnboardingPrompt): correct grammar in comment to Type field --- structs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/structs.go b/structs.go index 109a4cedb..5a9c0866d 100644 --- a/structs.go +++ b/structs.go @@ -1109,7 +1109,7 @@ type GuildOnboardingPrompt struct { // https://github.com/discord/discord-api-docs/issues/6320 for more information. ID string `json:"id,omitempty"` - // Type of prompt. + // Type of the prompt. Type GuildOnboardingPromptType `json:"type"` // Options available within the prompt. From 7fda7f9e886693b2768dd3b47268d76ca50fcbd5 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sun, 31 Dec 2023 22:20:02 +0300 Subject: [PATCH 16/20] docs(GuildOnboardingPromptType): fix grammar --- structs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/structs.go b/structs.go index 5a9c0866d..74c08aafc 100644 --- a/structs.go +++ b/structs.go @@ -1128,7 +1128,7 @@ type GuildOnboardingPrompt struct { InOnboarding bool `json:"in_onboarding"` } -// GuildOnboardingPromptType is the type of prompt during onboarding. +// GuildOnboardingPromptType is the type of onboarding prompt. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-types type GuildOnboardingPromptType int From 6784c6b4ab82d0230d8d3a015b405945a05f57c2 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sun, 31 Dec 2023 22:30:52 +0300 Subject: [PATCH 17/20] feat(GuildOnboardingPromptOption): implement flattened emoji fields Implement emoji_id, emoji_name and emoji_animated fields for usage in creation and update requests. --- structs.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/structs.go b/structs.go index 74c08aafc..086f8089e 100644 --- a/structs.go +++ b/structs.go @@ -1151,13 +1151,25 @@ type GuildOnboardingPromptOption struct { RoleIDs []string `json:"role_ids"` // Emoji of the option. - Emoji Emoji `json:"emoji"` + // NOTE: when creating or updating a prompt option + // EmojiID, EmojiName and EmojiAnimated should be used instead. + Emoji *Emoji `json:"emoji,omitempty"` // Title of the option. Title string `json:"title"` // Description of the option. Description string `json:"description"` + + // ID of the option's emoji. + // NOTE: only used when creating or updating a prompt option. + EmojiID string `json:"emoji_id,omitempty"` + // Name of the option's emoji. + // NOTE: only used when creating or updating a prompt option. + EmojiName string `json:"emoji_name,omitempty"` + // Whether the option's emoji is animated. + // NOTE: only used when creating or updating a prompt option. + EmojiAnimated *bool `json:"emoji_animated,omitempty"` } // A GuildTemplate represents a replicable template for guild creation From 4647d5ead6cd14714de51144c6abcb5acd4b1de3 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Sun, 31 Dec 2023 22:35:18 +0300 Subject: [PATCH 18/20] docs(GuildOnboardingPrompt): add missing customize community mentions --- structs.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/structs.go b/structs.go index 086f8089e..2dbd8690d 100644 --- a/structs.go +++ b/structs.go @@ -1124,7 +1124,8 @@ type GuildOnboardingPrompt struct { // Indicates whether the prompt is required before a user completes the onboarding flow. Required bool `json:"required"` - // Indicates whether the prompt is present in the onboarding flow. If false, the prompt will only appear in the Channels & Roles tab. + // Indicates whether the prompt is present in the onboarding flow. + // If false, the prompt will only appear in the customize community (Channels & Roles) tab. InOnboarding bool `json:"in_onboarding"` } From bc7ee2a124c076aa6f1485551d16704ae4cde1be Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Mon, 1 Jan 2024 07:42:51 +0300 Subject: [PATCH 19/20] docs: fix grammar and add missing periods --- structs.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/structs.go b/structs.go index 2dbd8690d..ae5eb7039 100644 --- a/structs.go +++ b/structs.go @@ -1085,7 +1085,7 @@ const ( // GuildOnboarding represents the onboarding flow for a guild. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object type GuildOnboarding struct { - // ID of the guild this onboarding is part of. + // ID of the guild this onboarding flow is part of. GuildID string `json:"guild_id,omitempty"` // Prompts shown during onboarding and in the customize community (Channels & Roles) tab. @@ -1129,11 +1129,11 @@ type GuildOnboardingPrompt struct { InOnboarding bool `json:"in_onboarding"` } -// GuildOnboardingPromptType is the type of onboarding prompt. +// GuildOnboardingPromptType is the type of an onboarding prompt. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-types type GuildOnboardingPromptType int -// Block containing known GuildOnboardingPromptType values +// Block containing known GuildOnboardingPromptType values. const ( GuildOnboardingPromptTypeMultipleChoice GuildOnboardingPromptType = 0 GuildOnboardingPromptTypeDropdown GuildOnboardingPromptType = 1 From 774b06ae7e3c362d9a11254abab16094bbc38bc3 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Mon, 1 Jan 2024 07:44:44 +0300 Subject: [PATCH 20/20] chore: reorder definitions of GuildOnboardingPromptType and GuildOnboardingPrompt --- structs.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/structs.go b/structs.go index ae5eb7039..d8746ce7e 100644 --- a/structs.go +++ b/structs.go @@ -1101,6 +1101,16 @@ type GuildOnboarding struct { Mode *GuildOnboardingMode `json:"mode,omitempty"` } +// GuildOnboardingPromptType is the type of an onboarding prompt. +// https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-types +type GuildOnboardingPromptType int + +// Block containing known GuildOnboardingPromptType values. +const ( + GuildOnboardingPromptTypeMultipleChoice GuildOnboardingPromptType = 0 + GuildOnboardingPromptTypeDropdown GuildOnboardingPromptType = 1 +) + // GuildOnboardingPrompt is a prompt shown during onboarding and in the customize community (Channels & Roles) tab. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-prompt-structure type GuildOnboardingPrompt struct { @@ -1129,16 +1139,6 @@ type GuildOnboardingPrompt struct { InOnboarding bool `json:"in_onboarding"` } -// GuildOnboardingPromptType is the type of an onboarding prompt. -// https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-types -type GuildOnboardingPromptType int - -// Block containing known GuildOnboardingPromptType values. -const ( - GuildOnboardingPromptTypeMultipleChoice GuildOnboardingPromptType = 0 - GuildOnboardingPromptTypeDropdown GuildOnboardingPromptType = 1 -) - // GuildOnboardingPromptOption is an option available within an onboarding prompt. // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-option-structure type GuildOnboardingPromptOption struct {