@discordjs/builders 0.14.0-dev.1650240529-9ef7ffd → 0.14.0-dev.1650672503-3617093

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.
package/dist/index.d.ts CHANGED
@@ -21,10 +21,19 @@ declare function validateFieldLength(amountAdding: number, fields?: APIEmbedFiel
21
21
  declare const authorNamePredicate: _sapphire_shapeshift.UnionValidator<string | null>;
22
22
  declare const imageURLPredicate: _sapphire_shapeshift.UnionValidator<string | null | undefined>;
23
23
  declare const urlPredicate: _sapphire_shapeshift.UnionValidator<string | null | undefined>;
24
+ declare const embedAuthorPredicate: _sapphire_shapeshift.ObjectValidator<{
25
+ name: string | null;
26
+ iconURL: string | null | undefined;
27
+ url: string | null | undefined;
28
+ }>;
24
29
  declare const RGBPredicate: _sapphire_shapeshift.NumberValidator<number>;
25
30
  declare const colorPredicate: _sapphire_shapeshift.UnionValidator<number | [number, number, number] | null>;
26
31
  declare const descriptionPredicate: _sapphire_shapeshift.UnionValidator<string | null>;
27
32
  declare const footerTextPredicate: _sapphire_shapeshift.UnionValidator<string | null>;
33
+ declare const embedFooterPredicate: _sapphire_shapeshift.ObjectValidator<{
34
+ text: string | null;
35
+ iconURL: string | null | undefined;
36
+ }>;
28
37
  declare const timestampPredicate: _sapphire_shapeshift.UnionValidator<number | Date | null>;
29
38
  declare const titlePredicate: _sapphire_shapeshift.UnionValidator<string | null>;
30
39
 
@@ -38,10 +47,12 @@ declare const Assertions$5_validateFieldLength: typeof validateFieldLength;
38
47
  declare const Assertions$5_authorNamePredicate: typeof authorNamePredicate;
39
48
  declare const Assertions$5_imageURLPredicate: typeof imageURLPredicate;
40
49
  declare const Assertions$5_urlPredicate: typeof urlPredicate;
50
+ declare const Assertions$5_embedAuthorPredicate: typeof embedAuthorPredicate;
41
51
  declare const Assertions$5_RGBPredicate: typeof RGBPredicate;
42
52
  declare const Assertions$5_colorPredicate: typeof colorPredicate;
43
53
  declare const Assertions$5_descriptionPredicate: typeof descriptionPredicate;
44
54
  declare const Assertions$5_footerTextPredicate: typeof footerTextPredicate;
55
+ declare const Assertions$5_embedFooterPredicate: typeof embedFooterPredicate;
45
56
  declare const Assertions$5_timestampPredicate: typeof timestampPredicate;
46
57
  declare const Assertions$5_titlePredicate: typeof titlePredicate;
47
58
  declare namespace Assertions$5 {
@@ -56,10 +67,12 @@ declare namespace Assertions$5 {
56
67
  Assertions$5_authorNamePredicate as authorNamePredicate,
57
68
  Assertions$5_imageURLPredicate as imageURLPredicate,
58
69
  Assertions$5_urlPredicate as urlPredicate,
70
+ Assertions$5_embedAuthorPredicate as embedAuthorPredicate,
59
71
  Assertions$5_RGBPredicate as RGBPredicate,
60
72
  Assertions$5_colorPredicate as colorPredicate,
61
73
  Assertions$5_descriptionPredicate as descriptionPredicate,
62
74
  Assertions$5_footerTextPredicate as footerTextPredicate,
75
+ Assertions$5_embedFooterPredicate as embedFooterPredicate,
63
76
  Assertions$5_timestampPredicate as timestampPredicate,
64
77
  Assertions$5_titlePredicate as titlePredicate,
65
78
  };
@@ -97,7 +110,7 @@ declare class UnsafeEmbedBuilder {
97
110
  *
98
111
  * @param fields The fields to add
99
112
  */
100
- addFields(...fields: APIEmbedField[]): this;
113
+ addFields(fields: APIEmbedField[]): this;
101
114
  /**
102
115
  * Removes, replaces, or inserts fields in the embed (max 25)
103
116
  *
@@ -110,7 +123,7 @@ declare class UnsafeEmbedBuilder {
110
123
  * Sets the embed's fields (max 25).
111
124
  * @param fields The fields to set
112
125
  */
113
- setFields(...fields: APIEmbedField[]): this;
126
+ setFields(fields: APIEmbedField[]): this;
114
127
  /**
115
128
  * Sets the author of this embed
116
129
  *
@@ -175,7 +188,7 @@ declare class UnsafeEmbedBuilder {
175
188
  * Represents a validated embed in a message (image/video preview, rich embed, etc.)
176
189
  */
177
190
  declare class EmbedBuilder extends UnsafeEmbedBuilder {
178
- addFields(...fields: APIEmbedField[]): this;
191
+ addFields(fields: APIEmbedField[]): this;
179
192
  spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this;
180
193
  setAuthor(options: EmbedAuthorOptions | null): this;
181
194
  setColor(color: number | RGBTuple | null): this;
@@ -571,12 +584,12 @@ declare class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentB
571
584
  * @param components The components to add to this action row.
572
585
  * @returns
573
586
  */
574
- addComponents(...components: T[]): this;
587
+ addComponents(components: T[]): this;
575
588
  /**
576
589
  * Sets the components in this action row
577
590
  * @param components The components to set this row to
578
591
  */
579
- setComponents(...components: T[]): this;
592
+ setComponents(components: T[]): this;
580
593
  toJSON(): APIActionRowComponent<ReturnType<T['toJSON']>>;
581
594
  }
582
595
 
@@ -652,7 +665,7 @@ declare class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputCompon
652
665
  });
653
666
  /**
654
667
  * Sets the custom id for this text input
655
- * @param customId The custom id of this text inputå
668
+ * @param customId The custom id of this text input
656
669
  */
657
670
  setCustomId(customId: string): this;
658
671
  /**
@@ -750,12 +763,12 @@ declare class UnsafeModalBuilder implements JSONEncodable<APIModalInteractionRes
750
763
  * Adds components to this modal
751
764
  * @param components The components to add to this modal
752
765
  */
753
- addComponents(...components: (ActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>)[]): this;
766
+ addComponents(components: (ActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>)[]): this;
754
767
  /**
755
768
  * Sets the components in this modal
756
769
  * @param components The components to set this modal to
757
770
  */
758
- setComponents(...components: ActionRowBuilder<ModalActionRowComponentBuilder>[]): this;
771
+ setComponents(components: ActionRowBuilder<ModalActionRowComponentBuilder>[]): this;
759
772
  toJSON(): APIModalInteractionResponseCallbackData;
760
773
  }
