Skip to content

Commit

Permalink
Address Discord having shitty API design
Browse files Browse the repository at this point in the history
  • Loading branch information
mlnrDev committed Nov 15, 2023
1 parent c9a2364 commit 7e8c825
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions discord/guild_onboarding.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package discord

import "github.com/disgoorg/snowflake/v2"
import (
"github.com/disgoorg/json"
"github.com/disgoorg/snowflake/v2"
)

type GuildOnboarding struct {
GuildID snowflake.ID `json:"guild_id"`
Expand All @@ -21,12 +24,28 @@ type GuildOnboardingPrompt struct {
}

type GuildOnboardingPromptOption struct {
ID snowflake.ID `json:"id"`
ChannelIDs []snowflake.ID `json:"channel_ids"`
RoleIDs []snowflake.ID `json:"role_ids"`
Emoji PartialEmoji `json:"emoji"`
Title string `json:"title"`
Description *string `json:"description"`
ID snowflake.ID `json:"id"`
ChannelIDs []snowflake.ID `json:"channel_ids"`
RoleIDs []snowflake.ID `json:"role_ids"`
// When creating or updating prompts and their options, this field will be broken down into 3 separate fields in the payload: https://github.com/discord/discord-api-docs/pull/6479
Emoji PartialEmoji `json:"emoji"`
Title string `json:"title"`
Description *string `json:"description"`
}

func (o GuildOnboardingPromptOption) MarshalJSON() ([]byte, error) {
type onboardingPromptOption GuildOnboardingPromptOption
return json.Marshal(struct {
EmojiID *snowflake.ID `json:"emoji_id,omitempty"`
EmojiName *string `json:"emoji_name,omitempty"`
EmojiAnimated bool `json:"emoji_animated"`
onboardingPromptOption
}{
EmojiID: o.Emoji.ID,
EmojiName: o.Emoji.Name,
EmojiAnimated: o.Emoji.Animated,
onboardingPromptOption: onboardingPromptOption(o),
})
}

type GuildOnboardingPromptType int
Expand Down

2 comments on commit 7e8c825

@sebm253
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebm253
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.