package main import "encoding/json" // UnmarshalWebhook UnmarshalWebhook func UnmarshalWebhook(data []byte) (Webhook, error) { var r Webhook err := json.Unmarshal(data, &r) return r, err } // Marshal Marshal func (r *Webhook) Marshal() ([]byte, error) { return json.Marshal(r) } // Webhook Webhook type Webhook struct { Username string `json:"username,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` TTS string `json:"tts,omitempty"` Content string `json:"content,omitempty"` Embeds []*Embed `json:"embeds,omitempty"` } // Embed Embed type Embed struct { Author Author `json:"author,omitempty"` Title string `json:"title,omitempty"` URL string `json:"url,omitempty"` Description string `json:"description,omitempty"` Color int64 `json:"color,omitempty"` Fields []Field `json:"fields,omitempty"` Thumbnail Image `json:"thumbnail,omitempty"` Image Image `json:"image,omitempty"` Footer Footer `json:"footer,omitempty"` } // Author Author type Author struct { Name string `json:"name"` URL string `json:"url"` IconURL string `json:"icon_url"` } // Field Field type Field struct { Name string `json:"name"` Value string `json:"value"` Inline *bool `json:"inline,omitempty"` } // Footer Footer type Footer struct { Text string `json:"text"` IconURL string `json:"icon_url"` } // Image Image type Image struct { URL string `json:"url"` }