@discordjs/builders 1.2.0-dev.1660392311-8e69efd.0 → 1.2.0-dev.1660867915-673262d.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embed.cjs","sources":["../../../src/messages/embed/Embed.ts"],"sourcesContent":["import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';\nimport {\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedAuthorPredicate,\n\tembedFieldsArrayPredicate,\n\tembedFooterPredicate,\n\timageURLPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport type RGBTuple = [red: number, green: number, blue: number];\n\nexport interface IconData {\n\t/**\n\t * The URL of the icon\n\t */\n\ticonURL?: string;\n\t/**\n\t * The proxy URL of the icon\n\t */\n\tproxyIconURL?: string;\n}\n\nexport type EmbedAuthorData = Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;\n\nexport type EmbedFooterData = Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;\n\nexport interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {\n\t/**\n\t * The proxy URL for the image\n\t */\n\tproxyURL?: string;\n}\n/**\n * Represents a embed in a message (image/video preview, rich embed, etc.)\n */\nexport class EmbedBuilder {\n\tpublic readonly data: APIEmbed;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.data = { ...data };\n\t\tif (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * Adds fields to the embed (max 25)\n\t *\n\t * @param fields The fields to add\n\t */\n\tpublic addFields(...fields: RestOrArray<APIEmbedField>): this {\n\t\tfields = normalizeArray(fields);\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\n\t\tif (this.data.fields) this.data.fields.push(...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed (max 25)\n\t *\n\t * @param index The index to start at\n\t * @param deleteCount The number of fields to remove\n\t * @param fields The replacing field objects\n\t */\n\tpublic spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length - deleteCount, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\t\tif (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the embed's fields (max 25).\n\t * @param fields The fields to set\n\t */\n\tpublic setFields(...fields: RestOrArray<APIEmbedField>) {\n\t\tthis.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed\n\t *\n\t * @param options The options for the author\n\t */\n\n\tpublic setAuthor(options: EmbedAuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedAuthorPredicate.parse(options);\n\n\t\tthis.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed\n\t *\n\t * @param color The color of the embed\n\t */\n\tpublic setColor(color: number | RGBTuple | null): this {\n\t\t// Data assertions\n\t\tcolorPredicate.parse(color);\n\n\t\tif (Array.isArray(color)) {\n\t\t\tconst [red, green, blue] = color;\n\t\t\tthis.data.color = (red << 16) + (green << 8) + blue;\n\t\t\treturn this;\n\t\t}\n\t\tthis.data.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed\n\t *\n\t * @param description The description\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tdescriptionPredicate.parse(description);\n\n\t\tthis.data.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed\n\t *\n\t * @param options The options for the footer\n\t */\n\tpublic setFooter(options: EmbedFooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedFooterPredicate.parse(options);\n\n\t\tthis.data.footer = { text: options.text, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed\n\t *\n\t * @param url The URL of the image\n\t */\n\tpublic setImage(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed\n\t *\n\t * @param url The URL of the thumbnail\n\t */\n\tpublic setThumbnail(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed\n\t *\n\t * @param timestamp The timestamp or date\n\t */\n\tpublic setTimestamp(timestamp: number | Date | null = Date.now()): this {\n\t\t// Data assertions\n\t\ttimestampPredicate.parse(timestamp);\n\n\t\tthis.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the title of this embed\n\t *\n\t * @param title The title\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\ttitlePredicate.parse(title);\n\n\t\tthis.data.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed\n\t *\n\t * @param url The URL\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\turlPredicate.parse(url);\n\n\t\tthis.data.url = url ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Transforms the embed to a plain object\n\t */\n\tpublic toJSON(): APIEmbed {\n\t\treturn { ...this.data };\n\t}\n}\n"],"names":["normalizeArray","validateFieldLength","embedFieldsArrayPredicate","embedAuthorPredicate","colorPredicate","descriptionPredicate","embedFooterPredicate","imageURLPredicate","timestampPredicate","titlePredicate","urlPredicate"],"mappings":";;;;;;;AAaO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,IAAI,CAAC,SAAS;AACtB,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AACnE,GAAG;AACH,EAAE,SAAS,CAAC,GAAG,MAAM,EAAE;AACvB,IAAI,MAAM,GAAGA,6BAAc,CAAC,MAAM,CAAC,CAAC;AACpC,IAAIC,8BAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACzD,IAAIC,oCAAyB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5C,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM;AACxB,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;AACvC;AACA,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AAChC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,YAAY,C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type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';\nimport {\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedAuthorPredicate,\n\tembedFieldsArrayPredicate,\n\tembedFooterPredicate,\n\timageURLPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport type RGBTuple = [red: number, green: number, blue: number];\n\nexport interface IconData {\n\t/**\n\t * The URL of the icon\n\t */\n\ticonURL?: string;\n\t/**\n\t * The proxy URL of the icon\n\t */\n\tproxyIconURL?: string;\n}\n\nexport type EmbedAuthorData = Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;\n\nexport type EmbedFooterData = Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;\n\nexport interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {\n\t/**\n\t * The proxy URL for the image\n\t */\n\tproxyURL?: string;\n}\n/**\n * Represents a embed in a message (image/video preview, rich embed, etc.)\n */\nexport class EmbedBuilder {\n\tpublic readonly data: APIEmbed;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.data = { ...data };\n\t\tif (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * Appends fields to the embed\n\t *\n\t * @remarks\n\t * This method accepts either an array of fields or a variable number of field parameters.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * @example\n\t * Using an array\n\t * ```ts\n\t * const fields: APIEmbedField[] = ...;\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(fields);\n\t * ```\n\t *\n\t * @example\n\t * Using rest parameters (variadic)\n\t * ```ts\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(\n\t * \t\t{ name: 'Field 1', value: 'Value 1' },\n\t * \t\t{ name: 'Field 2', value: 'Value 2' },\n\t * \t);\n\t * ```\n\t *\n\t * @param fields The fields to add\n\t */\n\tpublic addFields(...fields: RestOrArray<APIEmbedField>): this {\n\t\tfields = normalizeArray(fields);\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\n\t\tif (this.data.fields) this.data.fields.push(...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed.\n\t *\n\t * @remarks\n\t * This method behaves similarly\n\t * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * It's useful for modifying and adjusting order of the already-existing fields of an embed.\n\t *\n\t * @example\n\t * Remove the first field\n\t * ```ts\n\t * embed.spliceFields(0, 1);\n\t * ```\n\t *\n\t * @example\n\t * Remove the first n fields\n\t * ```ts\n\t * const n = 4\n\t * embed.spliceFields(0, n);\n\t * ```\n\t *\n\t * @example\n\t * Remove the last field\n\t * ```ts\n\t * embed.spliceFields(-1, 1);\n\t * ```\n\t *\n\t * @param index The index to start at\n\t * @param deleteCount The number of fields to remove\n\t * @param fields The replacing field objects\n\t */\n\tpublic spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length - deleteCount, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\t\tif (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the embed's fields\n\t *\n\t * @remarks\n\t * This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,\n\t * it splices the entire array of fields, replacing them with the provided fields.\n\t *\n\t * You can set a maximum of 25 fields.\n\t *\n\t * @param fields The fields to set\n\t */\n\tpublic setFields(...fields: RestOrArray<APIEmbedField>) {\n\t\tthis.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed\n\t *\n\t * @param options The options for the author\n\t */\n\n\tpublic setAuthor(options: EmbedAuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedAuthorPredicate.parse(options);\n\n\t\tthis.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed\n\t *\n\t * @param color The color of the embed\n\t */\n\tpublic setColor(color: number | RGBTuple | null): this {\n\t\t// Data assertions\n\t\tcolorPredicate.parse(color);\n\n\t\tif (Array.isArray(color)) {\n\t\t\tconst [red, green, blue] = color;\n\t\t\tthis.data.color = (red << 16) + (green << 8) + blue;\n\t\t\treturn this;\n\t\t}\n\t\tthis.data.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed\n\t *\n\t * @param description The description\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tdescriptionPredicate.parse(description);\n\n\t\tthis.data.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed\n\t *\n\t * @param options The options for the footer\n\t */\n\tpublic setFooter(options: EmbedFooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedFooterPredicate.parse(options);\n\n\t\tthis.data.footer = { text: options.text, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed\n\t *\n\t * @param url The URL of the image\n\t */\n\tpublic setImage(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed\n\t *\n\t * @param url The URL of the thumbnail\n\t */\n\tpublic setThumbnail(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed\n\t *\n\t * @param timestamp The timestamp or date\n\t */\n\tpublic setTimestamp(timestamp: number | Date | null = Date.now()): this {\n\t\t// Data assertions\n\t\ttimestampPredicate.parse(timestamp);\n\n\t\tthis.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the title of this embed\n\t *\n\t * @param title The title\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\ttitlePredicate.parse(title);\n\n\t\tthis.data.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed\n\t *\n\t * @param url The URL\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\turlPredicate.parse(url);\n\n\t\tthis.data.url = url ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Transforms the embed to a plain object\n\t */\n\tpublic toJSON(): APIEmbed {\n\t\treturn { ...this.data };\n\t}\n}\n"],"names":["normalizeArray","validateFieldLength","embedFieldsArrayPredicate","embedAuthorPredicate","colorPredicate","descriptionPredicate","embedFooterPredicate","imageURLPredicate","timestampPredicate","titlePredicate","urlPredicate"],"mappings":";;;;;;;AAaO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,IAAI,CAAC,SA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I,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAIC,yBAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC;AACtC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,CAAC,GAAG,EAAE;AACd,IAAIC,uBAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC;AAClC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5B,GAAG;AACH;;;;"}
|
|
@@ -28,13 +28,61 @@ export declare class EmbedBuilder {
|
|
|
28
28
|
readonly data: APIEmbed;
|
|
29
29
|
constructor(data?: APIEmbed);
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Appends fields to the embed
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* This method accepts either an array of fields or a variable number of field parameters.
|
|
35
|
+
* The maximum amount of fields that can be added is 25.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* Using an array
|
|
39
|
+
* ```ts
|
|
40
|
+
* const fields: APIEmbedField[] = ...;
|
|
41
|
+
* const embed = new EmbedBuilder()
|
|
42
|
+
* .addFields(fields);
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* Using rest parameters (variadic)
|
|
47
|
+
* ```ts
|
|
48
|
+
* const embed = new EmbedBuilder()
|
|
49
|
+
* .addFields(
|
|
50
|
+
* { name: 'Field 1', value: 'Value 1' },
|
|
51
|
+
* { name: 'Field 2', value: 'Value 2' },
|
|
52
|
+
* );
|
|
53
|
+
* ```
|
|
32
54
|
*
|
|
33
55
|
* @param fields The fields to add
|
|
34
56
|
*/
|
|
35
57
|
addFields(...fields: RestOrArray<APIEmbedField>): this;
|
|
36
58
|
/**
|
|
37
|
-
* Removes, replaces, or inserts fields in the embed
|
|
59
|
+
* Removes, replaces, or inserts fields in the embed.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* This method behaves similarly
|
|
63
|
+
* to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.
|
|
64
|
+
* The maximum amount of fields that can be added is 25.
|
|
65
|
+
*
|
|
66
|
+
* It's useful for modifying and adjusting order of the already-existing fields of an embed.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* Remove the first field
|
|
70
|
+
* ```ts
|
|
71
|
+
* embed.spliceFields(0, 1);
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* Remove the first n fields
|
|
76
|
+
* ```ts
|
|
77
|
+
* const n = 4
|
|
78
|
+
* embed.spliceFields(0, n);
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* Remove the last field
|
|
83
|
+
* ```ts
|
|
84
|
+
* embed.spliceFields(-1, 1);
|
|
85
|
+
* ```
|
|
38
86
|
*
|
|
39
87
|
* @param index The index to start at
|
|
40
88
|
* @param deleteCount The number of fields to remove
|
|
@@ -42,7 +90,14 @@ export declare class EmbedBuilder {
|
|
|
42
90
|
*/
|
|
43
91
|
spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this;
|
|
44
92
|
/**
|
|
45
|
-
* Sets the embed's fields
|
|
93
|
+
* Sets the embed's fields
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,
|
|
97
|
+
* it splices the entire array of fields, replacing them with the provided fields.
|
|
98
|
+
*
|
|
99
|
+
* You can set a maximum of 25 fields.
|
|
100
|
+
*
|
|
46
101
|
* @param fields The fields to set
|
|
47
102
|
*/
|
|
48
103
|
setFields(...fields: RestOrArray<APIEmbedField>): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embed.d.ts","sourceRoot":"","sources":["../../../src/messages/embed/Embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAapH,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7E,oBAAY,QAAQ,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,oBAAY,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,gBAAgB,CAAC,GAAG,QAAQ,CAAC;AAE7F,oBAAY,kBAAkB,GAAG,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AAEvE,oBAAY,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,gBAAgB,CAAC,GAAG,QAAQ,CAAC;AAE7F,oBAAY,kBAAkB,GAAG,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AAEvE,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC;IACvE;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AACD;;GAEG;AACH,qBAAa,YAAY;IACxB,SAAgB,IAAI,EAAE,QAAQ,CAAC;gBAEZ,IAAI,GAAE,QAAa;IAKtC
|
|
1
|
+
{"version":3,"file":"Embed.d.ts","sourceRoot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AAG,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;IAWzF;;;;;;;;;;OAUG;IACI,SAAS,CAAC,GAAG,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC;IAKtD;;;;OAIG;IAEI,SAAS,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,GAAG,IAAI;IAa1D;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI;IAatD;;;;OAIG;IACI,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQvD;;;;OAIG;IACI,SAAS,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,GAAG,IAAI;IAa1D;;;;OAIG;IACI,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQzC;;;;OAIG;IACI,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQ7C;;;;OAIG;IACI,YAAY,CAAC,SAAS,GAAE,MAAM,GAAG,IAAI,GAAG,IAAiB,GAAG,IAAI;IAQvE;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQ3C;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQvC;;OAEG;IACI,MAAM,IAAI,QAAQ;CAGzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embed.mjs","sources":["../../../src/messages/embed/Embed.ts"],"sourcesContent":["import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';\nimport {\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedAuthorPredicate,\n\tembedFieldsArrayPredicate,\n\tembedFooterPredicate,\n\timageURLPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport type RGBTuple = [red: number, green: number, blue: number];\n\nexport interface IconData {\n\t/**\n\t * The URL of the icon\n\t */\n\ticonURL?: string;\n\t/**\n\t * The proxy URL of the icon\n\t */\n\tproxyIconURL?: string;\n}\n\nexport type EmbedAuthorData = Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;\n\nexport type EmbedFooterData = Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;\n\nexport interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {\n\t/**\n\t * The proxy URL for the image\n\t */\n\tproxyURL?: string;\n}\n/**\n * Represents a embed in a message (image/video preview, rich embed, etc.)\n */\nexport class EmbedBuilder {\n\tpublic readonly data: APIEmbed;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.data = { ...data };\n\t\tif (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * Adds fields to the embed (max 25)\n\t *\n\t * @param fields The fields to add\n\t */\n\tpublic addFields(...fields: RestOrArray<APIEmbedField>): this {\n\t\tfields = normalizeArray(fields);\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\n\t\tif (this.data.fields) this.data.fields.push(...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed (max 25)\n\t *\n\t * @param index The index to start at\n\t * @param deleteCount The number of fields to remove\n\t * @param fields The replacing field objects\n\t */\n\tpublic spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length - deleteCount, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\t\tif (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the embed's fields (max 25).\n\t * @param fields The fields to set\n\t */\n\tpublic setFields(...fields: RestOrArray<APIEmbedField>) {\n\t\tthis.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed\n\t *\n\t * @param options The options for the author\n\t */\n\n\tpublic setAuthor(options: EmbedAuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedAuthorPredicate.parse(options);\n\n\t\tthis.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed\n\t *\n\t * @param color The color of the embed\n\t */\n\tpublic setColor(color: number | RGBTuple | null): this {\n\t\t// Data assertions\n\t\tcolorPredicate.parse(color);\n\n\t\tif (Array.isArray(color)) {\n\t\t\tconst [red, green, blue] = color;\n\t\t\tthis.data.color = (red << 16) + (green << 8) + blue;\n\t\t\treturn this;\n\t\t}\n\t\tthis.data.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed\n\t *\n\t * @param description The description\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tdescriptionPredicate.parse(description);\n\n\t\tthis.data.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed\n\t *\n\t * @param options The options for the footer\n\t */\n\tpublic setFooter(options: EmbedFooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedFooterPredicate.parse(options);\n\n\t\tthis.data.footer = { text: options.text, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed\n\t *\n\t * @param url The URL of the image\n\t */\n\tpublic setImage(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed\n\t *\n\t * @param url The URL of the thumbnail\n\t */\n\tpublic setThumbnail(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed\n\t *\n\t * @param timestamp The timestamp or date\n\t */\n\tpublic setTimestamp(timestamp: number | Date | null = Date.now()): this {\n\t\t// Data assertions\n\t\ttimestampPredicate.parse(timestamp);\n\n\t\tthis.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the title of this embed\n\t *\n\t * @param title The title\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\ttitlePredicate.parse(title);\n\n\t\tthis.data.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed\n\t *\n\t * @param url The URL\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\turlPredicate.parse(url);\n\n\t\tthis.data.url = url ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Transforms the embed to a plain object\n\t */\n\tpublic toJSON(): APIEmbed {\n\t\treturn { ...this.data };\n\t}\n}\n"],"names":[],"mappings":";;;AAaO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,IAAI,CAAC,SAAS;AACtB,MA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G;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC;AACtC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,CAAC,GAAG,EAAE;AACd,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC;AAClC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5B,GAAG;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"Embed.mjs","sources":["../../../src/messages/embed/Embed.ts"],"sourcesContent":["import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';\nimport {\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedAuthorPredicate,\n\tembedFieldsArrayPredicate,\n\tembedFooterPredicate,\n\timageURLPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport type RGBTuple = [red: number, green: number, blue: number];\n\nexport interface IconData {\n\t/**\n\t * The URL of the icon\n\t */\n\ticonURL?: string;\n\t/**\n\t * The proxy URL of the icon\n\t */\n\tproxyIconURL?: string;\n}\n\nexport type EmbedAuthorData = Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;\n\nexport type EmbedFooterData = Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;\n\nexport interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {\n\t/**\n\t * The proxy URL for the image\n\t */\n\tproxyURL?: string;\n}\n/**\n * Represents a embed in a message (image/video preview, rich embed, etc.)\n */\nexport class EmbedBuilder {\n\tpublic readonly data: APIEmbed;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.data = { ...data };\n\t\tif (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * Appends fields to the embed\n\t *\n\t * @remarks\n\t * This method accepts either an array of fields or a variable number of field parameters.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * @example\n\t * Using an array\n\t * ```ts\n\t * const fields: APIEmbedField[] = ...;\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(fields);\n\t * ```\n\t *\n\t * @example\n\t * Using rest parameters (variadic)\n\t * ```ts\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(\n\t * \t\t{ name: 'Field 1', value: 'Value 1' },\n\t * \t\t{ name: 'Field 2', value: 'Value 2' },\n\t * \t);\n\t * ```\n\t *\n\t * @param fields The fields to add\n\t */\n\tpublic addFields(...fields: RestOrArray<APIEmbedField>): this {\n\t\tfields = normalizeArray(fields);\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\n\t\tif (this.data.fields) this.data.fields.push(...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed.\n\t *\n\t * @remarks\n\t * This method behaves similarly\n\t * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * It's useful for modifying and adjusting order of the already-existing fields of an embed.\n\t *\n\t * @example\n\t * Remove the first field\n\t * ```ts\n\t * embed.spliceFields(0, 1);\n\t * ```\n\t *\n\t * @example\n\t * Remove the first n fields\n\t * ```ts\n\t * const n = 4\n\t * embed.spliceFields(0, n);\n\t * ```\n\t *\n\t * @example\n\t * Remove the last field\n\t * ```ts\n\t * embed.spliceFields(-1, 1);\n\t * ```\n\t *\n\t * @param index The index to start at\n\t * @param deleteCount The number of fields to remove\n\t * @param fields The replacing field objects\n\t */\n\tpublic spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length - deleteCount, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\t\tif (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the embed's fields\n\t *\n\t * @remarks\n\t * This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,\n\t * it splices the entire array of fields, replacing them with the provided fields.\n\t *\n\t * You can set a maximum of 25 fields.\n\t *\n\t * @param fields The fields to set\n\t */\n\tpublic setFields(...fields: RestOrArray<APIEmbedField>) {\n\t\tthis.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed\n\t *\n\t * @param options The options for the author\n\t */\n\n\tpublic setAuthor(options: EmbedAuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedAuthorPredicate.parse(options);\n\n\t\tthis.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed\n\t *\n\t * @param color The color of the embed\n\t */\n\tpublic setColor(color: number | RGBTuple | null): this {\n\t\t// Data assertions\n\t\tcolorPredicate.parse(color);\n\n\t\tif (Array.isArray(color)) {\n\t\t\tconst [red, green, blue] = color;\n\t\t\tthis.data.color = (red << 16) + (green << 8) + blue;\n\t\t\treturn this;\n\t\t}\n\t\tthis.data.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed\n\t *\n\t * @param description The description\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tdescriptionPredicate.parse(description);\n\n\t\tthis.data.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed\n\t *\n\t * @param options The options for the footer\n\t */\n\tpublic setFooter(options: EmbedFooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedFooterPredicate.parse(options);\n\n\t\tthis.data.footer = { text: options.text, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed\n\t *\n\t * @param url The URL of the image\n\t */\n\tpublic setImage(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed\n\t *\n\t * @param url The URL of the thumbnail\n\t */\n\tpublic setThumbnail(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed\n\t *\n\t * @param timestamp The timestamp or date\n\t */\n\tpublic setTimestamp(timestamp: number | Date | null = Date.now()): this {\n\t\t// Data assertions\n\t\ttimestampPredicate.parse(timestamp);\n\n\t\tthis.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the title of this embed\n\t *\n\t * @param title The title\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\ttitlePredicate.parse(title);\n\n\t\tthis.data.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed\n\t *\n\t * @param url The URL\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\turlPredicate.parse(url);\n\n\t\tthis.data.url = url ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Transforms the embed to a plain object\n\t */\n\tpublic toJSON(): APIEmbed {\n\t\treturn { ...this.data };\n\t}\n}\n"],"names":[],"mappings":";;;AAaO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,IAAI,CAAC,SAAS;AACtB,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AACnE,GAAG;AACH,EAAE,SAAS,CAAC,GAAG,MAAM,EAAE;AACvB,IAAI,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,IAAI,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACzD,IAAI,yBAAyB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5C,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM;AACxB,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;AACvC;AACA,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AAChC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE;AAC9C,IAAI,mBAAmB,CAAC,MAAM,CAAC,MAAM,GAAG,WAAW,EAAE,IAAI,C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ACpB,IAAI,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACjC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;AACjD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,YAAY,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;AACvC,IAAI,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACxC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC;AACjF,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC;AACtC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,CAAC,GAAG,EAAE;AACd,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC;AAClC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5B,GAAG;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discordjs/builders",
|
|
3
|
-
"version": "1.2.0-dev.
|
|
3
|
+
"version": "1.2.0-dev.1660867915-673262d.0",
|
|
4
4
|
"description": "A set of builders that you can use when creating your bot",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest run",
|
|
7
7
|
"build": "unbuild",
|
|
8
|
-
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
|
9
|
-
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
|
8
|
+
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
|
9
|
+
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
|
10
10
|
"fmt": "yarn format",
|
|
11
11
|
"docs": "downlevel-dts . docs --to=3.7 && docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript && api-extractor run --local",
|
|
12
12
|
"prepack": "yarn lint && yarn test && yarn build",
|
|
@@ -55,24 +55,30 @@
|
|
|
55
55
|
"homepage": "https://discord.js.org",
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@sapphire/shapeshift": "^3.5.1",
|
|
58
|
-
"discord-api-types": "^0.
|
|
58
|
+
"discord-api-types": "^0.37.2",
|
|
59
59
|
"fast-deep-equal": "^3.1.3",
|
|
60
60
|
"ts-mixer": "^6.0.1",
|
|
61
61
|
"tslib": "^2.4.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@discordjs/docgen": "^0.12.
|
|
64
|
+
"@discordjs/docgen": "^0.12.1",
|
|
65
65
|
"@favware/cliff-jumper": "^1.8.6",
|
|
66
66
|
"@microsoft/api-extractor": "^7.29.2",
|
|
67
|
-
"@types/node": "^16.11.
|
|
68
|
-
"
|
|
67
|
+
"@types/node": "^16.11.48",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
69
|
+
"@typescript-eslint/parser": "^5.33.0",
|
|
70
|
+
"@vitest/coverage-c8": "^0.22.0",
|
|
69
71
|
"downlevel-dts": "^0.10.0",
|
|
70
|
-
"eslint": "^8.
|
|
72
|
+
"eslint": "^8.22.0",
|
|
73
|
+
"eslint-config-marine": "^9.4.1",
|
|
74
|
+
"eslint-config-prettier": "^8.5.0",
|
|
75
|
+
"eslint-import-resolver-typescript": "^3.4.1",
|
|
76
|
+
"eslint-plugin-import": "^2.26.0",
|
|
71
77
|
"prettier": "^2.7.1",
|
|
72
78
|
"rollup-plugin-typescript2": "0.32.1",
|
|
73
79
|
"typescript": "^4.7.4",
|
|
74
|
-
"unbuild": "^0.8.
|
|
75
|
-
"vitest": "^0.
|
|
80
|
+
"unbuild": "^0.8.8",
|
|
81
|
+
"vitest": "^0.22.0"
|
|
76
82
|
},
|
|
77
83
|
"engines": {
|
|
78
84
|
"node": ">=16.9.0"
|