@@ -40,8 +40,13 @@ public struct BotEmbed: Codable {
40
40
case url
41
41
case timestamp
42
42
case color
43
- case fields
44
43
case footer
44
+ case image
45
+ case thumbnail
46
+ case video
47
+ case provider
48
+ case author
49
+ case fields
45
50
}
46
51
47
52
// Always rich as that's the only type supported
@@ -54,6 +59,11 @@ public struct BotEmbed: Codable {
54
59
fileprivate( set) var timestamp : Date ?
55
60
fileprivate( set) var color : Int ?
56
61
fileprivate( set) var footer : EmbedFooter ?
62
+ fileprivate( set) var image : EmbedMedia ?
63
+ fileprivate( set) var thumbnail : EmbedMedia ?
64
+ fileprivate( set) var video : EmbedMedia ?
65
+ fileprivate( set) var provider : EmbedProvider ?
66
+ fileprivate( set) var author : EmbedAuthor ?
57
67
private let fields : [ Field ] ?
58
68
59
69
public init ( fields: [ Field ] ? = nil ) {
@@ -77,12 +87,6 @@ public extension BotEmbed {
77
87
return embed
78
88
}
79
89
80
- func footer( _ text: String ) -> Self {
81
- var embed = self
82
- embed. footer = . init( text: text)
83
- return embed
84
- }
85
-
86
90
func url( _ url: URL ? ) -> Self {
87
91
var embed = self
88
92
embed. url = url
@@ -103,4 +107,81 @@ public extension BotEmbed {
103
107
embed. color = color
104
108
return embed
105
109
}
110
+
111
+ func footer( _ footer: EmbedFooter ? ) -> Self {
112
+ var embed = self
113
+ embed. footer = footer
114
+ return embed
115
+ }
116
+
117
+ func footer( text: String , iconURL: String ? = nil , proxyIconURL: String ? = nil ) -> Self {
118
+ return footer ( . init( text: text, icon_url: iconURL, proxy_icon_url: proxyIconURL) )
119
+ }
120
+
121
+ func footer( _ text: String ) -> Self {
122
+ return footer ( text: text)
123
+ }
124
+
125
+ func image( _ image: EmbedMedia ? ) -> Self {
126
+ var embed = self
127
+ embed. image = image
128
+ return embed
129
+ }
130
+
131
+ // TODO: accept URL in addition to string
132
+ func image( url: String , proxyURL: String ? = nil , height: Int ? = nil , width: Int ? = nil ) -> Self {
133
+ return image ( . init( url: url, proxy_url: proxyURL, height: height, width: width) )
134
+ }
135
+
136
+ func image( _ url: String ) -> Self {
137
+ return image ( url: url)
138
+ }
139
+
140
+ func thumbnail( _ thumbnail: EmbedMedia ? ) -> Self {
141
+ var embed = self
142
+ embed. thumbnail = thumbnail
143
+ return embed
144
+ }
145
+
146
+ func thumbnail( _ url: String ) -> Self {
147
+ return thumbnail ( url: url)
148
+ }
149
+
150
+ func thumbnail( url: String , proxyURL: String ? = nil , height: Int ? = nil , width: Int ? = nil ) -> Self {
151
+ return thumbnail ( . init( url: url, proxy_url: proxyURL, height: height, width: width) )
152
+ }
153
+
154
+ func video( _ video: EmbedMedia ? ) -> Self {
155
+ var embed = self
156
+ embed. video = video
157
+ return embed
158
+ }
159
+
160
+ func video( url: String , proxyURL: String ? = nil , height: Int ? = nil , width: Int ? = nil ) -> Self {
161
+ return video ( . init( url: url, proxy_url: proxyURL, height: height, width: width) )
162
+ }
163
+
164
+ func video( _ url: String ) -> Self {
165
+ return video ( url: url)
166
+ }
167
+
168
+ func provider( _ provider: EmbedProvider ? ) -> Self {
169
+ var embed = self
170
+ embed. provider = provider
171
+ return embed
172
+ }
173
+
174
+ func provider( name: String , url: String ? = nil ) -> Self {
175
+ return provider ( . init( name: name, url: url) )
176
+ }
177
+
178
+ func author( _ author: EmbedAuthor ? ) -> Self {
179
+ var embed = self
180
+ embed. author = author
181
+ return embed
182
+ }
183
+
184
+ func author( name: String , url: String ? = nil , iconURL: String ? = nil , proxyIconURL: String ? = nil ) -> Self {
185
+ return author ( . init( name: name, url: url, icon_url: iconURL, proxy_icon_url: proxyIconURL) )
186
+ }
106
187
}
0 commit comments