@discordjs/builders 0.6.0 → 0.8.2

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.
Files changed (81) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +28 -8
  3. package/dist/index.d.ts +818 -15
  4. package/dist/index.js +4 -19
  5. package/dist/index.js.map +7 -1
  6. package/dist/index.mjs +4 -36
  7. package/dist/index.mjs.map +7 -0
  8. package/package.json +63 -51
  9. package/dist/index.d.ts.map +0 -1
  10. package/dist/interactions/slashCommands/Assertions.d.ts +0 -12
  11. package/dist/interactions/slashCommands/Assertions.d.ts.map +0 -1
  12. package/dist/interactions/slashCommands/Assertions.js +0 -63
  13. package/dist/interactions/slashCommands/Assertions.js.map +0 -1
  14. package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts +0 -63
  15. package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts.map +0 -1
  16. package/dist/interactions/slashCommands/SlashCommandBuilder.js +0 -113
  17. package/dist/interactions/slashCommands/SlashCommandBuilder.js.map +0 -1
  18. package/dist/interactions/slashCommands/SlashCommandSubcommands.d.ts +0 -64
  19. package/dist/interactions/slashCommands/SlashCommandSubcommands.d.ts.map +0 -1
  20. package/dist/interactions/slashCommands/SlashCommandSubcommands.js +0 -123
  21. package/dist/interactions/slashCommands/SlashCommandSubcommands.js.map +0 -1
  22. package/dist/interactions/slashCommands/mixins/CommandOptionBase.d.ts +0 -20
  23. package/dist/interactions/slashCommands/mixins/CommandOptionBase.d.ts.map +0 -1
  24. package/dist/interactions/slashCommands/mixins/CommandOptionBase.js +0 -48
  25. package/dist/interactions/slashCommands/mixins/CommandOptionBase.js.map +0 -1
  26. package/dist/interactions/slashCommands/mixins/CommandOptionWithChoices.d.ts +0 -25
  27. package/dist/interactions/slashCommands/mixins/CommandOptionWithChoices.d.ts.map +0 -1
  28. package/dist/interactions/slashCommands/mixins/CommandOptionWithChoices.js +0 -71
  29. package/dist/interactions/slashCommands/mixins/CommandOptionWithChoices.js.map +0 -1
  30. package/dist/interactions/slashCommands/mixins/CommandOptions.d.ts +0 -54
  31. package/dist/interactions/slashCommands/mixins/CommandOptions.d.ts.map +0 -1
  32. package/dist/interactions/slashCommands/mixins/CommandOptions.js +0 -91
  33. package/dist/interactions/slashCommands/mixins/CommandOptions.js.map +0 -1
  34. package/dist/interactions/slashCommands/mixins/NameAndDescription.d.ts +0 -15
  35. package/dist/interactions/slashCommands/mixins/NameAndDescription.d.ts.map +0 -1
  36. package/dist/interactions/slashCommands/mixins/NameAndDescription.js +0 -42
  37. package/dist/interactions/slashCommands/mixins/NameAndDescription.js.map +0 -1
  38. package/dist/interactions/slashCommands/options/boolean.d.ts +0 -7
  39. package/dist/interactions/slashCommands/options/boolean.d.ts.map +0 -1
  40. package/dist/interactions/slashCommands/options/boolean.js +0 -18
  41. package/dist/interactions/slashCommands/options/boolean.js.map +0 -1
  42. package/dist/interactions/slashCommands/options/channel.d.ts +0 -7
  43. package/dist/interactions/slashCommands/options/channel.d.ts.map +0 -1
  44. package/dist/interactions/slashCommands/options/channel.js +0 -18
  45. package/dist/interactions/slashCommands/options/channel.js.map +0 -1
  46. package/dist/interactions/slashCommands/options/integer.d.ts +0 -7
  47. package/dist/interactions/slashCommands/options/integer.d.ts.map +0 -1
  48. package/dist/interactions/slashCommands/options/integer.js +0 -18
  49. package/dist/interactions/slashCommands/options/integer.js.map +0 -1
  50. package/dist/interactions/slashCommands/options/mentionable.d.ts +0 -7
  51. package/dist/interactions/slashCommands/options/mentionable.d.ts.map +0 -1
  52. package/dist/interactions/slashCommands/options/mentionable.js +0 -18
  53. package/dist/interactions/slashCommands/options/mentionable.js.map +0 -1
  54. package/dist/interactions/slashCommands/options/number.d.ts +0 -7
  55. package/dist/interactions/slashCommands/options/number.d.ts.map +0 -1
  56. package/dist/interactions/slashCommands/options/number.js +0 -18
  57. package/dist/interactions/slashCommands/options/number.js.map +0 -1
  58. package/dist/interactions/slashCommands/options/role.d.ts +0 -7
  59. package/dist/interactions/slashCommands/options/role.d.ts.map +0 -1
  60. package/dist/interactions/slashCommands/options/role.js +0 -18
  61. package/dist/interactions/slashCommands/options/role.js.map +0 -1
  62. package/dist/interactions/slashCommands/options/string.d.ts +0 -7
  63. package/dist/interactions/slashCommands/options/string.d.ts.map +0 -1
  64. package/dist/interactions/slashCommands/options/string.js +0 -18
  65. package/dist/interactions/slashCommands/options/string.js.map +0 -1
  66. package/dist/interactions/slashCommands/options/user.d.ts +0 -7
  67. package/dist/interactions/slashCommands/options/user.d.ts.map +0 -1
  68. package/dist/interactions/slashCommands/options/user.js +0 -18
  69. package/dist/interactions/slashCommands/options/user.js.map +0 -1
  70. package/dist/messages/embed/Assertions.d.ts +0 -23
  71. package/dist/messages/embed/Assertions.d.ts.map +0 -1
  72. package/dist/messages/embed/Assertions.js +0 -26
  73. package/dist/messages/embed/Assertions.js.map +0 -1
  74. package/dist/messages/embed/Embed.d.ts +0 -140
  75. package/dist/messages/embed/Embed.d.ts.map +0 -1
  76. package/dist/messages/embed/Embed.js +0 -300
  77. package/dist/messages/embed/Embed.js.map +0 -1
  78. package/dist/messages/formatters.d.ts +0 -198
  79. package/dist/messages/formatters.d.ts.map +0 -1
  80. package/dist/messages/formatters.js +0 -181
  81. package/dist/messages/formatters.js.map +0 -1
