diff --git a/components.go b/components.go index 3aaf46f2c..776c4a334 100644 --- a/components.go +++ b/components.go @@ -177,6 +177,24 @@ type SelectMenuOption struct { Default bool `json:"default"` } +// MarshalJSON is a method for marshalling SelectMenuOption to a JSON object. +func (o SelectMenuOption) MarshalJSON() ([]byte, error) { + type selectMenuOption SelectMenuOption + + var emoji *ComponentEmoji + if o.Emoji.ID != "" || o.Emoji.Name != "" { + emoji = &o.Emoji + } + + return json.Marshal(struct { + selectMenuOption + Emoji *ComponentEmoji `json:"emoji,omitempty"` + }{ + selectMenuOption: selectMenuOption(o), + Emoji: emoji, + }) +} + // SelectMenu represents select menu component. type SelectMenu struct { CustomID string `json:"custom_id,omitempty"`