@discordjs/builders 2.0.0-move-client-init.1761650119-a4c0a246f → 2.0.0-pr-11006.1765450224-e636950b2

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.mjs CHANGED
@@ -95,15 +95,15 @@ import { Locale } from "discord-api-types/v10";
95
95
  import { z as z2 } from "zod";
96
96
  var idPredicate = z2.int().min(0).max(2147483647).optional();
97
97
  var customIdPredicate = z2.string().min(1).max(100);
98
+ var snowflakePredicate = z2.string().regex(/^(?:0|[1-9]\d*)$/);
98
99
  var memberPermissionsPredicate = z2.coerce.bigint();
99
100
  var localeMapPredicate = z2.strictObject(
100
101
  Object.fromEntries(Object.values(Locale).map((loc) => [loc, z2.string().optional()]))
101
102
  );
102
103
 
103
104
  // src/components/Assertions.ts
104
- var labelPredicate = z3.string().min(1).max(80);
105
105
  var emojiPredicate = z3.strictObject({
106
- id: z3.string().optional(),
106
+ id: snowflakePredicate.optional(),
107
107
  name: z3.string().min(2).max(32).optional(),
108
108
  animated: z3.boolean().optional()
109
109
  }).refine((data) => data.id !== void 0 || data.name !== void 0, {
@@ -113,24 +113,29 @@ var buttonPredicateBase = z3.strictObject({
113
113
  type: z3.literal(ComponentType.Button),
114
114
  disabled: z3.boolean().optional()
115
115
  });
116
+ var buttonLabelPredicate = z3.string().min(1).max(80);
116
117
  var buttonCustomIdPredicateBase = buttonPredicateBase.extend({
117
118
  custom_id: customIdPredicate,
118
119
  emoji: emojiPredicate.optional(),
119
- label: labelPredicate
120
+ label: buttonLabelPredicate.optional()
121
+ }).refine((data) => data.emoji !== void 0 || data.label !== void 0, {
122
+ message: "Buttons with a custom id must have either an emoji or a label."
120
123
  });
121
- var buttonPrimaryPredicate = buttonCustomIdPredicateBase.extend({ style: z3.literal(ButtonStyle.Primary) });
122
- var buttonSecondaryPredicate = buttonCustomIdPredicateBase.extend({ style: z3.literal(ButtonStyle.Secondary) });
123
- var buttonSuccessPredicate = buttonCustomIdPredicateBase.extend({ style: z3.literal(ButtonStyle.Success) });
124
- var buttonDangerPredicate = buttonCustomIdPredicateBase.extend({ style: z3.literal(ButtonStyle.Danger) });
124
+ var buttonPrimaryPredicate = buttonCustomIdPredicateBase.safeExtend({ style: z3.literal(ButtonStyle.Primary) });
125
+ var buttonSecondaryPredicate = buttonCustomIdPredicateBase.safeExtend({ style: z3.literal(ButtonStyle.Secondary) });
126
+ var buttonSuccessPredicate = buttonCustomIdPredicateBase.safeExtend({ style: z3.literal(ButtonStyle.Success) });
127
+ var buttonDangerPredicate = buttonCustomIdPredicateBase.safeExtend({ style: z3.literal(ButtonStyle.Danger) });
125
128
  var buttonLinkPredicate = buttonPredicateBase.extend({
126
129
  style: z3.literal(ButtonStyle.Link),
127
130
  url: z3.url({ protocol: /^(?:https?|discord)$/ }).max(512),
128
131
  emoji: emojiPredicate.optional(),
129
- label: labelPredicate
132
+ label: buttonLabelPredicate.optional()
133
+ }).refine((data) => data.emoji !== void 0 || data.label !== void 0, {
134
+ message: "Link buttons must have either an emoji or a label."
130
135
  });
131
136
  var buttonPremiumPredicate = buttonPredicateBase.extend({
132
137
  style: z3.literal(ButtonStyle.Premium),
133
- sku_id: z3.string()
138
+ sku_id: snowflakePredicate
134
139
  });
135
140
  var buttonPredicate = z3.discriminatedUnion("style", [
136
141
  buttonLinkPredicate,
@@ -151,21 +156,21 @@ var selectMenuBasePredicate = z3.object({
151
156
  var selectMenuChannelPredicate = selectMenuBasePredicate.extend({
152
157
  type: z3.literal(ComponentType.ChannelSelect),
153
158
  channel_types: z3.enum(ChannelType).array().optional(),
154
- default_values: z3.object({ id: z3.string(), type: z3.literal(SelectMenuDefaultValueType.Channel) }).array().max(25).optional()
159
+ default_values: z3.object({ id: snowflakePredicate, type: z3.literal(SelectMenuDefaultValueType.Channel) }).array().max(25).optional()
155
160
  });
156
161
  var selectMenuMentionablePredicate = selectMenuBasePredicate.extend({
157
162
  type: z3.literal(ComponentType.MentionableSelect),
158
163
  default_values: z3.object({
159
- id: z3.string(),
164
+ id: snowflakePredicate,
160
165
  type: z3.literal([SelectMenuDefaultValueType.Role, SelectMenuDefaultValueType.User])
161
166
  }).array().max(25).optional()
162
167
  });
163
168
  var selectMenuRolePredicate = selectMenuBasePredicate.extend({
164
169
  type: z3.literal(ComponentType.RoleSelect),
165
- default_values: z3.object({ id: z3.string(), type: z3.literal(SelectMenuDefaultValueType.Role) }).array().max(25).optional()
170
+ default_values: z3.object({ id: snowflakePredicate, type: z3.literal(SelectMenuDefaultValueType.Role) }).array().max(25).optional()
166
171
  });
167
172
  var selectMenuStringOptionPredicate = z3.object({
168
- label: labelPredicate,
173
+ label: z3.string().min(1).max(100),
169
174
  value: z3.string().min(1).max(100),
170
175
  description: z3.string().min(1).max(100).optional(),
171
176
  emoji: emojiPredicate.optional(),
@@ -203,7 +208,7 @@ var selectMenuStringPredicate = selectMenuBasePredicate.extend({
203
208
  });
204
209
  var selectMenuUserPredicate = selectMenuBasePredicate.extend({
205
210
  type: z3.literal(ComponentType.UserSelect),
206
- default_values: z3.object({ id: z3.string(), type: z3.literal(SelectMenuDefaultValueType.User) }).array().max(25).optional()
211
+ default_values: z3.object({ id: snowflakePredicate, type: z3.literal(SelectMenuDefaultValueType.User) }).array().max(25).optional()
207
212
  });
208
213
  var actionRowPredicate = z3.object({
209
214
  id: idPredicate,
@@ -382,8 +387,119 @@ var PremiumButtonBuilder = class extends BaseButtonBuilder {
382
387
  }
383
388
  };
384
389
 
390
+ // src/components/fileUpload/FileUpload.ts
391
+ import { ComponentType as ComponentType6 } from "discord-api-types/v10";
392
+
393
+ // src/components/fileUpload/Assertions.ts
394
+ import { ComponentType as ComponentType5 } from "discord-api-types/v10";
395
+ import { z as z4 } from "zod";
396
+ var fileUploadPredicate = z4.object({
397
+ type: z4.literal(ComponentType5.FileUpload),
398
+ id: idPredicate,
399
+ custom_id: customIdPredicate,
400
+ min_values: z4.int().min(0).max(10).optional(),
401
+ max_values: z4.int().min(1).max(10).optional(),
402
+ required: z4.boolean().optional()
403
+ });
404
+
405
+ // src/components/fileUpload/FileUpload.ts
406
+ var FileUploadBuilder = class extends ComponentBuilder {
407
+ static {
408
+ __name(this, "FileUploadBuilder");
409
+ }
410
+ /**
411
+ * @internal
412
+ */
413
+ data;
414
+ /**
415
+ * Creates a new file upload.
416
+ *
417
+ * @param data - The API data to create this file upload with
418
+ * @example
419
+ * Creating a file upload from an API data object:
420
+ * ```ts
421
+ * const fileUpload = new FileUploadBuilder({
422
+ * custom_id: "file_upload",
423
+ * min_values: 2,
424
+ * max_values: 5,
425
+ * });
426
+ * ```
427
+ * @example
428
+ * Creating a file upload using setters and API data:
429
+ * ```ts
430
+ * const fileUpload = new FileUploadBuilder({
431
+ * custom_id: "file_upload",
432
+ * min_values: 2,
433
+ * max_values: 5,
434
+ * }).setRequired();
435
+ * ```
436
+ */
437
+ constructor(data = {}) {
438
+ super();
439
+ this.data = { ...structuredClone(data), type: ComponentType6.FileUpload };
440
+ }
441
+ /**
442
+ * Sets the custom id for this file upload.
443
+ *
444
+ * @param customId - The custom id to use
445
+ */
446
+ setCustomId(customId) {
447
+ this.data.custom_id = customId;
448
+ return this;
449
+ }
450
+ /**
451
+ * Sets the minimum number of file uploads required.
452
+ *
453
+ * @param minValues - The minimum values that must be uploaded
454
+ */
455
+ setMinValues(minValues) {
456
+ this.data.min_values = minValues;
457
+ return this;
458
+ }
459
+ /**
460
+ * Clears the minimum values.
461
+ */
462
+ clearMinValues() {
463
+ this.data.min_values = void 0;
464
+ return this;
465
+ }
466
+ /**
467
+ * Sets the maximum number of file uploads required.
468
+ *
469
+ * @param maxValues - The maximum values that can be uploaded
470
+ */
471
+ setMaxValues(maxValues) {
472
+ this.data.max_values = maxValues;
473
+ return this;
474
+ }
475
+ /**
476
+ * Clears the maximum values.
477
+ */
478
+ clearMaxValues() {
479
+ this.data.max_values = void 0;
480
+ return this;
481
+ }
482
+ /**
483
+ * Sets whether this file upload is required.
484
+ *
485
+ * @param required - Whether this file upload is required
486
+ */
487
+ setRequired(required = true) {
488
+ this.data.required = required;
489
+ return this;
490
+ }
491
+ /**
492
+ * {@inheritDoc ComponentBuilder.toJSON}
493
+ */
494
+ toJSON(validationOverride) {
495
+ const clone = structuredClone(this.data);
496
+ validate(fileUploadPredicate, clone, validationOverride);
497
+ return clone;
498
+ }
499
+ };
500
+
385
501
  // src/components/label/Label.ts
386
- import { ComponentType as ComponentType23 } from "discord-api-types/v10";
502
+ import { ComponentType as ComponentType25 } from "discord-api-types/v10";
387
503
 
388
504
  // src/util/resolveBuilder.ts
389
505
  function isBuilder(builder, Constructor) {
@@ -402,10 +518,10 @@ function resolveBuilder(builder, Constructor) {
402
518
  __name(resolveBuilder, "resolveBuilder");
403
519
 
404
520
  // src/components/Components.ts
405
- import { ButtonStyle as ButtonStyle5, ComponentType as ComponentType21 } from "discord-api-types/v10";
521
+ import { ButtonStyle as ButtonStyle5, ComponentType as ComponentType23 } from "discord-api-types/v10";
406
522
 
407
523
  // src/components/ActionRow.ts
408
- import { ComponentType as ComponentType12 } from "discord-api-types/v10";
524
+ import { ComponentType as ComponentType14 } from "discord-api-types/v10";
409
525
 
410
526
  // src/util/normalizeArray.ts
411
527
  function normalizeArray(arr) {
@@ -416,7 +532,7 @@ __name(normalizeArray, "normalizeArray");
416
532
 
417
533
  // src/components/selectMenu/ChannelSelectMenu.ts
418
534
  import {
419
- ComponentType as ComponentType5,
535
+ ComponentType as ComponentType7,
420
536
  SelectMenuDefaultValueType as SelectMenuDefaultValueType2
421
537
  } from "discord-api-types/v10";
422
538
 
@@ -451,9 +567,9 @@ var BaseSelectMenuBuilder = class extends ComponentBuilder {
451
567
  return this;
452
568
  }
453
569
  /**
454
- * Sets the maximum values that must be selected in the select menu.
570
+ * Sets the maximum values that can be selected in the select menu.
455
571
  *
456
- * @param maxValues - The maximum values that must be selected
572
+ * @param maxValues - The maximum values that can be selected
457
573
  */
458
574
  setMaxValues(maxValues) {
459
575
  this.data.max_values = maxValues;
@@ -520,7 +636,7 @@ var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
520
636
  */
521
637
  constructor(data = {}) {
522
638
  super();
523
- this.data = { ...structuredClone(data), type: ComponentType5.ChannelSelect };
639
+ this.data = { ...structuredClone(data), type: ComponentType7.ChannelSelect };
524
640
  }
525
641
  /**
526
642
  * Adds channel types to this select menu.
@@ -585,7 +701,7 @@ var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
585
701
 
586
702
  // src/components/selectMenu/MentionableSelectMenu.ts
587
703
  import {
588
- ComponentType as ComponentType6,
704
+ ComponentType as ComponentType8,
589
705
  SelectMenuDefaultValueType as SelectMenuDefaultValueType3
590
706
  } from "discord-api-types/v10";
591
707
  var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
@@ -617,7 +733,7 @@ var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
617
733
  */
618
734
  constructor(data = {}) {
619
735
  super();
620
- this.data = { ...structuredClone(data), type: ComponentType6.MentionableSelect };
736
+ this.data = { ...structuredClone(data), type: ComponentType8.MentionableSelect };
621
737
  }
622
738
  /**
623
739
  * Adds default roles to this auto populated select menu.
@@ -684,7 +800,7 @@ var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
684
800
 
685
801
  // src/components/selectMenu/RoleSelectMenu.ts
686
802
  import {
687
- ComponentType as ComponentType7,
803
+ ComponentType as ComponentType9,
688
804
  SelectMenuDefaultValueType as SelectMenuDefaultValueType4
689
805
  } from "discord-api-types/v10";
690
806
  var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
@@ -716,7 +832,7 @@ var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
716
832
  */
717
833
  constructor(data = {}) {
718
834
  super();
719
- this.data = { ...structuredClone(data), type: ComponentType7.RoleSelect };
835
+ this.data = { ...structuredClone(data), type: ComponentType9.RoleSelect };
720
836
  }
721
837
  /**
722
838
  * Adds default roles to this auto populated select menu.
@@ -758,7 +874,7 @@ var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
758
874
  };
759
875
 
760
876
  // src/components/selectMenu/StringSelectMenu.ts
761
- import { ComponentType as ComponentType8 } from "discord-api-types/v10";
877
+ import { ComponentType as ComponentType10 } from "discord-api-types/v10";
762
878
 
763
879
  // src/components/selectMenu/StringSelectMenuOption.ts
764
880
  var StringSelectMenuOptionBuilder = class {
@@ -909,7 +1025,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
909
1025
  this.data = {
910
1026
  ...structuredClone(rest),
911
1027
  options: options.map((option) => new StringSelectMenuOptionBuilder(option)),
912
- type: ComponentType8.StringSelect
1028
+ type: ComponentType10.StringSelect
913
1029
  };
914
1030
  }
915
1031
  /**
@@ -981,7 +1097,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
981
1097
 
982
1098
  // src/components/selectMenu/UserSelectMenu.ts
983
1099
  import {
984
- ComponentType as ComponentType9,
1100
+ ComponentType as ComponentType11,
985
1101
  SelectMenuDefaultValueType as SelectMenuDefaultValueType5
986
1102
  } from "discord-api-types/v10";
987
1103
  var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
@@ -1013,7 +1129,7 @@ var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
1013
1129
  */
1014
1130
  constructor(data = {}) {
1015
1131
  super();
1016
- this.data = { ...structuredClone(data), type: ComponentType9.UserSelect };
1132
+ this.data = { ...structuredClone(data), type: ComponentType11.UserSelect };
1017
1133
  }
1018
1134
  /**
1019
1135
  * Adds default users to this auto populated select menu.
@@ -1055,21 +1171,21 @@ var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
1055
1171
  };
1056
1172
 
1057
1173
  // src/components/textInput/TextInput.ts
1058
- import { ComponentType as ComponentType11 } from "discord-api-types/v10";
1174
+ import { ComponentType as ComponentType13 } from "discord-api-types/v10";
1059
1175
 
1060
1176
  // src/components/textInput/Assertions.ts
1061
- import { ComponentType as ComponentType10, TextInputStyle } from "discord-api-types/v10";
1062
- import { z as z4 } from "zod";
1063
- var textInputPredicate = z4.object({
1177
+ import { ComponentType as ComponentType12, TextInputStyle } from "discord-api-types/v10";
1178
+ import { z as z5 } from "zod";
1179
+ var textInputPredicate = z5.object({
1064
1180
  id: idPredicate,
1065
- type: z4.literal(ComponentType10.TextInput),
1181
+ type: z5.literal(ComponentType12.TextInput),
1066
1182
  custom_id: customIdPredicate,
1067
- style: z4.enum(TextInputStyle),
1068
- min_length: z4.number().min(0).max(4e3).optional(),
1069
- max_length: z4.number().min(1).max(4e3).optional(),
1070
- placeholder: z4.string().max(100).optional(),
1071
- value: z4.string().min(0).max(4e3).optional(),
1072
- required: z4.boolean().optional()
1183
+ style: z5.enum(TextInputStyle),
1184
+ min_length: z5.number().min(0).max(4e3).optional(),
1185
+ max_length: z5.number().min(1).max(4e3).optional(),
1186
+ placeholder: z5.string().max(100).optional(),
1187
+ value: z5.string().min(0).max(4e3).optional(),
1188
+ required: z5.boolean().optional()
1073
1189
  });
1074
1190
 
1075
1191
  // src/components/textInput/TextInput.ts
@@ -1106,7 +1222,7 @@ var TextInputBuilder = class extends ComponentBuilder {
1106
1222
  */
1107
1223
  constructor(data = {}) {
1108
1224
  super();
1109
- this.data = { ...structuredClone(data), type: ComponentType11.TextInput };
1225
+ this.data = { ...structuredClone(data), type: ComponentType13.TextInput };
1110
1226
  }
1111
1227
  /**
1112
1228
  * Sets the custom id for this text input.
@@ -1264,7 +1380,7 @@ var ActionRowBuilder = class extends ComponentBuilder {
1264
1380
  this.data = {
1265
1381
  ...structuredClone(rest),
1266
1382
  components: components.map((component) => createComponentBuilder(component)),
1267
- type: ComponentType12.ActionRow
1383
+ type: ComponentType14.ActionRow
1268
1384
  };
1269
1385
  }
1270
1386
  /**
@@ -1441,67 +1557,67 @@ var ActionRowBuilder = class extends ComponentBuilder {
1441
1557
 
1442
1558
  // src/components/v2/Container.ts
1443
1559
  import {
1444
- ComponentType as ComponentType20
1560
+ ComponentType as ComponentType22
1445
1561
  } from "discord-api-types/v10";
1446
1562
 
1447
1563
  // src/components/v2/Assertions.ts
1448
- import { ComponentType as ComponentType13, SeparatorSpacingSize } from "discord-api-types/v10";
1449
- import { z as z5 } from "zod";
1450
- var unfurledMediaItemPredicate = z5.object({
1451
- url: z5.url({ protocol: /^(?:https?|attachment)$/ })
1564
+ import { ComponentType as ComponentType15, SeparatorSpacingSize } from "discord-api-types/v10";
1565
+ import { z as z6 } from "zod";
1566
+ var unfurledMediaItemPredicate = z6.object({
1567
+ url: z6.url({ protocol: /^(?:https?|attachment)$/ })
1452
1568
  });
1453
- var thumbnailPredicate = z5.object({
1454
- type: z5.literal(ComponentType13.Thumbnail),
1569
+ var thumbnailPredicate = z6.object({
1570
+ type: z6.literal(ComponentType15.Thumbnail),
1455
1571
  id: idPredicate,
1456
1572
  media: unfurledMediaItemPredicate,
1457
- description: z5.string().min(1).max(1024).nullish(),
1458
- spoiler: z5.boolean().optional()
1573
+ description: z6.string().min(1).max(1024).nullish(),
1574
+ spoiler: z6.boolean().optional()
1459
1575
  });
1460
- var unfurledMediaItemAttachmentOnlyPredicate = z5.object({
1461
- url: z5.url({ protocol: /^attachment$/ })
1576
+ var unfurledMediaItemAttachmentOnlyPredicate = z6.object({
1577
+ url: z6.url({ protocol: /^attachment$/ })
1462
1578
  });
1463
- var filePredicate = z5.object({
1464
- type: z5.literal(ComponentType13.File),
1579
+ var filePredicate = z6.object({
1580
+ type: z6.literal(ComponentType15.File),
1465
1581
  id: idPredicate,
1466
1582
  file: unfurledMediaItemAttachmentOnlyPredicate,
1467
- spoiler: z5.boolean().optional()
1583
+ spoiler: z6.boolean().optional()
1468
1584
  });
1469
- var separatorPredicate = z5.object({
1470
- type: z5.literal(ComponentType13.Separator),
1585
+ var separatorPredicate = z6.object({
1586
+ type: z6.literal(ComponentType15.Separator),
1471
1587
  id: idPredicate,
1472
- divider: z5.boolean().optional(),
1473
- spacing: z5.enum(SeparatorSpacingSize).optional()
1588
+ divider: z6.boolean().optional(),
1589
+ spacing: z6.enum(SeparatorSpacingSize).optional()
1474
1590
  });
1475
- var textDisplayPredicate = z5.object({
1476
- type: z5.literal(ComponentType13.TextDisplay),
1591
+ var textDisplayPredicate = z6.object({
1592
+ type: z6.literal(ComponentType15.TextDisplay),
1477
1593
  id: idPredicate,
1478
- content: z5.string().min(1).max(4e3)
1594
+ content: z6.string().min(1).max(4e3)
1479
1595
  });
1480
- var mediaGalleryItemPredicate = z5.object({
1596
+ var mediaGalleryItemPredicate = z6.object({
1481
1597
  id: idPredicate,
1482
1598
  media: unfurledMediaItemPredicate,
1483
- description: z5.string().min(1).max(1024).nullish(),
1484
- spoiler: z5.boolean().optional()
1599
+ description: z6.string().min(1).max(1024).nullish(),
1600
+ spoiler: z6.boolean().optional()
1485
1601
  });
1486
- var mediaGalleryPredicate = z5.object({
1487
- type: z5.literal(ComponentType13.MediaGallery),
1602
+ var mediaGalleryPredicate = z6.object({
1603
+ type: z6.literal(ComponentType15.MediaGallery),
1488
1604
  id: idPredicate,
1489
- items: z5.array(mediaGalleryItemPredicate).min(1).max(10)
1605
+ items: z6.array(mediaGalleryItemPredicate).min(1).max(10)
1490
1606
  });
1491
- var sectionPredicate = z5.object({
1492
- type: z5.literal(ComponentType13.Section),
1607
+ var sectionPredicate = z6.object({
1608
+ type: z6.literal(ComponentType15.Section),
1493
1609
  id: idPredicate,
1494
- components: z5.array(textDisplayPredicate).min(1).max(3),
1495
- accessory: z5.union([
1496
- z5.object({ type: z5.literal(ComponentType13.Button) }),
1497
- z5.object({ type: z5.literal(ComponentType13.Thumbnail) })
1610
+ components: z6.array(textDisplayPredicate).min(1).max(3),
1611
+ accessory: z6.union([
1612
+ z6.object({ type: z6.literal(ComponentType15.Button) }),
1613
+ z6.object({ type: z6.literal(ComponentType15.Thumbnail) })
1498
1614
  ])
1499
1615
  });
1500
- var containerPredicate = z5.object({
1501
- type: z5.literal(ComponentType13.Container),
1616
+ var containerPredicate = z6.object({
1617
+ type: z6.literal(ComponentType15.Container),
1502
1618
  id: idPredicate,
1503
- components: z5.array(
1504
- z5.union([
1619
+ components: z6.array(
1620
+ z6.union([
1505
1621
  actionRowPredicate,
1506
1622
  filePredicate,
1507
1623
  mediaGalleryPredicate,
@@ -1510,12 +1626,12 @@ var containerPredicate = z5.object({
1510
1626
  textDisplayPredicate
1511
1627
  ])
1512
1628
  ).min(1),
1513
- spoiler: z5.boolean().optional(),
1514
- accent_color: z5.int().min(0).max(16777215).nullish()
1629
+ spoiler: z6.boolean().optional(),
1630
+ accent_color: z6.int().min(0).max(16777215).nullish()
1515
1631
  });
1516
1632
 
1517
1633
  // src/components/v2/File.ts
1518
- import { ComponentType as ComponentType14 } from "discord-api-types/v10";
1634
+ import { ComponentType as ComponentType16 } from "discord-api-types/v10";
1519
1635
  var FileBuilder = class extends ComponentBuilder {
1520
1636
  static {
1521
1637
  __name(this, "FileBuilder");
@@ -1555,7 +1671,7 @@ var FileBuilder = class extends ComponentBuilder {
1555
1671
  this.data = {
1556
1672
  ...structuredClone(rest),
1557
1673
  file: file && { url: file.url },
1558
- type: ComponentType14.File
1674
+ type: ComponentType16.File
1559
1675
  };
1560
1676
  }
1561
1677
  /**
@@ -1587,7 +1703,7 @@ var FileBuilder = class extends ComponentBuilder {
1587
1703
  };
1588
1704
 
1589
1705
  // src/components/v2/MediaGallery.ts
1590
- import { ComponentType as ComponentType15 } from "discord-api-types/v10";
1706
+ import { ComponentType as ComponentType17 } from "discord-api-types/v10";
1591
1707
 
1592
1708
  // src/components/v2/MediaGalleryItem.ts
1593
1709
  var MediaGalleryItemBuilder = class {
@@ -1722,7 +1838,7 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
1722
1838
  this.data = {
1723
1839
  ...structuredClone(rest),
1724
1840
  items: items.map((item) => new MediaGalleryItemBuilder(item)),
1725
- type: ComponentType15.MediaGallery
1841
+ type: ComponentType17.MediaGallery
1726
1842
  };
1727
1843
  }
1728
1844
  /**
@@ -1764,10 +1880,10 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
1764
1880
  };
1765
1881
 
1766
1882
  // src/components/v2/Section.ts
1767
- import { ComponentType as ComponentType18 } from "discord-api-types/v10";
1883
+ import { ComponentType as ComponentType20 } from "discord-api-types/v10";
1768
1884
 
1769
1885
  // src/components/v2/TextDisplay.ts
1770
- import { ComponentType as ComponentType16 } from "discord-api-types/v10";
1886
+ import { ComponentType as ComponentType18 } from "discord-api-types/v10";
1771
1887
  var TextDisplayBuilder = class extends ComponentBuilder {
1772
1888
  static {
1773
1889
  __name(this, "TextDisplayBuilder");
@@ -1800,7 +1916,7 @@ var TextDisplayBuilder = class extends ComponentBuilder {
1800
1916
  super();
1801
1917
  this.data = {
1802
1918
  ...structuredClone(data),
1803
- type: ComponentType16.TextDisplay
1919
+ type: ComponentType18.TextDisplay
1804
1920
  };
1805
1921
  }
1806
1922
  /**
@@ -1823,7 +1939,7 @@ var TextDisplayBuilder = class extends ComponentBuilder {
1823
1939
  };
1824
1940
 
1825
1941
  // src/components/v2/Thumbnail.ts
1826
- import { ComponentType as ComponentType17 } from "discord-api-types/v10";
1942
+ import { ComponentType as ComponentType19 } from "discord-api-types/v10";
1827
1943
  var ThumbnailBuilder = class extends ComponentBuilder {
1828
1944
  static {
1829
1945
  __name(this, "ThumbnailBuilder");
@@ -1863,7 +1979,7 @@ var ThumbnailBuilder = class extends ComponentBuilder {
1863
1979
  this.data = {
1864
1980
  ...structuredClone(rest),
1865
1981
  media: media && { url: media.url },
1866
- type: ComponentType17.Thumbnail
1982
+ type: ComponentType19.Thumbnail
1867
1983
  };
1868
1984
  }
1869
1985
  /**
@@ -1967,7 +2083,7 @@ var SectionBuilder = class extends ComponentBuilder {
1967
2083
  ...structuredClone(rest),
1968
2084
  accessory: accessory && resolveAccessoryComponent(accessory),
1969
2085
  components: components.map((component) => new TextDisplayBuilder(component)),
1970
- type: ComponentType18.Section
2086
+ type: ComponentType20.Section
1971
2087
  };
1972
2088
  }
1973
2089
  /**
@@ -2080,7 +2196,7 @@ var SectionBuilder = class extends ComponentBuilder {
2080
2196
  };
2081
2197
 
2082
2198
  // src/components/v2/Separator.ts
2083
- import { ComponentType as ComponentType19 } from "discord-api-types/v10";
2199
+ import { ComponentType as ComponentType21 } from "discord-api-types/v10";
2084
2200
  var SeparatorBuilder = class extends ComponentBuilder {
2085
2201
  static {
2086
2202
  __name(this, "SeparatorBuilder");
@@ -2114,7 +2230,7 @@ var SeparatorBuilder = class extends ComponentBuilder {
2114
2230
  super();
2115
2231
  this.data = {
2116
2232
  ...structuredClone(data),
2117
- type: ComponentType19.Separator
2233
+ type: ComponentType21.Separator
2118
2234
  };
2119
2235
  }
2120
2236
  /**
@@ -2178,7 +2294,7 @@ var ContainerBuilder = class extends ComponentBuilder {
2178
2294
  this.data = {
2179
2295
  ...structuredClone(rest),
2180
2296
  components: components.map((component) => createComponentBuilder(component)),
2181
- type: ComponentType20.Container
2297
+ type: ComponentType22.Container
2182
2298
  };
2183
2299
  }
2184
2300
  /**
@@ -2328,38 +2444,40 @@ function createComponentBuilder(data) {
2328
2444
  return data;
2329
2445
  }
2330
2446
  switch (data.type) {
2331
- case ComponentType21.ActionRow:
2447
+ case ComponentType23.ActionRow:
2332
2448
  return new ActionRowBuilder(data);
2333
- case ComponentType21.Button:
2449
+ case ComponentType23.Button:
2334
2450
  return createButtonBuilder(data);
2335
- case ComponentType21.StringSelect:
2451
+ case ComponentType23.StringSelect:
2336
2452
  return new StringSelectMenuBuilder(data);
2337
- case ComponentType21.TextInput:
2453
+ case ComponentType23.TextInput:
2338
2454
  return new TextInputBuilder(data);
2339
- case ComponentType21.UserSelect:
2455
+ case ComponentType23.UserSelect:
2340
2456
  return new UserSelectMenuBuilder(data);
2341
- case ComponentType21.RoleSelect:
2457
+ case ComponentType23.RoleSelect:
2342
2458
  return new RoleSelectMenuBuilder(data);
2343
- case ComponentType21.MentionableSelect:
2459
+ case ComponentType23.MentionableSelect:
2344
2460
  return new MentionableSelectMenuBuilder(data);
2345
- case ComponentType21.ChannelSelect:
2461
+ case ComponentType23.ChannelSelect:
2346
2462
  return new ChannelSelectMenuBuilder(data);
2347
- case ComponentType21.Thumbnail:
2463
+ case ComponentType23.Thumbnail:
2348
2464
  return new ThumbnailBuilder(data);
2349
- case ComponentType21.File:
2465
+ case ComponentType23.File:
2350
2466
  return new FileBuilder(data);
2351
- case ComponentType21.Separator:
2467
+ case ComponentType23.Separator:
2352
2468
  return new SeparatorBuilder(data);
2353
- case ComponentType21.TextDisplay:
2469
+ case ComponentType23.TextDisplay:
2354
2470
  return new TextDisplayBuilder(data);
2355
- case ComponentType21.MediaGallery:
2471
+ case ComponentType23.MediaGallery:
2356
2472
  return new MediaGalleryBuilder(data);
2357
- case ComponentType21.Section:
2473
+ case ComponentType23.Section:
2358
2474
  return new SectionBuilder(data);
2359
- case ComponentType21.Container:
2475
+ case ComponentType23.Container:
2360
2476
  return new ContainerBuilder(data);
2361
- case ComponentType21.Label:
2477
+ case ComponentType23.Label:
2362
2478
  return new LabelBuilder(data);
2479
+ case ComponentType23.FileUpload:
2480
+ return new FileUploadBuilder(data);
2363
2481
  default:
2364
2482
  throw new Error(`Cannot properly serialize component type: ${data.type}`);
2365
2483
  }
@@ -2386,9 +2504,9 @@ function createButtonBuilder(data) {
2386
2504
  __name(createButtonBuilder, "createButtonBuilder");
2387
2505
  function resolveAccessoryComponent(component) {
2388
2506
  switch (component.type) {
2389
- case ComponentType21.Button:
2507
+ case ComponentType23.Button:
2390
2508
  return createButtonBuilder(component);
2391
- case ComponentType21.Thumbnail:
2509
+ case ComponentType23.Thumbnail:
2392
2510
  return new ThumbnailBuilder(component);
2393
2511
  default:
2394
2512
  throw new Error(`Cannot properly serialize section accessory component: ${component.type}`);
@@ -2397,20 +2515,21 @@ function resolveAccessoryComponent(component) {
2397
2515
  __name(resolveAccessoryComponent, "resolveAccessoryComponent");
2398
2516
 
2399
2517
  // src/components/label/Assertions.ts
2400
- import { ComponentType as ComponentType22 } from "discord-api-types/v10";
2401
- import { z as z6 } from "zod";
2402
- var labelPredicate2 = z6.object({
2518
+ import { ComponentType as ComponentType24 } from "discord-api-types/v10";
2519
+ import { z as z7 } from "zod";
2520
+ var labelPredicate = z7.object({
2403
2521
  id: idPredicate,
2404
- type: z6.literal(ComponentType22.Label),
2405
- label: z6.string().min(1).max(45),
2406
- description: z6.string().min(1).max(100).optional(),
2407
- component: z6.union([
2522
+ type: z7.literal(ComponentType24.Label),
2523
+ label: z7.string().min(1).max(45),
2524
+ description: z7.string().min(1).max(100).optional(),
2525
+ component: z7.union([
2408
2526
  selectMenuStringPredicate,
2409
2527
  textInputPredicate,
2410
2528
  selectMenuUserPredicate,
2411
2529
  selectMenuRolePredicate,
2412
2530
  selectMenuMentionablePredicate,
2413
- selectMenuChannelPredicate
2531
+ selectMenuChannelPredicate,
2532
+ fileUploadPredicate
2414
2533
  ])
2415
2534
  });
2416
2535
 
@@ -2449,9 +2568,8 @@ var LabelBuilder = class extends ComponentBuilder {
2449
2568
  const { component, ...rest } = data;
2450
2569
  this.data = {
2451
2570
  ...structuredClone(rest),
2452
- // @ts-expect-error fixed in https://github.com/discordjs/discord.js/pull/11108
2453
2571
  component: component ? createComponentBuilder(component) : void 0,
2454
- type: ComponentType23.Label
2572
+ type: ComponentType25.Label
2455
2573
  };
2456
2574
  }
2457
2575
  /**
@@ -2533,6 +2651,15 @@ var LabelBuilder = class extends ComponentBuilder {
2533
2651
  this.data.component = resolveBuilder(input, TextInputBuilder);
2534
2652
  return this;
2535
2653
  }
2654
+ /**
2655
+ * Sets a file upload component to this label.
2656
+ *
2657
+ * @param input - A function that returns a component builder or an already built builder
2658
+ */
2659
+ setFileUploadComponent(input) {
2660
+ this.data.component = resolveBuilder(input, FileUploadBuilder);
2661
+ return this;
2662
+ }
2536
2663
  /**
2537
2664
  * {@inheritDoc ComponentBuilder.toJSON}
2538
2665
  */
@@ -2543,7 +2670,7 @@ var LabelBuilder = class extends ComponentBuilder {
2543
2670
  // The label predicate validates the component.
2544
2671
  component: component?.toJSON(false)
2545
2672
  };
2546
- validate(labelPredicate2, data, validationOverride);
2673
+ validate(labelPredicate, data, validationOverride);
2547
2674
  return data;
2548
2675
  }
2549
2676
  };
@@ -2792,33 +2919,33 @@ import {
2792
2919
  InteractionContextType,
2793
2920
  ApplicationCommandOptionType
2794
2921
  } from "discord-api-types/v10";
2795
- import { z as z7 } from "zod";
2796
- var namePredicate = z7.string().min(1).max(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u);
2797
- var descriptionPredicate = z7.string().min(1).max(100);
2798
- var sharedNameAndDescriptionPredicate = z7.object({
2922
+ import { z as z8 } from "zod";
2923
+ var namePredicate = z8.string().min(1).max(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u);
2924
+ var descriptionPredicate = z8.string().min(1).max(100);
2925
+ var sharedNameAndDescriptionPredicate = z8.object({
2799
2926
  name: namePredicate,
2800
2927
  name_localizations: localeMapPredicate.optional(),
2801
2928
  description: descriptionPredicate,
2802
2929
  description_localizations: localeMapPredicate.optional()
2803
2930
  });
2804
- var numericMixinNumberOptionPredicate = z7.object({
2805
- max_value: z7.float32().optional(),
2806
- min_value: z7.float32().optional()
2931
+ var numericMixinNumberOptionPredicate = z8.object({
2932
+ max_value: z8.float32().optional(),
2933
+ min_value: z8.float32().optional()
2807
2934
  });
2808
- var numericMixinIntegerOptionPredicate = z7.object({
2809
- max_value: z7.int().optional(),
2810
- min_value: z7.int().optional()
2935
+ var numericMixinIntegerOptionPredicate = z8.object({
2936
+ max_value: z8.int().optional(),
2937
+ min_value: z8.int().optional()
2811
2938
  });
2812
- var channelMixinOptionPredicate = z7.object({
2813
- channel_types: z7.literal(ApplicationCommandOptionAllowedChannelTypes).array().optional()
2939
+ var channelMixinOptionPredicate = z8.object({
2940
+ channel_types: z8.literal(ApplicationCommandOptionAllowedChannelTypes).array().optional()
2814
2941
  });
2815
- var autocompleteMixinOptionPredicate = z7.object({
2816
- autocomplete: z7.literal(true),
2817
- choices: z7.union([z7.never(), z7.never().array(), z7.undefined()])
2942
+ var autocompleteMixinOptionPredicate = z8.object({
2943
+ autocomplete: z8.literal(true),
2944
+ choices: z8.union([z8.never(), z8.never().array(), z8.undefined()])
2818
2945
  });
2819
- var choiceValueStringPredicate = z7.string().min(1).max(100);
2820
- var choiceValueNumberPredicate = z7.number();
2821
- var choiceBasePredicate = z7.object({
2946
+ var choiceValueStringPredicate = z8.string().min(1).max(100);
2947
+ var choiceValueNumberPredicate = z8.number();
2948
+ var choiceBasePredicate = z8.object({
2822
2949
  name: choiceValueStringPredicate,
2823
2950
  name_localizations: localeMapPredicate.optional()
2824
2951
  });
@@ -2828,8 +2955,8 @@ var choiceStringPredicate = choiceBasePredicate.extend({
2828
2955
  var choiceNumberPredicate = choiceBasePredicate.extend({
2829
2956
  value: choiceValueNumberPredicate
2830
2957
  });
2831
- var choiceBaseMixinPredicate = z7.object({
2832
- autocomplete: z7.literal(false).optional()
2958
+ var choiceBaseMixinPredicate = z8.object({
2959
+ autocomplete: z8.literal(false).optional()
2833
2960
  });
2834
2961
  var choiceStringMixinPredicate = choiceBaseMixinPredicate.extend({
2835
2962
  choices: choiceStringPredicate.array().max(25).optional()
@@ -2837,7 +2964,7 @@ var choiceStringMixinPredicate = choiceBaseMixinPredicate.extend({
2837
2964
  var choiceNumberMixinPredicate = choiceBaseMixinPredicate.extend({
2838
2965
  choices: choiceNumberPredicate.array().max(25).optional()
2839
2966
  });
2840
- var basicOptionTypesPredicate = z7.literal([
2967
+ var basicOptionTypesPredicate = z8.literal([
2841
2968
  ApplicationCommandOptionType.Attachment,
2842
2969
  ApplicationCommandOptionType.Boolean,
2843
2970
  ApplicationCommandOptionType.Channel,
@@ -2849,54 +2976,58 @@ var basicOptionTypesPredicate = z7.literal([
2849
2976
  ApplicationCommandOptionType.User
2850
2977
  ]);
2851
2978
  var basicOptionPredicate = sharedNameAndDescriptionPredicate.extend({
2852
- required: z7.boolean().optional(),
2979
+ required: z8.boolean().optional(),
2853
2980
  type: basicOptionTypesPredicate
2854
2981
  });
2855
- var autocompleteOrStringChoicesMixinOptionPredicate = z7.discriminatedUnion("autocomplete", [
2982
+ var autocompleteOrStringChoicesMixinOptionPredicate = z8.discriminatedUnion("autocomplete", [
2856
2983
  autocompleteMixinOptionPredicate,
2857
2984
  choiceStringMixinPredicate
2858
2985
  ]);
2859
- var autocompleteOrNumberChoicesMixinOptionPredicate = z7.discriminatedUnion("autocomplete", [
2986
+ var autocompleteOrNumberChoicesMixinOptionPredicate = z8.discriminatedUnion("autocomplete", [
2860
2987
  autocompleteMixinOptionPredicate,
2861
2988
  choiceNumberMixinPredicate
2862
2989
  ]);
2863
- var channelOptionPredicate = z7.object({
2990
+ var channelOptionPredicate = z8.object({
2864
2991
  ...basicOptionPredicate.shape,
2865
2992
  ...channelMixinOptionPredicate.shape
2866
2993
  });
2867
- var integerOptionPredicate = z7.object({
2994
+ var integerOptionPredicate = z8.object({
2868
2995
  ...basicOptionPredicate.shape,
2869
2996
  ...numericMixinIntegerOptionPredicate.shape
2870
2997
  }).and(autocompleteOrNumberChoicesMixinOptionPredicate);
2871
- var numberOptionPredicate = z7.object({
2998
+ var numberOptionPredicate = z8.object({
2872
2999
  ...basicOptionPredicate.shape,
2873
3000
  ...numericMixinNumberOptionPredicate.shape
2874
3001
  }).and(autocompleteOrNumberChoicesMixinOptionPredicate);
2875
3002
  var stringOptionPredicate = basicOptionPredicate.extend({
2876
- max_length: z7.number().min(0).max(6e3).optional(),
2877
- min_length: z7.number().min(1).max(6e3).optional()
3003
+ max_length: z8.number().min(1).max(6e3).optional(),
3004
+ min_length: z8.number().min(0).max(6e3).optional()
2878
3005
  }).and(autocompleteOrStringChoicesMixinOptionPredicate);
2879
3006
  var baseChatInputCommandPredicate = sharedNameAndDescriptionPredicate.extend({
2880
- contexts: z7.array(z7.enum(InteractionContextType)).optional(),
3007
+ contexts: z8.array(z8.enum(InteractionContextType)).optional(),
2881
3008
  default_member_permissions: memberPermissionsPredicate.optional(),
2882
- integration_types: z7.array(z7.enum(ApplicationIntegrationType)).optional(),
2883
- nsfw: z7.boolean().optional()
3009
+ integration_types: z8.array(z8.enum(ApplicationIntegrationType)).optional(),
3010
+ nsfw: z8.boolean().optional()
2884
3011
  });
2885
- var chatInputCommandOptionsPredicate = z7.union([
2886
- z7.object({ type: basicOptionTypesPredicate }).array(),
2887
- z7.object({ type: z7.literal(ApplicationCommandOptionType.Subcommand) }).array(),
2888
- z7.object({ type: z7.literal(ApplicationCommandOptionType.SubcommandGroup) }).array()
3012
+ var chatInputCommandOptionsPredicate = z8.union([
3013
+ z8.object({ type: basicOptionTypesPredicate }).array(),
3014
+ z8.object({
3015
+ type: z8.union([
3016
+ z8.literal(ApplicationCommandOptionType.Subcommand),
3017
+ z8.literal(ApplicationCommandOptionType.SubcommandGroup)
3018
+ ])
3019
+ }).array()
2889
3020
  ]);
2890
3021
  var chatInputCommandPredicate = baseChatInputCommandPredicate.extend({
2891
3022
  options: chatInputCommandOptionsPredicate.optional()
2892
3023
  });
2893
3024
  var chatInputCommandSubcommandGroupPredicate = sharedNameAndDescriptionPredicate.extend({
2894
- type: z7.literal(ApplicationCommandOptionType.SubcommandGroup),
2895
- options: z7.array(z7.object({ type: z7.literal(ApplicationCommandOptionType.Subcommand) })).min(1).max(25)
3025
+ type: z8.literal(ApplicationCommandOptionType.SubcommandGroup),
3026
+ options: z8.array(z8.object({ type: z8.literal(ApplicationCommandOptionType.Subcommand) })).min(1).max(25)
2896
3027
  });
2897
3028
  var chatInputCommandSubcommandPredicate = sharedNameAndDescriptionPredicate.extend({
2898
- type: z7.literal(ApplicationCommandOptionType.Subcommand),
2899
- options: z7.array(z7.object({ type: basicOptionTypesPredicate })).max(25)
3029
+ type: z8.literal(ApplicationCommandOptionType.Subcommand),
3030
+ options: z8.array(z8.object({ type: basicOptionTypesPredicate })).max(25)
2900
3031
  });
2901
3032
 
2902
3033
  // src/interactions/commands/chatInput/options/ApplicationCommandOptionBase.ts
@@ -3445,25 +3576,25 @@ var ChatInputCommandBuilder = class extends Mixin8(
3445
3576
 
3446
3577
  // src/interactions/commands/contextMenu/Assertions.ts
3447
3578
  import { ApplicationCommandType as ApplicationCommandType2, ApplicationIntegrationType as ApplicationIntegrationType2, InteractionContextType as InteractionContextType2 } from "discord-api-types/v10";
3448
- import { z as z8 } from "zod";
3449
- var namePredicate2 = z8.string().min(1).max(32).refine((val) => val.trim().length > 0, {
3579
+ import { z as z9 } from "zod";
3580
+ var namePredicate2 = z9.string().min(1).max(32).refine((val) => val.trim().length > 0, {
3450
3581
  error: "Must not consist of only whitespace."
3451
3582
  });
3452
- var contextsPredicate = z8.array(z8.enum(InteractionContextType2));
3453
- var integrationTypesPredicate = z8.array(z8.enum(ApplicationIntegrationType2));
3454
- var baseContextMenuCommandPredicate = z8.object({
3583
+ var contextsPredicate = z9.array(z9.enum(InteractionContextType2));
3584
+ var integrationTypesPredicate = z9.array(z9.enum(ApplicationIntegrationType2));
3585
+ var baseContextMenuCommandPredicate = z9.object({
3455
3586
  contexts: contextsPredicate.optional(),
3456
3587
  default_member_permissions: memberPermissionsPredicate.optional(),
3457
3588
  name: namePredicate2,
3458
3589
  name_localizations: localeMapPredicate.optional(),
3459
3590
  integration_types: integrationTypesPredicate.optional(),
3460
- nsfw: z8.boolean().optional()
3591
+ nsfw: z9.boolean().optional()
3461
3592
  });
3462
3593
  var userCommandPredicate = baseContextMenuCommandPredicate.extend({
3463
- type: z8.literal(ApplicationCommandType2.User)
3594
+ type: z9.literal(ApplicationCommandType2.User)
3464
3595
  });
3465
3596
  var messageCommandPredicate = baseContextMenuCommandPredicate.extend({
3466
- type: z8.literal(ApplicationCommandType2.Message)
3597
+ type: z9.literal(ApplicationCommandType2.Message)
3467
3598
  });
3468
3599
 
3469
3600
  // src/interactions/commands/contextMenu/ContextMenuCommand.ts
@@ -3525,18 +3656,18 @@ var UserContextCommandBuilder = class extends ContextMenuCommandBuilder {
3525
3656
  };
3526
3657
 
3527
3658
  // src/interactions/modals/Assertions.ts
3528
- import { ComponentType as ComponentType24 } from "discord-api-types/v10";
3529
- import { z as z9 } from "zod";
3530
- var titlePredicate = z9.string().min(1).max(45);
3531
- var modalPredicate = z9.object({
3659
+ import { ComponentType as ComponentType26 } from "discord-api-types/v10";
3660
+ import { z as z10 } from "zod";
3661
+ var titlePredicate = z10.string().min(1).max(45);
3662
+ var modalPredicate = z10.object({
3532
3663
  title: titlePredicate,
3533
3664
  custom_id: customIdPredicate,
3534
- components: z9.union([
3535
- z9.object({
3536
- type: z9.literal(ComponentType24.ActionRow),
3537
- components: z9.object({ type: z9.literal(ComponentType24.TextInput) }).array().length(1)
3665
+ components: z10.union([
3666
+ z10.object({
3667
+ type: z10.literal(ComponentType26.ActionRow),
3668
+ components: z10.object({ type: z10.literal(ComponentType26.TextInput) }).array().length(1)
3538
3669
  }),
3539
- labelPredicate2,
3670
+ labelPredicate,
3540
3671
  textDisplayPredicate
3541
3672
  ]).array().min(1).max(5)
3542
3673
  });
@@ -3565,7 +3696,6 @@ var ModalBuilder = class {
3565
3696
  const { components = [], ...rest } = data;
3566
3697
  this.data = {
3567
3698
  ...structuredClone(rest),
3568
- // @ts-expect-error fixed in https://github.com/discordjs/discord.js/pull/11108
3569
3699
  components: components.map((component) => createComponentBuilder(component))
3570
3700
  };
3571
3701
  }
@@ -3661,43 +3791,36 @@ var ModalBuilder = class {
3661
3791
  };
3662
3792
 
3663
3793
  // src/messages/embed/Assertions.ts
3664
- import { z as z10 } from "zod";
3665
-
3666
- // src/util/componentUtil.ts
3667
- function embedLength(data) {
3668
- return (data.title?.length ?? 0) + (data.description?.length ?? 0) + (data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) + (data.footer?.text.length ?? 0) + (data.author?.name.length ?? 0);
3669
- }
3670
- __name(embedLength, "embedLength");
3671
-
3672
- // src/messages/embed/Assertions.ts
3673
- var namePredicate3 = z10.string().max(256);
3674
- var URLPredicate = z10.url({ protocol: /^https?$/ });
3675
- var URLWithAttachmentProtocolPredicate = z10.url({ protocol: /^(?:https?|attachment)$/ });
3676
- var embedFieldPredicate = z10.object({
3794
+ import { embedLength } from "@discordjs/util";
3795
+ import { z as z11 } from "zod";
3796
+ var namePredicate3 = z11.string().max(256);
3797
+ var URLPredicate = z11.url({ protocol: /^https?$/ });
3798
+ var URLWithAttachmentProtocolPredicate = z11.url({ protocol: /^(?:https?|attachment)$/ });
3799
+ var embedFieldPredicate = z11.object({
3677
3800
  name: namePredicate3,
3678
- value: z10.string().max(1024),
3679
- inline: z10.boolean().optional()
3801
+ value: z11.string().max(1024),
3802
+ inline: z11.boolean().optional()
3680
3803
  });
3681
- var embedAuthorPredicate = z10.object({
3804
+ var embedAuthorPredicate = z11.object({
3682
3805
  name: namePredicate3.min(1),
3683
3806
  icon_url: URLWithAttachmentProtocolPredicate.optional(),
3684
3807
  url: URLPredicate.optional()
3685
3808
  });
3686
- var embedFooterPredicate = z10.object({
3687
- text: z10.string().min(1).max(2048),
3809
+ var embedFooterPredicate = z11.object({
3810
+ text: z11.string().min(1).max(2048),
3688
3811
  icon_url: URLWithAttachmentProtocolPredicate.optional()
3689
3812
  });
3690
- var embedPredicate = z10.object({
3813
+ var embedPredicate = z11.object({
3691
3814
  title: namePredicate3.min(1).optional(),
3692
- description: z10.string().min(1).max(4096).optional(),
3815
+ description: z11.string().min(1).max(4096).optional(),
3693
3816
  url: URLPredicate.optional(),
3694
- timestamp: z10.string().optional(),
3695
- color: z10.int().min(0).max(16777215).optional(),
3817
+ timestamp: z11.string().optional(),
3818
+ color: z11.int().min(0).max(16777215).optional(),
3696
3819
  footer: embedFooterPredicate.optional(),
3697
- image: z10.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
3698
- thumbnail: z10.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
3820
+ image: z11.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
3821
+ thumbnail: z11.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
3699
3822
  author: embedAuthorPredicate.optional(),
3700
- fields: z10.array(embedFieldPredicate).max(25).optional()
3823
+ fields: z11.array(embedFieldPredicate).max(25).optional()
3701
3824
  }).refine(
3702
3825
  (embed) => embed.title !== void 0 || embed.description !== void 0 || embed.fields !== void 0 && embed.fields.length > 0 || embed.footer !== void 0 || embed.author !== void 0 || embed.image !== void 0 || embed.thumbnail !== void 0,
3703
3826
  {
@@ -4183,19 +4306,19 @@ var EmbedBuilder = class {
4183
4306
 
4184
4307
  // src/messages/poll/Assertions.ts
4185
4308
  import { PollLayoutType } from "discord-api-types/v10";
4186
- import { z as z11 } from "zod";
4187
- var pollQuestionPredicate = z11.object({ text: z11.string().min(1).max(300) });
4188
- var pollAnswerMediaPredicate = z11.object({
4189
- text: z11.string().min(1).max(55),
4309
+ import { z as z12 } from "zod";
4310
+ var pollQuestionPredicate = z12.object({ text: z12.string().min(1).max(300) });
4311
+ var pollAnswerMediaPredicate = z12.object({
4312
+ text: z12.string().min(1).max(55),
4190
4313
  emoji: emojiPredicate.optional()
4191
4314
  });
4192
- var pollAnswerPredicate = z11.object({ poll_media: pollAnswerMediaPredicate });
4193
- var pollPredicate = z11.object({
4315
+ var pollAnswerPredicate = z12.object({ poll_media: pollAnswerMediaPredicate });
4316
+ var pollPredicate = z12.object({
4194
4317
  question: pollQuestionPredicate,
4195
- answers: z11.array(pollAnswerPredicate).min(1).max(10),
4196
- duration: z11.number().min(1).max(768).optional(),
4197
- allow_multiselect: z11.boolean().optional(),
4198
- layout_type: z11.enum(PollLayoutType).optional()
4318
+ answers: z12.array(pollAnswerPredicate).min(1).max(10),
4319
+ duration: z12.number().min(1).max(768).optional(),
4320
+ allow_multiselect: z12.boolean().optional(),
4321
+ layout_type: z12.enum(PollLayoutType).optional()
4199
4322
  });
4200
4323
 
4201
4324
  // src/messages/poll/PollMedia.ts
@@ -4524,95 +4647,109 @@ var PollBuilder = class {
4524
4647
  };
4525
4648
 
4526
4649
  // src/messages/Assertions.ts
4527
- import { AllowedMentionsTypes, ComponentType as ComponentType25, MessageFlags, MessageReferenceType } from "discord-api-types/v10";
4528
- import { z as z12 } from "zod";
4529
- var attachmentPredicate = z12.object({
4530
- id: z12.union([z12.string(), z12.number()]),
4531
- description: z12.string().max(1024).optional(),
4532
- duration_secs: z12.number().max(2 ** 31 - 1).optional(),
4533
- filename: z12.string().max(1024).optional(),
4534
- title: z12.string().max(1024).optional(),
4535
- waveform: z12.string().max(400).optional()
4650
+ import { Buffer as Buffer2 } from "buffer";
4651
+ import { AllowedMentionsTypes, ComponentType as ComponentType27, MessageFlags, MessageReferenceType } from "discord-api-types/v10";
4652
+ import { z as z13 } from "zod";
4653
+ var fileKeyRegex = /^files\[(?<placeholder>\d+?)]$/;
4654
+ var rawFilePredicate = z13.object({
4655
+ data: z13.union([z13.instanceof(Buffer2), z13.instanceof(Uint8Array), z13.string()]),
4656
+ name: z13.string().min(1),
4657
+ contentType: z13.string().optional(),
4658
+ key: z13.string().regex(fileKeyRegex).optional()
4536
4659
  });
4537
- var allowedMentionPredicate = z12.object({
4538
- parse: z12.enum(AllowedMentionsTypes).array().optional(),
4539
- roles: z12.string().array().max(100).optional(),
4540
- users: z12.string().array().max(100).optional(),
4541
- replied_user: z12.boolean().optional()
4660
+ var attachmentPredicate = z13.object({
4661
+ // As a string it only makes sense for edits when we do have an attachment snowflake
4662
+ id: z13.union([snowflakePredicate, z13.number()]),
4663
+ description: z13.string().max(1024).optional(),
4664
+ duration_secs: z13.number().max(2 ** 31 - 1).optional(),
4665
+ filename: z13.string().max(1024).optional(),
4666
+ title: z13.string().max(1024).optional(),
4667
+ waveform: z13.string().max(400).optional()
4668
+ });
4669
+ var allowedMentionPredicate = z13.object({
4670
+ parse: z13.enum(AllowedMentionsTypes).array().optional(),
4671
+ roles: z13.string().array().max(100).optional(),
4672
+ users: z13.string().array().max(100).optional(),
4673
+ replied_user: z13.boolean().optional()
4542
4674
  }).refine(
4543
4675
  (data) => !(data.parse?.includes(AllowedMentionsTypes.User) && data.users?.length || data.parse?.includes(AllowedMentionsTypes.Role) && data.roles?.length),
4544
4676
  {
4545
4677
  error: 'Cannot specify both parse: ["users"] and non-empty users array, or parse: ["roles"] and non-empty roles array. These are mutually exclusive'
4546
4678
  }
4547
4679
  );
4548
- var messageReferencePredicate = z12.object({
4549
- channel_id: z12.string().optional(),
4550
- fail_if_not_exists: z12.boolean().optional(),
4551
- guild_id: z12.string().optional(),
4552
- message_id: z12.string(),
4553
- type: z12.enum(MessageReferenceType).optional()
4680
+ var messageReferencePredicate = z13.object({
4681
+ channel_id: z13.string().optional(),
4682
+ fail_if_not_exists: z13.boolean().optional(),
4683
+ guild_id: z13.string().optional(),
4684
+ message_id: z13.string(),
4685
+ type: z13.enum(MessageReferenceType).optional()
4554
4686
  });
4555
- var baseMessagePredicate = z12.object({
4556
- nonce: z12.union([z12.string().max(25), z12.number()]).optional(),
4557
- tts: z12.boolean().optional(),
4687
+ var baseMessagePredicate = z13.object({
4688
+ nonce: z13.union([z13.string().max(25), z13.number()]).optional(),
4689
+ tts: z13.boolean().optional(),
4558
4690
  allowed_mentions: allowedMentionPredicate.optional(),
4559
4691
  message_reference: messageReferencePredicate.optional(),
4560
4692
  attachments: attachmentPredicate.array().max(10).optional(),
4561
- enforce_nonce: z12.boolean().optional()
4693
+ enforce_nonce: z13.boolean().optional()
4562
4694
  });
4563
- var basicActionRowPredicate = z12.object({
4564
- type: z12.literal(ComponentType25.ActionRow),
4565
- components: z12.object({
4566
- type: z12.literal([
4567
- ComponentType25.Button,
4568
- ComponentType25.ChannelSelect,
4569
- ComponentType25.MentionableSelect,
4570
- ComponentType25.RoleSelect,
4571
- ComponentType25.StringSelect,
4572
- ComponentType25.UserSelect
4695
+ var basicActionRowPredicate = z13.object({
4696
+ type: z13.literal(ComponentType27.ActionRow),
4697
+ components: z13.object({
4698
+ type: z13.literal([
4699
+ ComponentType27.Button,
4700
+ ComponentType27.ChannelSelect,
4701
+ ComponentType27.MentionableSelect,
4702
+ ComponentType27.RoleSelect,
4703
+ ComponentType27.StringSelect,
4704
+ ComponentType27.UserSelect
4573
4705
  ])
4574
4706
  }).array()
4575
4707
  });
4576
4708
  var messageNoComponentsV2Predicate = baseMessagePredicate.extend({
4577
- content: z12.string().max(2e3).optional(),
4709
+ content: z13.string().max(2e3).optional(),
4578
4710
  embeds: embedPredicate.array().max(10).optional(),
4579
- sticker_ids: z12.array(z12.string()).max(3).optional(),
4711
+ sticker_ids: z13.array(z13.string()).max(3).optional(),
4580
4712
  poll: pollPredicate.optional(),
4581
4713
  components: basicActionRowPredicate.array().max(5).optional(),
4582
- flags: z12.int().optional().refine((flags) => !flags || (flags & MessageFlags.IsComponentsV2) === 0, {
4714
+ flags: z13.int().optional().refine((flags) => !flags || (flags & MessageFlags.IsComponentsV2) === 0, {
4583
4715
  error: "Cannot set content, embeds, stickers, or poll with IsComponentsV2 flag set"
4584
4716
  })
4585
4717
  }).refine(
4586
4718
  (data) => data.content !== void 0 || data.embeds !== void 0 && data.embeds.length > 0 || data.poll !== void 0 || data.attachments !== void 0 && data.attachments.length > 0 || data.components !== void 0 && data.components.length > 0 || data.sticker_ids !== void 0 && data.sticker_ids.length > 0,
4587
4719
  { error: "Messages must have content, embeds, a poll, attachments, components or stickers" }
4588
4720
  );
4589
- var allTopLevelComponentsPredicate = z12.union([
4721
+ var allTopLevelComponentsPredicate = z13.union([
4590
4722
  basicActionRowPredicate,
4591
- z12.object({
4592
- type: z12.literal([
4723
+ z13.object({
4724
+ type: z13.literal([
4593
4725
  // Components v2
4594
- ComponentType25.Container,
4595
- ComponentType25.File,
4596
- ComponentType25.MediaGallery,
4597
- ComponentType25.Section,
4598
- ComponentType25.Separator,
4599
- ComponentType25.TextDisplay,
4600
- ComponentType25.Thumbnail
4726
+ ComponentType27.Container,
4727
+ ComponentType27.File,
4728
+ ComponentType27.MediaGallery,
4729
+ ComponentType27.Section,
4730
+ ComponentType27.Separator,
4731
+ ComponentType27.TextDisplay,
4732
+ ComponentType27.Thumbnail
4601
4733
  ])
4602
4734
  })
4603
4735
  ]).array().min(1).max(10);
4604
4736
  var messageComponentsV2Predicate = baseMessagePredicate.extend({
4605
4737
  components: allTopLevelComponentsPredicate,
4606
- flags: z12.int().refine((flags) => (flags & MessageFlags.IsComponentsV2) === MessageFlags.IsComponentsV2, {
4738
+ flags: z13.int().refine((flags) => (flags & MessageFlags.IsComponentsV2) === MessageFlags.IsComponentsV2, {
4607
4739
  error: "Must set IsComponentsV2 flag to use Components V2"
4608
4740
  }),
4609
4741
  // These fields cannot be set
4610
- content: z12.string().length(0).nullish(),
4611
- embeds: z12.array(z12.never()).nullish(),
4612
- sticker_ids: z12.array(z12.never()).nullish(),
4613
- poll: z12.null().optional()
4742
+ content: z13.string().length(0).nullish(),
4743
+ embeds: z13.array(z13.never()).nullish(),
4744
+ sticker_ids: z13.array(z13.never()).nullish(),
4745
+ poll: z13.null().optional()
4746
+ });
4747
+ var messagePredicate = z13.union([messageNoComponentsV2Predicate, messageComponentsV2Predicate]);
4748
+ var fileBodyMessagePredicate = z13.object({
4749
+ body: messagePredicate,
4750
+ // No min length to support message edits
4751
+ files: rawFilePredicate.array().max(10)
4614
4752
  });
4615
- var messagePredicate = z12.union([messageNoComponentsV2Predicate, messageComponentsV2Predicate]);
4616
4753
 
4617
4754
  // src/messages/AllowedMentions.ts
4618
4755
  var AllowedMentionsBuilder = class {
@@ -4797,13 +4934,29 @@ var AttachmentBuilder = class {
4797
4934
  * The API data associated with this attachment.
4798
4935
  */
4799
4936
  data;
4937
+ /**
4938
+ * This data is not included in the output of `toJSON()`. For this class specifically, this refers to binary data
4939
+ * that will wind up being included in the multipart/form-data request, if used with the `MessageBuilder`.
4940
+ * To retrieve this data, use {@link getRawFile}.
4941
+ *
4942
+ * @remarks This cannot be set via the constructor, primarily because of the behavior described
4943
+ * {@link https://discord.com/developers/docs/reference#editing-message-attachments | here}.
4944
+ * That is, when editing a message's attachments, you should only be providing file data for new attachments.
4945
+ */
4946
+ fileData;
4800
4947
  /**
4801
4948
  * Creates a new attachment builder.
4802
4949
  *
4803
4950
  * @param data - The API data to create this attachment with
4951
+ * @example
4952
+ * ```ts
4953
+ * const attachment = new AttachmentBuilder().setId(1).setFileData(':)').setFilename('smiley.txt')
4954
+ * ```
4955
+ * @remarks Please note that the `id` field is required, it's rather easy to miss!
4804
4956
  */
4805
4957
  constructor(data = {}) {
4806
4958
  this.data = structuredClone(data);
4959
+ this.fileData = {};
4807
4960
  }
4808
4961
  /**
4809
4962
  * Sets the id of the attachment.
@@ -4862,6 +5015,54 @@ var AttachmentBuilder = class {
4862
5015
  this.data.filename = void 0;
4863
5016
  return this;
4864
5017
  }
5018
+ /**
5019
+ * Sets the file data to upload with this attachment.
5020
+ *
5021
+ * @param data - The file data
5022
+ * @remarks Note that this data is NOT included in the {@link toJSON} output. To retrieve it, use {@link getRawFile}.
5023
+ */
5024
+ setFileData(data) {
5025
+ this.fileData.data = data;
5026
+ return this;
5027
+ }
5028
+ /**
5029
+ * Clears the file data from this attachment.
5030
+ */
5031
+ clearFileData() {
5032
+ this.fileData.data = void 0;
5033
+ return this;
5034
+ }
5035
+ /**
5036
+ * Sets the content type of the file data to upload with this attachment.
5037
+ *
5038
+ * @remarks Note that this data is NOT included in the {@link toJSON} output. To retrieve it, use {@link getRawFile}.
5039
+ */
5040
+ setFileContentType(contentType) {
5041
+ this.fileData.contentType = contentType;
5042
+ return this;
5043
+ }
5044
+ /**
5045
+ * Clears the content type of the file data from this attachment.
5046
+ */
5047
+ clearFileContentType() {
5048
+ this.fileData.contentType = void 0;
5049
+ return this;
5050
+ }
5051
+ /**
5052
+ * Converts this attachment to a {@link RawFile} for uploading.
5053
+ *
5054
+ * @returns A {@link RawFile} object, or `undefined` if no file data is set
5055
+ */
5056
+ getRawFile() {
5057
+ if (!this.fileData?.data) {
5058
+ return;
5059
+ }
5060
+ return {
5061
+ ...this.fileData,
5062
+ name: this.data.filename,
5063
+ key: this.data.id === void 0 ? void 0 : `files[${this.data.id}]`
5064
+ };
5065
+ }
4865
5066
  /**
4866
5067
  * Sets the title of this attachment.
4867
5068
  *
@@ -5166,7 +5367,7 @@ var MessageBuilder = class {
5166
5367
  *
5167
5368
  * @param allowedMentions - The allowed mentions to set
5168
5369
  */
5169
- setAllowedMentions(allowedMentions) {
5370
+ setAllowedMentions(allowedMentions = new AllowedMentionsBuilder()) {
5170
5371
  this.data.allowed_mentions = resolveBuilder(allowedMentions, AllowedMentionsBuilder);
5171
5372
  return this;
5172
5373
  }
@@ -5499,10 +5700,31 @@ var MessageBuilder = class {
5499
5700
  validate(messagePredicate, data, validationOverride);
5500
5701
  return data;
5501
5702
  }
5703
+ /**
5704
+ * Serializes this builder to both JSON body and file data for multipart/form-data requests.
5705
+ *
5706
+ * @param validationOverride - Force validation to run/not run regardless of your global preference
5707
+ * @remarks
5708
+ * This method extracts file data from attachments that have files set via {@link AttachmentBuilder.setFileData}.
5709
+ * The returned body includes attachment metadata, while files contains the binary data for upload.
5710
+ */
5711
+ toFileBody(validationOverride) {
5712
+ const body = this.toJSON(false);
5713
+ const files = [];
5714
+ for (const attachment of this.data.attachments) {
5715
+ const rawFile = attachment.getRawFile();
5716
+ if (rawFile?.data || rawFile?.contentType) {
5717
+ files.push(rawFile);
5718
+ }
5719
+ }
5720
+ const combined = { body, files };
5721
+ validate(fileBodyMessagePredicate, combined, validationOverride);
5722
+ return combined;
5723
+ }
5502
5724
  };
5503
5725
 
5504
5726
  // src/index.ts
5505
- var version = "2.0.0-move-client-init.1761650119-a4c0a246f";
5727
+ var version = "2.0.0-pr-11006.1765450224-e636950b2";
5506
5728
  export {
5507
5729
  ActionRowBuilder,
5508
5730
  AllowedMentionsBuilder,
@@ -5540,6 +5762,7 @@ export {
5540
5762
  EmbedFooterBuilder,
5541
5763
  EmojiOrLabelButtonMixin,
5542
5764
  FileBuilder,
5765
+ FileUploadBuilder,
5543
5766
  LabelBuilder,
5544
5767
  LinkButtonBuilder,
5545
5768
  MediaGalleryBuilder,
@@ -5589,15 +5812,16 @@ export {
5589
5812
  embedAuthorPredicate,
5590
5813
  embedFieldPredicate,
5591
5814
  embedFooterPredicate,
5592
- embedLength,
5593
5815
  embedPredicate,
5594
5816
  emojiPredicate,
5595
5817
  enableValidators,
5818
+ fileBodyMessagePredicate,
5596
5819
  filePredicate,
5820
+ fileUploadPredicate,
5597
5821
  idPredicate,
5598
5822
  integerOptionPredicate,
5599
5823
  isValidationEnabled,
5600
- labelPredicate2 as labelPredicate,
5824
+ labelPredicate,
5601
5825
  localeMapPredicate,
5602
5826
  mediaGalleryItemPredicate,
5603
5827
  mediaGalleryPredicate,
@@ -5612,6 +5836,7 @@ export {
5612
5836
  pollAnswerPredicate,
5613
5837
  pollPredicate,
5614
5838
  pollQuestionPredicate,
5839
+ rawFilePredicate,
5615
5840
  resolveAccessoryComponent,
5616
5841
  resolveBuilder,
5617
5842
  sectionPredicate,
@@ -5622,6 +5847,7 @@ export {
5622
5847
  selectMenuStringPredicate,
5623
5848
  selectMenuUserPredicate,
5624
5849
  separatorPredicate,
5850
+ snowflakePredicate,
5625
5851
  stringOptionPredicate,
5626
5852
  textDisplayPredicate,
5627
5853
  textInputPredicate,