@@ -1,23 +0,0 @@
1
- import type { APIEmbedField } from 'discord-api-types/v9';
2
- export declare const fieldNamePredicate: import("ow").StringPredicate;
3
- export declare const fieldValuePredicate: import("ow").StringPredicate;
4
- export declare const fieldInlinePredicate: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
5
- export declare const embedFieldPredicate: import("ow").ObjectPredicate<{
6
- name: string;
7
- value: string;
8
- inline: boolean | undefined;
9
- }>;
10
- export declare const embedFieldsArrayPredicate: import("ow").ArrayPredicate<{
11
- name: string;
12
- value: string;
13
- inline: boolean | undefined;
14
- }>;
15
- export declare function validateFieldLength(fields: APIEmbedField[], amountAdding: number): void;
16
- export declare const authorNamePredicate: import("ow").AnyPredicate<string | null>;
17
- export declare const urlPredicate: import("ow").AnyPredicate<string | null | undefined>;
18
- export declare const colorPredicate: import("ow").AnyPredicate<number | null>;
19
- export declare const descriptionPredicate: import("ow").AnyPredicate<string | null>;
20
- export declare const footerTextPredicate: import("ow").AnyPredicate<string | null>;
21
- export declare const timestampPredicate: import("ow").AnyPredicate<number | Date | null>;
22
- export declare const titlePredicate: import("ow").AnyPredicate<string | null>;
23
- //# sourceMappingURL=Assertions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Assertions.d.ts","sourceRoot":"/","sources":["messages/embed/Assertions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,eAAO,MAAM,kBAAkB,8BAAwC,CAAC;AAExE,eAAO,MAAM,mBAAmB,8BAAyC,CAAC;AAE1E,eAAO,MAAM,oBAAoB,iFAAsB,CAAC;AAExD,eAAO,MAAM,mBAAmB;;;;EAI9B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;EAAuC,CAAC;AAE9E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAEvF;AAED,eAAO,MAAM,mBAAmB,0CAAsC,CAAC;AAEvE,eAAO,MAAM,YAAY,sDAA4C,CAAC;AAEtE,eAAO,MAAM,cAAc,0CAA6E,CAAC;AAEzG,eAAO,MAAM,oBAAoB,0CAA0D,CAAC;AAE5F,eAAO,MAAM,mBAAmB,0CAA0D,CAAC;AAE3F,eAAO,MAAM,kBAAkB,iDAAsC,CAAC;AAEtE,eAAO,MAAM,cAAc,0CAAsC,CAAC"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.titlePredicate = exports.timestampPredicate = exports.footerTextPredicate = exports.descriptionPredicate = exports.colorPredicate = exports.urlPredicate = exports.authorNamePredicate = exports.validateFieldLength = exports.embedFieldsArrayPredicate = exports.embedFieldPredicate = exports.fieldInlinePredicate = exports.fieldValuePredicate = exports.fieldNamePredicate = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
6
- exports.fieldNamePredicate = ow_1.default.string.minLength(1).maxLength(256);
7
- exports.fieldValuePredicate = ow_1.default.string.minLength(1).maxLength(1024);
8
- exports.fieldInlinePredicate = ow_1.default.optional.boolean;
9
- exports.embedFieldPredicate = ow_1.default.object.exactShape({
10
- name: exports.fieldNamePredicate,
11
- value: exports.fieldValuePredicate,
12
- inline: exports.fieldInlinePredicate,
13
- });
14
- exports.embedFieldsArrayPredicate = ow_1.default.array.ofType(exports.embedFieldPredicate);
15
- function validateFieldLength(fields, amountAdding) {
16
- ow_1.default(fields.length + amountAdding, 'field amount', ow_1.default.number.lessThanOrEqual(25));
17
- }
18
- exports.validateFieldLength = validateFieldLength;
19
- exports.authorNamePredicate = ow_1.default.any(exports.fieldNamePredicate, ow_1.default.null);
20
- exports.urlPredicate = ow_1.default.any(ow_1.default.string.url, ow_1.default.nullOrUndefined);
21
- exports.colorPredicate = ow_1.default.any(ow_1.default.number.greaterThanOrEqual(0).lessThanOrEqual(0xffffff), ow_1.default.null);
22
- exports.descriptionPredicate = ow_1.default.any(ow_1.default.string.minLength(1).maxLength(4096), ow_1.default.null);
23
- exports.footerTextPredicate = ow_1.default.any(ow_1.default.string.minLength(1).maxLength(2048), ow_1.default.null);
24
- exports.timestampPredicate = ow_1.default.any(ow_1.default.number, ow_1.default.date, ow_1.default.null);
25
- exports.titlePredicate = ow_1.default.any(exports.fieldNamePredicate, ow_1.default.null);
26
- //# sourceMappingURL=Assertions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Assertions.js","sourceRoot":"/","sources":["messages/embed/Assertions.ts"],"names":[],"mappings":";;;;AACA,oDAAoB;AAEP,QAAA,kBAAkB,GAAG,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,S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AAC,GAAG,CAAC,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAE9E,QAAA,kBAAkB,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,EAAE,YAAE,CAAC,IAAI,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAEzD,QAAA,cAAc,GAAG,YAAE,CAAC,GAAG,CAAC,0BAAkB,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import type { APIEmbedField } from 'discord-api-types/v9';\nimport ow from 'ow';\n\nexport const fieldNamePredicate = ow.string.minLength(1).maxLength(256);\n\nexport const fieldValuePredicate = ow.string.minLength(1).maxLength(1024);\n\nexport const fieldInlinePredicate = ow.optional.boolean;\n\nexport const embedFieldPredicate = ow.object.exactShape({\n\tname: fieldNamePredicate,\n\tvalue: fieldValuePredicate,\n\tinline: fieldInlinePredicate,\n});\n\nexport const embedFieldsArrayPredicate = ow.array.ofType(embedFieldPredicate);\n\nexport function validateFieldLength(fields: APIEmbedField[], amountAdding: number): void {\n\tow(fields.length + amountAdding, 'field amount', ow.number.lessThanOrEqual(25));\n}\n\nexport const authorNamePredicate = ow.any(fieldNamePredicate, ow.null);\n\nexport const urlPredicate = ow.any(ow.string.url, ow.nullOrUndefined);\n\nexport const colorPredicate = ow.any(ow.number.greaterThanOrEqual(0).lessThanOrEqual(0xffffff), ow.null);\n\nexport const descriptionPredicate = ow.any(ow.string.minLength(1).maxLength(4096), ow.null);\n\nexport const footerTextPredicate = ow.any(ow.string.minLength(1).maxLength(2048), ow.null);\n\nexport const timestampPredicate = ow.any(ow.number, ow.date, ow.null);\n\nexport const titlePredicate = ow.any(fieldNamePredicate, ow.null);\n"]}
@@ -1,140 +0,0 @@
1
- import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage, APIEmbedProvider, APIEmbedThumbnail, APIEmbedVideo } from 'discord-api-types/v9';
2
- export interface AuthorOptions {
3
- name: string;
4
- url?: string;
5
- iconURL?: string;
6
- }
7
- export interface FooterOptions {
8
- text: string;
9
- iconURL?: string;
10
- }
11
- /**
12
- * Represents an embed in a message (image/video preview, rich embed, etc.)
13
- */
14
- export declare class Embed implements APIEmbed {
15
- /**
16
- * An array of fields of this embed.
17
- */
18
- fields: APIEmbedField[];
19
- /**
20
- * The embed title.
21
- */
22
- title?: string;
23
- /**
24
- * The embed description.
25
- */
26
- description?: string;
27
- /**
28
- * The embed url.
29
- */
30
- url?: string;
31
- /**
32
- * The embed color.
33
- */
34
- color?: number;
35
- /**
36
- * The timestamp of the embed in the ISO format.
37
- */
38
- timestamp?: string;
39
- /**
40
- * The embed thumbnail data.
41
- */
42
- thumbnail?: APIEmbedThumbnail;
43
- /**
44
- * The embed image data.
45
- */
46
- image?: APIEmbedImage;
47
- /**
48
- * Received video data.
49
- */
50
- video?: APIEmbedVideo;
51
- /**
52
- * The embed author data.
53
- */
54
- author?: APIEmbedAuthor;
55
- /**
56
- * Received data about the embed provider.
57
- */
58
- provider?: APIEmbedProvider;
59
- /**
60
- * The embed footer data.
61
- */
62
- footer?: APIEmbedFooter;
63
- constructor(data?: APIEmbed);
64
- /**
65
- * The accumulated length for the embed title, description, fields, footer text, and author name.
66
- */
67
- get length(): number;
68
- /**
69
- * Adds a field to the embed (max 25).
70
- * @param field The field to add.
71
- */
72
- addField(field: APIEmbedField): this;
73
- /**
74
- * Adds fields to the embed (max 25).
75
- * @param fields The fields to add.
76
- */
77
- addFields(...fields: APIEmbedField[]): this;
78
- /**
79
- * Removes, replaces, or inserts fields in the embed (max 25).
80
- * @param index The index to start at.
81
- * @param deleteCount The number of fields to remove.
82
- * @param fields The replacing field objects.
83
- */
84
- spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this;
85
- /**
86
- * Sets the author of this embed.
87
- * @param options The options for the author.
88
- */
89
- setAuthor(options: AuthorOptions | null): this;
90
- /**
91
- * Sets the color of this embed.
92
- * @param color The color of the embed.
93
- */
94
- setColor(color: number | null): this;
95
- /**
96
- * Sets the description of this embed.
97
- * @param description The description.
98
- */
99
- setDescription(description: string | null): this;
100
- /**
101
- * Sets the footer of this embed.
102
- * @param options The options for the footer.
103
- */
104
- setFooter(options: FooterOptions | null): this;
105
- /**
106
- * Sets the image of this embed.
107
- * @param url The URL of the image.
108
- */
109
- setImage(url: string | null): this;
110
- /**
111
- * Sets the thumbnail of this embed.
112
- * @param url The URL of the thumbnail.
113
- */
114
- setThumbnail(url: string | null): this;
115
- /**
116
- * Sets the timestamp of this embed.
117
- * @param timestamp The timestamp or date.
118
- */
119
- setTimestamp(timestamp?: number | Date | null): this;
120
- /**
121
- * Sets the title of this embed.
122
- * @param title The title.
123
- */
124
- setTitle(title: string | null): this;
125
- /**
126
- * Sets the URL of this embed.
127
- * @param url The URL.
128
- */
129
- setURL(url: string | null): this;
130
- /**
131
- * Transforms the embed to a plain object.
132
- */
133
- toJSON(): APIEmbed;
134
- /**
135
- * Normalizes field input and resolves strings.
136
- * @param fields Fields to normalize.
137
- */
138
- static normalizeFields(...fields: APIEmbedField[]): APIEmbedField[];
139
- }
140
- //# sourceMappingURL=Embed.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Embed.d.ts","sourceRoot":"/","sources":["messages/embed/Embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,QAAQ,EACR,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,MAAM,sBAAsB,CAAC;AAiB9B,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AA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AAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI;IAerD;;;OAGG;IACI,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQzC;;;OAGG;IACI,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQ7C;;;OAGG;IACI,YAAY,CAAC,SAAS,GAAE,MAAM,GAAG,IAAI,GAAG,IAAiB,GAAG,IAAI;IAQvE;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQ3C;;;OAGG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQvC;;OAEG;IACI,MAAM,IAAI,QAAQ;IAIzB;;;OAGG;WACW,eAAe,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE;CAS1E"}
@@ -1,300 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Embed = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
6
- const Assertions_1 = require("./Assertions");
7
- /**
8
- * Represents an embed in a message (image/video preview, rich embed, etc.)
9
- */
10
- class Embed {
11
- constructor(data = {}) {
12
- /**
13
- * An array of fields of this embed.
14
- */
15
- Object.defineProperty(this, "fields", {
16
- enumerable: true,
17
- configurable: true,
18
- writable: true,
19
- value: void 0
20
- });
21
- /**
22
- * The embed title.
23
- */
24
- Object.defineProperty(this, "title", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: void 0
29
- });
30
- /**
31
- * The embed description.
32
- */
33
- Object.defineProperty(this, "description", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
37
- value: void 0
38
- });
39
- /**
40
- * The embed url.
41
- */
42
- Object.defineProperty(this, "url", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: void 0
47
- });
48
- /**
49
- * The embed color.
50
- */
51
- Object.defineProperty(this, "color", {
52
- enumerable: true,
53
- configurable: true,
54
- writable: true,
55
- value: void 0
56
- });
57
- /**
58
- * The timestamp of the embed in the ISO format.
59
- */
60
- Object.defineProperty(this, "timestamp", {
61
- enumerable: true,
62
- configurable: true,
63
- writable: true,
64
- value: void 0
65
- });
66
- /**
67
- * The embed thumbnail data.
68
- */
69
- Object.defineProperty(this, "thumbnail", {
70
- enumerable: true,
71
- configurable: true,
72
- writable: true,
73
- value: void 0
74
- });
75
- /**
76
- * The embed image data.
77
- */
78
- Object.defineProperty(this, "image", {
79
- enumerable: true,
80
- configurable: true,
81
- writable: true,
82
- value: void 0
83
- });
84
- /**
85
- * Received video data.
86
- */
87
- Object.defineProperty(this, "video", {
88
- enumerable: true,
89
- configurable: true,
90
- writable: true,
91
- value: void 0
92
- });
93
- /**
94
- * The embed author data.
95
- */
96
- Object.defineProperty(this, "author", {
97
- enumerable: true,
98
- configurable: true,
99
- writable: true,
100
- value: void 0
101
- });
102
- /**
103
- * Received data about the embed provider.
104
- */
105
- Object.defineProperty(this, "provider", {
106
- enumerable: true,
107
- configurable: true,
108
- writable: true,
109
- value: void 0
110
- });
111
- /**
112
- * The embed footer data.
113
- */
114
- Object.defineProperty(this, "footer", {
115
- enumerable: true,
116
- configurable: true,
117
- writable: true,
118
- value: void 0
119
- });
120
- this.title = data.title;
121
- this.description = data.description;
122
- this.url = data.url;
123
- this.color = data.color;
124
- this.thumbnail = data.thumbnail;
125
- this.image = data.image;
126
- this.video = data.video;
127
- this.author = data.author;
128
- this.provider = data.provider;
129
- this.footer = data.footer;
130
- this.fields = data.fields ?? [];
131
- if (data.timestamp)
132
- this.timestamp = new Date(data.timestamp).toISOString();
133
- }
134
- /**
135
- * The accumulated length for the embed title, description, fields, footer text, and author name.
136
- */
137
- get length() {
138
- return ((this.title?.length ?? 0) +
139
- (this.description?.length ?? 0) +
140
- this.fields.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) +
141
- (this.footer?.text.length ?? 0) +
142
- (this.author?.name?.length ?? 0));
143
- }
144
- /**
145
- * Adds a field to the embed (max 25).
146
- * @param field The field to add.
147
- */
148
- addField(field) {
149
- return this.addFields(field);
150
- }
151
- /**
152
- * Adds fields to the embed (max 25).
153
- * @param fields The fields to add.
154
- */
155
- addFields(...fields) {
156
- // Data assertions
157
- ow_1.default(fields, 'fields', Assertions_1.embedFieldsArrayPredicate);
158
- // Ensure adding these fields won't exceed the 25 field limit
159
- Assertions_1.validateFieldLength(this.fields, fields.length);
160
- this.fields.push(...Embed.normalizeFields(...fields));
161
- return this;
162
- }
163
- /**
164
- * Removes, replaces, or inserts fields in the embed (max 25).
165
- * @param index The index to start at.
166
- * @param deleteCount The number of fields to remove.
167
- * @param fields The replacing field objects.
168
- */
169
- spliceFields(index, deleteCount, ...fields) {
170
- // Data assertions
171
- ow_1.default(fields, 'fields', Assertions_1.embedFieldsArrayPredicate);
172
- // Ensure adding these fields won't exceed the 25 field limit
173
- Assertions_1.validateFieldLength(this.fields, fields.length - deleteCount);
174
- this.fields.splice(index, deleteCount, ...Embed.normalizeFields(...fields));
175
- return this;
176
- }
177
- /**
178
- * Sets the author of this embed.
179
- * @param options The options for the author.
180
- */
181
- setAuthor(options) {
182
- if (options === null) {
183
- this.author = undefined;
184
- return this;
185
- }
186
- const { name, iconURL, url } = options;
187
- // Data assertions
188
- ow_1.default(name, 'name', Assertions_1.authorNamePredicate);
189
- ow_1.default(iconURL, 'iconURL', Assertions_1.urlPredicate);
190
- ow_1.default(url, 'url', Assertions_1.urlPredicate);
191
- this.author = { name, url, icon_url: iconURL };
192
- return this;
193
- }
194
- /**
195
- * Sets the color of this embed.
196
- * @param color The color of the embed.
197
- */
198
- setColor(color) {
199
- // Data assertions
200
- ow_1.default(color, 'color', Assertions_1.colorPredicate);
201
- this.color = color ?? undefined;
202
- return this;
203
- }
204
- /**
205
- * Sets the description of this embed.
206
- * @param description The description.
207
- */
208
- setDescription(description) {
209
- // Data assertions
210
- ow_1.default(description, 'description', Assertions_1.descriptionPredicate);
211
- this.description = description ?? undefined;
212
- return this;
213
- }
214
- /**
215
- * Sets the footer of this embed.
216
- * @param options The options for the footer.
217
- */
218
- setFooter(options) {
219
- if (options === null) {
220
- this.footer = undefined;
221
- return this;
222
- }
223
- const { text, iconURL } = options;
224
- // Data assertions
225
- ow_1.default(text, 'text', Assertions_1.footerTextPredicate);
226
- ow_1.default(iconURL, 'iconURL', Assertions_1.urlPredicate);
227
- this.footer = { text, icon_url: iconURL };
228
- return this;
229
- }
230
- /**
231
- * Sets the image of this embed.
232
- * @param url The URL of the image.
233
- */
234
- setImage(url) {
235
- // Data assertions
236
- ow_1.default(url, 'url', Assertions_1.urlPredicate);
237
- this.image = url ? { url } : undefined;
238
- return this;
239
- }
240
- /**
241
- * Sets the thumbnail of this embed.
242
- * @param url The URL of the thumbnail.
243
- */
244
- setThumbnail(url) {
245
- // Data assertions
246
- ow_1.default(url, 'url', Assertions_1.urlPredicate);
247
- this.thumbnail = url ? { url } : undefined;
248
- return this;
249
- }
250
- /**
251
- * Sets the timestamp of this embed.
252
- * @param timestamp The timestamp or date.
253
- */
254
- setTimestamp(timestamp = Date.now()) {
255
- // Data assertions
256
- ow_1.default(timestamp, 'timestamp', Assertions_1.timestampPredicate);
257
- this.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;
258
- return this;
259
- }
260
- /**
261
- * Sets the title of this embed.
262
- * @param title The title.
263
- */
264
- setTitle(title) {
265
- // Data assertions
266
- ow_1.default(title, 'title', Assertions_1.titlePredicate);
267
- this.title = title ?? undefined;
268
- return this;
269
- }
270
- /**
271
- * Sets the URL of this embed.
272
- * @param url The URL.
273
- */
274
- setURL(url) {
275
- // Data assertions
276
- ow_1.default(url, 'url', Assertions_1.urlPredicate);
277
- this.url = url ?? undefined;
278
- return this;
279
- }
280
- /**
281
- * Transforms the embed to a plain object.
282
- */
283
- toJSON() {
284
- return { ...this };
285
- }
286
- /**
287
- * Normalizes field input and resolves strings.
288
- * @param fields Fields to normalize.
289
- */
290
- static normalizeFields(...fields) {
291
- return fields.flat(Infinity).map((field) => {
292
- ow_1.default(field.name, 'field name', Assertions_1.fieldNamePredicate);
293
- ow_1.default(field.value, 'field value', Assertions_1.fieldValuePredicate);
294
- ow_1.default(field.inline, 'field inline', Assertions_1.fieldInlinePredicate);
295
- return { name: field.name, value: field.value, inline: field.inline ?? undefined };
296
- });
297
- }
298
- }
299
- exports.Embed = Embed;
300
- //# sourceMappingURL=Embed.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Embed.js","sourceRoot":"/","sources":["messages/embed/Embed.ts"],"names":[],"mappings":";;;;AAUA,oDAAoB;AACpB,6CAasB;AAatB;;GAEG;AACH,MAAa,KAAK;IA6DjB,YAAmB,OAAiB,EAAE;QA5DtC;;WAEG;QACH;;;;;WAA+B;QAE/B;;WAEG;QACH;;;;;WAAsB;QAEtB;;WAEG;QACH;;;;;WAA4B;QAE5B;;WAEG;QACH;;;;;WAAoB;QAEpB;;WAEG;QACH;;;;;WAAsB;QAEtB;;WAEG;QACH;;;;;WAA0B;QAE1B;;WAEG;QACH;;;;;WAAqC;QAErC;;WAEG;QACH;;;;;WAA6B;QAE7B;;WAEG;QACH;;;;;WAA6B;QAE7B;;WAEG;QACH;;;;;WAA+B;QAE/B;;WAEG;QACH;;;;;WAAmC;QAEnC;;WAEG;QACH;;;;;WAA+B;QAG9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAA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AK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QACpF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAjRD,sBAiRC","sourcesContent":["import type {\n\tAPIEmbed,\n\tAPIEmbedAuthor,\n\tAPIEmbedField,\n\tAPIEmbedFooter,\n\tAPIEmbedImage,\n\tAPIEmbedProvider,\n\tAPIEmbedThumbnail,\n\tAPIEmbedVideo,\n} from 'discord-api-types/v9';\nimport ow from 'ow';\nimport {\n\tauthorNamePredicate,\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedFieldsArrayPredicate,\n\tfieldInlinePredicate,\n\tfieldNamePredicate,\n\tfieldValuePredicate,\n\tfooterTextPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions';\n\nexport interface AuthorOptions {\n\tname: string;\n\turl?: string;\n\ticonURL?: string;\n}\n\nexport interface FooterOptions {\n\ttext: string;\n\ticonURL?: string;\n}\n\n/**\n * Represents an embed in a message (image/video preview, rich embed, etc.)\n */\nexport class Embed implements APIEmbed {\n\t/**\n\t * An array of fields of this embed.\n\t */\n\tpublic fields: APIEmbedField[];\n\n\t/**\n\t * The embed title.\n\t */\n\tpublic title?: string;\n\n\t/**\n\t * The embed description.\n\t */\n\tpublic description?: string;\n\n\t/**\n\t * The embed url.\n\t */\n\tpublic url?: string;\n\n\t/**\n\t * The embed color.\n\t */\n\tpublic color?: number;\n\n\t/**\n\t * The timestamp of the embed in the ISO format.\n\t */\n\tpublic timestamp?: string;\n\n\t/**\n\t * The embed thumbnail data.\n\t */\n\tpublic thumbnail?: APIEmbedThumbnail;\n\n\t/**\n\t * The embed image data.\n\t */\n\tpublic image?: APIEmbedImage;\n\n\t/**\n\t * Received video data.\n\t */\n\tpublic video?: APIEmbedVideo;\n\n\t/**\n\t * The embed author data.\n\t */\n\tpublic author?: APIEmbedAuthor;\n\n\t/**\n\t * Received data about the embed provider.\n\t */\n\tpublic provider?: APIEmbedProvider;\n\n\t/**\n\t * The embed footer data.\n\t */\n\tpublic footer?: APIEmbedFooter;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.title = data.title;\n\t\tthis.description = data.description;\n\t\tthis.url = data.url;\n\t\tthis.color = data.color;\n\t\tthis.thumbnail = data.thumbnail;\n\t\tthis.image = data.image;\n\t\tthis.video = data.video;\n\t\tthis.author = data.author;\n\t\tthis.provider = data.provider;\n\t\tthis.footer = data.footer;\n\t\tthis.fields = data.fields ?? [];\n\n\t\tif (data.timestamp) this.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * The accumulated length for the embed title, description, fields, footer text, and author name.\n\t */\n\tpublic get length(): number {\n\t\treturn (\n\t\t\t(this.title?.length ?? 0) +\n\t\t\t(this.description?.length ?? 0) +\n\t\t\tthis.fields.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) +\n\t\t\t(this.footer?.text.length ?? 0) +\n\t\t\t(this.author?.name?.length ?? 0)\n\t\t);\n\t}\n\n\t/**\n\t * Adds a field to the embed (max 25).\n\t * @param field The field to add.\n\t */\n\tpublic addField(field: APIEmbedField): this {\n\t\treturn this.addFields(field);\n\t}\n\n\t/**\n\t * Adds fields to the embed (max 25).\n\t * @param fields The fields to add.\n\t */\n\tpublic addFields(...fields: APIEmbedField[]): this {\n\t\t// Data assertions\n\t\tow(fields, 'fields', embedFieldsArrayPredicate);\n\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(this.fields, fields.length);\n\n\t\tthis.fields.push(...Embed.normalizeFields(...fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed (max 25).\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// Data assertions\n\t\tow(fields, 'fields', embedFieldsArrayPredicate);\n\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(this.fields, fields.length - deleteCount);\n\n\t\tthis.fields.splice(index, deleteCount, ...Embed.normalizeFields(...fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed.\n\t * @param options The options for the author.\n\t */\n\tpublic setAuthor(options: AuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\tconst { name, iconURL, url } = options;\n\t\t// Data assertions\n\t\tow(name, 'name', authorNamePredicate);\n\t\tow(iconURL, 'iconURL', urlPredicate);\n\t\tow(url, 'url', urlPredicate);\n\n\t\tthis.author = { name, url, icon_url: iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed.\n\t * @param color The color of the embed.\n\t */\n\tpublic setColor(color: number | null): this {\n\t\t// Data assertions\n\t\tow(color, 'color', colorPredicate);\n\n\t\tthis.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed.\n\t * @param description The description.\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tow(description, 'description', descriptionPredicate);\n\n\t\tthis.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed.\n\t * @param options The options for the footer.\n\t */\n\tpublic setFooter(options: FooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\tconst { text, iconURL } = options;\n\t\t// Data assertions\n\t\tow(text, 'text', footerTextPredicate);\n\t\tow(iconURL, 'iconURL', urlPredicate);\n\n\t\tthis.footer = { text, icon_url: iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed.\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\tow(url, 'url', urlPredicate);\n\n\t\tthis.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed.\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\tow(url, 'url', urlPredicate);\n\n\t\tthis.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed.\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\tow(timestamp, 'timestamp', timestampPredicate);\n\n\t\tthis.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 * @param title The title.\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\tow(title, 'title', titlePredicate);\n\n\t\tthis.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed.\n\t * @param url The URL.\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\tow(url, 'url', urlPredicate);\n\n\t\tthis.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 };\n\t}\n\n\t/**\n\t * Normalizes field input and resolves strings.\n\t * @param fields Fields to normalize.\n\t */\n\tpublic static normalizeFields(...fields: APIEmbedField[]): APIEmbedField[] {\n\t\treturn fields.flat(Infinity).map((field) => {\n\t\t\tow(field.name, 'field name', fieldNamePredicate);\n\t\t\tow(field.value, 'field value', fieldValuePredicate);\n\t\t\tow(field.inline, 'field inline', fieldInlinePredicate);\n\n\t\t\treturn { name: field.name, value: field.value, inline: field.inline ?? undefined };\n\t\t});\n\t}\n}\n"]}