761
774
 
@@ -818,12 +831,12 @@ declare class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuComp
818
831
  * @param options The options to add to this select menu
819
832
  * @returns
820
833
  */
821
- addOptions(...options: (UnsafeSelectMenuOptionBuilder | APISelectMenuOption)[]): this;
834
+ addOptions(options: (UnsafeSelectMenuOptionBuilder | APISelectMenuOption)[]): this;
822
835
  /**
823
836
  * Sets the options on this select menu
824
837
  * @param options The options to set on this select menu
825
838
  */
826
- setOptions(...options: (UnsafeSelectMenuOptionBuilder | APISelectMenuOption)[]): this;
839
+ setOptions(options: (UnsafeSelectMenuOptionBuilder | APISelectMenuOption)[]): this;
827
840
  toJSON(): APISelectMenuComponent;
828
841
  }
829
842
 
@@ -836,8 +849,8 @@ declare class SelectMenuBuilder extends UnsafeSelectMenuBuilder {
836
849
  setMaxValues(maxValues: number): this;
837
850
  setCustomId(customId: string): this;
838
851
  setDisabled(disabled?: boolean): this;
839
- addOptions(...options: (UnsafeSelectMenuOptionBuilder | APISelectMenuOption)[]): this;
840
- setOptions(...options: (UnsafeSelectMenuOptionBuilder | APISelectMenuOption)[]): this;
852
+ addOptions(options: (UnsafeSelectMenuOptionBuilder | APISelectMenuOption)[]): this;
853
+ setOptions(options: (UnsafeSelectMenuOptionBuilder | APISelectMenuOption)[]): this;
841
854
  toJSON(): APISelectMenuComponent;
842
855
  }
