@@ -6,31 +6,26 @@ const isEqual = require('fast-deep-equal');
6
6
* Represents an embed.
7
7
*/
8
8
class Embed {
9
- /**
10
- * Creates a new embed object
11
- * @param {APIEmbed } data API embed data
12
- * @private
13
- */
14
9
constructor ( data ) {
15
10
/**
16
- * The API embed data
11
+ * The API embed data.
17
12
* @type {APIEmbed }
18
13
* @readonly
19
14
*/
20
15
this . data = { ...data } ;
21
16
}
22
17
23
18
/**
24
- * An array of fields of this embed
25
- * @type {? Array<APIEmbedField> }
19
+ * An array of fields of this embed.
20
+ * @type {Array<APIEmbedField> }
26
21
* @readonly
27
22
*/
28
23
get fields ( ) {
29
- return this . data . fields ?? null ;
24
+ return this . data . fields ?? [ ] ;
30
25
}
31
26
32
27
/**
33
- * The embed title
28
+ * The title of this embed.
34
29
* @type {?string }
35
30
* @readonly
36
31
*/
@@ -39,7 +34,7 @@ class Embed {
39
34
}
40
35
41
36
/**
42
- * The embed description
37
+ * The description of this embed.
43
38
* @type {?string }
44
39
* @readonly
45
40
*/
@@ -48,7 +43,7 @@ class Embed {
48
43
}
49
44
50
45
/**
51
- * The embed URL
46
+ * The URL of this embed.
52
47
* @type {?string }
53
48
* @readonly
54
49
*/
@@ -57,7 +52,7 @@ class Embed {
57
52
}
58
53
59
54
/**
60
- * The embed color
55
+ * The color of this embed.
61
56
* @type {?number }
62
57
* @readonly
63
58
*/
@@ -66,7 +61,7 @@ class Embed {
66
61
}
67
62
68
63
/**
69
- * The timestamp of the embed in an ISO 8601 format
64
+ * The timestamp of this embed. This is in an ISO 8601 format.
70
65
* @type {?string }
71
66
* @readonly
72
67
*/
@@ -75,8 +70,16 @@ class Embed {
75
70
}
76
71
77
72
/**
78
- * The embed thumbnail data
79
- * @type {?EmbedImageData }
73
+ * @typedef {Object } EmbedAssetData
74
+ * @property {?string } url The URL of the image
75
+ * @property {?string } proxyURL The proxy URL of the image
76
+ * @property {?string } height The height of the image
77
+ * @property {?string } width The width of the image
78
+ */
79
+
80
+ /**
81
+ * The thumbnail of this embed.
82
+ * @type {?EmbedAssetData }
80
83
* @readonly
81
84
*/
82
85
get thumbnail ( ) {
@@ -90,8 +93,8 @@ class Embed {
90
93
}
91
94
92
95
/**
93
- * The embed image data
94
- * @type {?EmbedImageData }
96
+ * The image of this embed.
97
+ * @type {?EmbedAssetData }
95
98
* @readonly
96
99
*/
97
100
get image ( ) {
@@ -105,16 +108,30 @@ class Embed {
105
108
}
106
109
107
110
/**
108
- * Received video data
109
- * @type {?EmbedVideoData }
111
+ * The video of this embed.
112
+ * @type {?EmbedAssetData }
110
113
* @readonly
111
114
*/
112
115
get video ( ) {
113
- return this . data . video ?? null ;
116
+ if ( ! this . data . video ) return null ;
117
+ return {
118
+ url : this . data . image . url ,
119
+ proxyURL : this . data . image . proxy_url ,
120
+ height : this . data . image . height ,
121
+ width : this . data . image . width ,
122
+ } ;
114
123
}
115
124
116
125
/**
117
- * The embed author data
126
+ * @typedef {Object } EmbedAuthorData
127
+ * @property {string } name The name of the author
128
+ * @property {?string } url The URL of the author
129
+ * @property {?string } iconURL The icon URL of the author
130
+ * @property {?string } proxyIconURL The proxy icon URL of the author
131
+ */
132
+
133
+ /**
134
+ * The author of this embed.
118
135
* @type {?EmbedAuthorData }
119
136
* @readonly
120
137
*/
@@ -129,16 +146,23 @@ class Embed {
129
146
}
130
147
131
148
/**
132
- * Received data about the embed provider
133
- * @type {?EmbedProvider }
149
+ * The provider of this embed.
150
+ * @type {?APIEmbedProvider }
134
151
* @readonly
135
152
*/
136
153
get provider ( ) {
137
154
return this . data . provider ?? null ;
138
155
}
139
156
140
157
/**
141
- * The embed footer data
158
+ * @typedef {Object } EmbedFooterData
159
+ * @property {string } text The text of the footer
160
+ * @property {?string } iconURL The URL of the icon
161
+ * @property {?string } proxyIconURL The proxy URL of the icon
162
+ */
163
+
164
+ /**
165
+ * The footer of this embed.
142
166
* @type {?EmbedFooterData }
143
167
* @readonly
144
168
*/
@@ -152,7 +176,7 @@ class Embed {
152
176
}
153
177
154
178
/**
155
- * The accumulated length for the embed title, description, fields, footer text, and author name
179
+ * The accumulated length for the embed title, description, fields, footer text, and author name.
156
180
* @type {number }
157
181
* @readonly
158
182
*/
@@ -167,7 +191,7 @@ class Embed {
167
191
}
168
192
169
193
/**
170
- * The hex color of the current color of the embed
194
+ * The hex color of this embed.
171
195
* @type {?string }
172
196
* @readonly
173
197
*/
@@ -178,15 +202,15 @@ class Embed {
178
202
}
179
203
180
204
/**
181
- * Returns the API-compatible JSON for this embed
205
+ * Returns the API-compatible JSON for this embed.
182
206
* @returns {APIEmbed }
183
207
*/
184
208
toJSON ( ) {
185
209
return { ...this . data } ;
186
210
}
187
211
188
212
/**
189
- * Whether or not the given embeds are equal
213
+ * Whether the given embeds are equal.
190
214
* @param {Embed|APIEmbed } other The embed to compare against
191
215
* @returns {boolean }
192
216
*/
0 commit comments