-
Notifications
You must be signed in to change notification settings - Fork 0
/
embed.go
116 lines (97 loc) · 2.81 KB
/
embed.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package httpcord
type Embed struct {
Title string `json:"title,omitempty"`
// Always "rich" for webhook embeds
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
URL string `json:"url,omitempty"`
Timestamp Time `json:"timestamp"`
Color int `json:"color,omitempty"`
Footer *EmbedFooter `json:"footer,omitempty"`
Image *EmbedImage `json:"image,omitempty"`
Thumbnail *EmbedThumbnail `json:"thumbnail,omitempty"`
Video *EmbedVideo `json:"video,omitempty"`
Provider *EmbedProvider `json:"provider,omitempty"`
Author *EmbedAuthor `json:"author,omitempty"`
Fields []*EmbedField `json:"fields,omitempty"`
}
type EmbedFooter struct {
Text string `json:"text"`
IconURL string `json:"icon_url,omitempty"`
ProxyIconURl string `json:"proxy_icon_url,omitempty"`
}
type EmbedImage struct {
URL string `json:"url,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
Height int `json:"height,omitempty"`
Width int `json:"width,omitempty"`
}
type EmbedThumbnail struct {
URL string `json:"url,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
Height int `json:"height,omitempty"`
Width int `json:"width,omitempty"`
}
type EmbedVideo struct {
URL string `json:"url,omitempty"`
Height int `json:"height,omitempty"`
Width int `json:"width,omitempty"`
}
type EmbedProvider struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
}
type EmbedAuthor struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
IconURl string `json:"icon_url,omitempty"`
ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}
type EmbedField struct {
Name string `json:"name"`
Value string `json:"value"`
Inline bool `json:"inline,omitempty"`
}
func NewEmbedBuilder() *Embed {
return &Embed{}
}
func (e *Embed) SetTitle(title string) *Embed {
e.Title = title
return e
}
func (e *Embed) SetDescription(description string) *Embed {
e.Description = description
return e
}
func (e *Embed) SetURL(URL string) *Embed {
e.URL = URL
return e
}
func (e *Embed) SetTimestamp(timestamp Time) *Embed {
e.Timestamp = timestamp
return e
}
func (e *Embed) SetColor(color int) *Embed {
e.Color = color
return e
}
func (e *Embed) SetFooter(footer *EmbedFooter) *Embed {
e.Footer = footer
return e
}
func (e *Embed) SetImage(image *EmbedImage) *Embed {
e.Image = image
return e
}
func (e *Embed) SetThumbnail(thumbnail *EmbedThumbnail) *Embed {
e.Thumbnail = thumbnail
return e
}
func (e *Embed) SetAuthor(author *EmbedAuthor) *Embed {
e.Author = author
return e
}
func (e *Embed) AddField(field *EmbedField) *Embed {
e.Fields = append(e.Fields, field)
return e
}