843
856
 
package/dist/index.js CHANGED
@@ -103,8 +103,10 @@ __export(Assertions_exports, {
103
103
  authorNamePredicate: () => authorNamePredicate,
104
104
  colorPredicate: () => colorPredicate,
105
105
  descriptionPredicate: () => descriptionPredicate,
106
+ embedAuthorPredicate: () => embedAuthorPredicate,
106
107
  embedFieldPredicate: () => embedFieldPredicate,
107
108
  embedFieldsArrayPredicate: () => embedFieldsArrayPredicate,
109
+ embedFooterPredicate: () => embedFooterPredicate,
108
110
  fieldInlinePredicate: () => fieldInlinePredicate,
109
111
  fieldLengthPredicate: () => fieldLengthPredicate,
110
112
  fieldNamePredicate: () => fieldNamePredicate,
@@ -138,10 +140,19 @@ var imageURLPredicate = import_shapeshift.s.string.url({
138
140
  var urlPredicate = import_shapeshift.s.string.url({
139
141
  allowedProtocols: ["http:", "https:"]
140
142
  }).nullish;
143
+ var embedAuthorPredicate = import_shapeshift.s.object({
144
+ name: authorNamePredicate,
145
+ iconURL: imageURLPredicate,
146
+ url: urlPredicate
147
+ });
141
148
  var RGBPredicate = import_shapeshift.s.number.int.ge(0).le(255);
142
149
  var colorPredicate = import_shapeshift.s.number.int.ge(0).le(16777215).or(import_shapeshift.s.tuple([RGBPredicate, RGBPredicate, RGBPredicate])).nullable;
143
150
  var descriptionPredicate = import_shapeshift.s.string.lengthGe(1).lengthLe(4096).nullable;
144
151
  var footerTextPredicate = import_shapeshift.s.string.lengthGe(1).lengthLe(2048).nullable;
152
+ var embedFooterPredicate = import_shapeshift.s.object({
153
+ text: footerTextPredicate,
154
+ iconURL: imageURLPredicate
155
+ });
145
156
  var timestampPredicate = import_shapeshift.s.union(import_shapeshift.s.number, import_shapeshift.s.date).nullable;
146
157
  var titlePredicate = fieldNamePredicate.nullable;
147
158
 
@@ -153,7 +164,7 @@ var UnsafeEmbedBuilder = class {
153
164
  if (data.timestamp)
154
165
  this.data.timestamp = new Date(data.timestamp).toISOString();
155
166
  }
156
- addFields(...fields) {
167
+ addFields(fields) {
157
168
  if (this.data.fields)
158
169
  this.data.fields.push(...fields);
159
170
  else
@@ -167,7 +178,7 @@ var UnsafeEmbedBuilder = class {
167
178
  this.data.fields = fields;
168
179
  return this;
169
180
  }
170
- setFields(...fields) {
181
+ setFields(fields) {
171
182
  this.spliceFields(0, this.data.fields?.length ?? 0, ...fields);
172
183
  return this;
173
184
  }
@@ -228,9 +239,9 @@ __name(UnsafeEmbedBuilder, "UnsafeEmbedBuilder");
228
239
 
229
240
  // src/messages/embed/Embed.ts
230
241
  var EmbedBuilder = class extends UnsafeEmbedBuilder {
231
- addFields(...fields) {
242
+ addFields(fields) {
232
243
  validateFieldLength(fields.length, this.data.fields);
233
- return super.addFields(...embedFieldsArrayPredicate.parse(fields));
244
+ return super.addFields(embedFieldsArrayPredicate.parse(fields));
234
245
  }
235
246
  spliceFields(index, deleteCount, ...fields) {
236
247
  validateFieldLength(fields.length - deleteCount, this.data.fields);
@@ -240,9 +251,7 @@ var EmbedBuilder = class extends UnsafeEmbedBuilder {
240
251
  if (options === null) {
241
252
  return super.setAuthor(null);
242
253
  }
243
- authorNamePredicate.parse(options.name);
244
- urlPredicate.parse(options.iconURL);
245
- urlPredicate.parse(options.url);
254
+ embedAuthorPredicate.parse(options);
246
255
  return super.setAuthor(options);
247
256
  }
248
257
  setColor(color) {
@@ -255,8 +264,7 @@ var EmbedBuilder = class extends UnsafeEmbedBuilder {
255
264
  if (options === null) {
256
265
  return super.setFooter(null);
257
266
  }
258
- footerTextPredicate.parse(options.text);
259
- urlPredicate.parse(options.iconURL);
267
+ embedFooterPredicate.parse(options);
260
268
  return super.setFooter(options);
261
269
  }
262
270
  setImage(url) {
@@ -514,11 +522,11 @@ var ActionRowBuilder = class extends ComponentBuilder {
514
522
  __publicField(this, "components");
515
523
  this.components = components?.map((c) => createComponentBuilder(c)) ?? [];
516
524
  }
517
- addComponents(...components) {
525
+ addComponents(components) {
518
526
  this.components.push(...components);
519
527
  return this;
520
528
  }
521
- setComponents(...components) {
529
+ setComponents(components) {
522
530
  this.components.splice(0, this.components.length, ...components);
523
531
  return this;
524
532
  }
@@ -717,11 +725,11 @@ var UnsafeModalBuilder = class {
717
725
  this.data.custom_id = customId;
718
726
  return this;
719
727
  }
720
- addComponents(...components) {
728
+ addComponents(components) {
721
729
  this.components.push(...components.map((component) => component instanceof ActionRowBuilder ? component : new ActionRowBuilder(component)));
722
730
  return this;
723
731
  }
724
- setComponents(...components) {
732
+ setComponents(components) {
725
733
  this.components.splice(0, this.components.length, ...components);
726
734
  return this;
727
735
  }
@@ -795,11 +803,11 @@ var UnsafeSelectMenuBuilder = class extends ComponentBuilder {
795
803
  this.data.disabled = disabled;
796
804
  return this;
797
805
  }
798
- addOptions(...options) {
806
+ addOptions(options) {
799
807
  this.options.push(...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(option)));
800
808
  return this;
801
809
  }
802
- setOptions(...options) {
810
+ setOptions(options) {
803
811
  this.options.splice(0, this.options.length, ...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(option)));
804
812
  return this;
805
813
  }
@@ -829,12 +837,12 @@ var SelectMenuBuilder = class extends UnsafeSelectMenuBuilder {
829
837
  setDisabled(disabled = true) {
830
838
  return super.setDisabled(disabledValidator.parse(disabled));
831
839
  }
832
- addOptions(...options) {
840
+ addOptions(options) {
833
841
  optionsLengthValidator.parse(this.options.length + options.length);
834
842
  this.options.push(...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(optionValidator.parse(option))));
835
843
  return this;
836
844
  }
837
- setOptions(...options) {
845
+ setOptions(options) {
838
846
  optionsLengthValidator.parse(options.length);
839
847
  this.options.splice(0, this.options.length, ...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(optionValidator.parse(option))));
840
848
  return this;