comment all

This commit is contained in:
2020-01-15 14:59:09 +01:00
parent 41861da83e
commit 63c342d87a
6 changed files with 65 additions and 40 deletions

View File

@@ -2,16 +2,19 @@ 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"`
@@ -20,6 +23,7 @@ type Webhook struct {
Embeds []*Embed `json:"embeds,omitempty"`
}
// Embed Embed
type Embed struct {
Author Author `json:"author,omitempty"`
Title string `json:"title,omitempty"`
@@ -32,23 +36,27 @@ type Embed struct {
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"`
}