From 888d71cb210362fde6a1cee15f44aeb37cff8a26 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Wed, 10 Jan 2024 11:05:18 +0300 Subject: [PATCH] fix(Button): omit empty Emoji field --- components.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components.go b/components.go index 6ee4e2895..37adbe2bc 100644 --- a/components.go +++ b/components.go @@ -145,12 +145,19 @@ func (b Button) MarshalJSON() ([]byte, error) { b.Style = PrimaryButton } + var emoji *ComponentEmoji + if b.Emoji.ID != "" || b.Emoji.Name != "" { + emoji = &b.Emoji + } + return Marshal(struct { button - Type ComponentType `json:"type"` + Type ComponentType `json:"type"` + Emoji *ComponentEmoji `json:"emoji,omitempty"` }{ button: button(b), Type: b.Type(), + Emoji: emoji, }) }