Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(guild): implement onboarding #1401

Merged
merged 21 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e42474c
feat(guild): add onboarding
Earlopain Jun 29, 2023
a94ce89
Merge branch 'master' into guild-onboarding
FedorLap2006 Jul 3, 2023
1b46ab7
feat: add onboarding modes
FedorLap2006 Jul 15, 2023
8dc250a
Adress review comments
Earlopain Jul 24, 2023
f245bdf
Update structs.go
Earlopain Aug 10, 2023
34f0fa5
add update endpoint
Earlopain Aug 10, 2023
7534059
Reuse GuildOnboarding struct
Earlopain Aug 14, 2023
e040334
feat(GuildOnboarding): allow empty prompt array
FedorLap2006 Oct 12, 2023
c628c3e
fix: use GuildOnboardingMode in mode values
FedorLap2006 Oct 12, 2023
0170114
feat(GuildOnboardingPromptOption): omit empty id
FedorLap2006 Oct 14, 2023
c3e6b88
docs(rest): reword descriptions of GuildOnboarding and GuildOnboardin…
FedorLap2006 Oct 14, 2023
ea7e003
docs(GuildOnboardingEdit): fix indentation in parameter comments
FedorLap2006 Oct 14, 2023
2748b58
feat(GuildOnboardingPromptOption): make description not nullable
FedorLap2006 Oct 21, 2023
081d4af
style: add missing periods
FedorLap2006 Oct 21, 2023
265dac5
docs(GuildOnboardingPrompt): clarify customize community tab name
FedorLap2006 Oct 21, 2023
b4d6804
docs(GuildOnboardingPrompt): correct grammar in comment to Type field
FedorLap2006 Oct 29, 2023
7fda7f9
docs(GuildOnboardingPromptType): fix grammar
FedorLap2006 Dec 31, 2023
6784c6b
feat(GuildOnboardingPromptOption): implement flattened emoji fields
FedorLap2006 Dec 31, 2023
4647d5e
docs(GuildOnboardingPrompt): add missing customize community mentions
FedorLap2006 Dec 31, 2023
bc7ee2a
docs: fix grammar and add missing periods
FedorLap2006 Jan 1, 2024
774b06a
chore: reorder definitions of GuildOnboardingPromptType and GuildOnbo…
FedorLap2006 Jan 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
15 changes: 15 additions & 0 deletions restapi.go
Earlopain marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ----------------------------------------------------------------------
Expand Down
88 changes: 88 additions & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,94 @@ 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

// Block containing known GuildOnboardingMode values
const (
// GuildOnboardingModeDefault counts default channels towards constraints
GuildOnboardingModeDefault = 0
// GuildOnboardingModeAdvanced counts default channels and questions towards constraints
GuildOnboardingModeAdvanced = 1
)

// GuildOnboarding represents the onboarding flow for a guild.
Earlopain marked this conversation as resolved.
Show resolved Hide resolved
// 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.
Earlopain marked this conversation as resolved.
Show resolved Hide resolved
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"`

// Current mode of onboarding.
Mode GuildOnboardingMode `json:"mode"`
}

// 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"`
}

// A GuildTemplate represents a replicable template for guild creation
type GuildTemplate struct {
// The unique code for the guild template
Expand Down