@discordjs/builders 2.0.0-dev.1761177718-886d4a7fc → 2.0.0-djs-file-upload.1761302390-5ae769c9e
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.mts +108 -5
- package/dist/index.d.ts +108 -5
- package/dist/index.js +434 -309
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +367 -244
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -382,8 +382,119 @@ var PremiumButtonBuilder = class extends BaseButtonBuilder {
|
|
|
382
382
|
}
|
|
383
383
|
};
|
|
384
384
|
|
|
385
|
+
// src/components/fileUpload/FileUpload.ts
|
|
386
|
+
import { ComponentType as ComponentType6 } from "discord-api-types/v10";
|
|
387
|
+
|
|
388
|
+
// src/components/fileUpload/Assertions.ts
|
|
389
|
+
import { ComponentType as ComponentType5 } from "discord-api-types/v10";
|
|
390
|
+
import { z as z4 } from "zod";
|
|
391
|
+
var fileUploadPredicate = z4.object({
|
|
392
|
+
type: z4.literal(ComponentType5.FileUpload),
|
|
393
|
+
id: z4.int().min(0).optional(),
|
|
394
|
+
custom_id: customIdPredicate,
|
|
395
|
+
min_values: z4.int().min(0).max(10).optional(),
|
|
396
|
+
max_values: z4.int().min(1).max(10).optional(),
|
|
397
|
+
required: z4.boolean().optional()
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// src/components/fileUpload/FileUpload.ts
|
|
401
|
+
var FileUploadBuilder = class extends ComponentBuilder {
|
|
402
|
+
static {
|
|
403
|
+
__name(this, "FileUploadBuilder");
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* @internal
|
|
407
|
+
*/
|
|
408
|
+
data;
|
|
409
|
+
/**
|
|
410
|
+
* Creates a new file upload.
|
|
411
|
+
*
|
|
412
|
+
* @param data - The API data to create this file upload with
|
|
413
|
+
* @example
|
|
414
|
+
* Creating a file upload from an API data object:
|
|
415
|
+
* ```ts
|
|
416
|
+
* const fileUpload = new FileUploadBuilder({
|
|
417
|
+
* custom_id: "file_upload",
|
|
418
|
+
* min_values: 2,
|
|
419
|
+
* max_values: 5,
|
|
420
|
+
* });
|
|
421
|
+
* ```
|
|
422
|
+
* @example
|
|
423
|
+
* Creating a file upload using setters and API data:
|
|
424
|
+
* ```ts
|
|
425
|
+
* const fileUpload = new FileUploadBuilder({
|
|
426
|
+
* custom_id: "file_upload",
|
|
427
|
+
* min_values: 2,
|
|
428
|
+
* max_values: 5,
|
|
429
|
+
* }).setRequired();
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
constructor(data = {}) {
|
|
433
|
+
super();
|
|
434
|
+
this.data = { ...structuredClone(data), type: ComponentType6.FileUpload };
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Sets the custom id for this file upload.
|
|
438
|
+
*
|
|
439
|
+
* @param customId - The custom id to use
|
|
440
|
+
*/
|
|
441
|
+
setCustomId(customId) {
|
|
442
|
+
this.data.custom_id = customId;
|
|
443
|
+
return this;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Sets the minimum number of file uploads required.
|
|
447
|
+
*
|
|
448
|
+
* @param minValues - The minimum values that must be uploaded
|
|
449
|
+
*/
|
|
450
|
+
setMinValues(minValues) {
|
|
451
|
+
this.data.min_values = minValues;
|
|
452
|
+
return this;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Clears the minimum values.
|
|
456
|
+
*/
|
|
457
|
+
clearMinValues() {
|
|
458
|
+
this.data.min_values = void 0;
|
|
459
|
+
return this;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Sets the maximum number of file uploads required.
|
|
463
|
+
*
|
|
464
|
+
* @param maxValues - The maximum values that must be uploaded
|
|
465
|
+
*/
|
|
466
|
+
setMaxValues(maxValues) {
|
|
467
|
+
this.data.max_values = maxValues;
|
|
468
|
+
return this;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Clears the maximum values.
|
|
472
|
+
*/
|
|
473
|
+
clearMaxValues() {
|
|
474
|
+
this.data.max_values = void 0;
|
|
475
|
+
return this;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Sets whether this file upload is required.
|
|
479
|
+
*
|
|
480
|
+
* @param required - Whether this file upload is required
|
|
481
|
+
*/
|
|
482
|
+
setRequired(required = true) {
|
|
483
|
+
this.data.required = required;
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
488
|
+
*/
|
|
489
|
+
toJSON(validationOverride) {
|
|
490
|
+
const clone = structuredClone(this.data);
|
|
491
|
+
validate(fileUploadPredicate, clone, validationOverride);
|
|
492
|
+
return clone;
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
|
|
385
496
|
// src/components/label/Label.ts
|
|
386
|
-
import { ComponentType as
|
|
497
|
+
import { ComponentType as ComponentType25 } from "discord-api-types/v10";
|
|
387
498
|
|
|
388
499
|
// src/util/resolveBuilder.ts
|
|
389
500
|
function isBuilder(builder, Constructor) {
|
|
@@ -402,10 +513,10 @@ function resolveBuilder(builder, Constructor) {
|
|
|
402
513
|
__name(resolveBuilder, "resolveBuilder");
|
|
403
514
|
|
|
404
515
|
// src/components/Components.ts
|
|
405
|
-
import { ButtonStyle as ButtonStyle5, ComponentType as
|
|
516
|
+
import { ButtonStyle as ButtonStyle5, ComponentType as ComponentType23 } from "discord-api-types/v10";
|
|
406
517
|
|
|
407
518
|
// src/components/ActionRow.ts
|
|
408
|
-
import { ComponentType as
|
|
519
|
+
import { ComponentType as ComponentType14 } from "discord-api-types/v10";
|
|
409
520
|
|
|
410
521
|
// src/util/normalizeArray.ts
|
|
411
522
|
function normalizeArray(arr) {
|
|
@@ -416,7 +527,7 @@ __name(normalizeArray, "normalizeArray");
|
|
|
416
527
|
|
|
417
528
|
// src/components/selectMenu/ChannelSelectMenu.ts
|
|
418
529
|
import {
|
|
419
|
-
ComponentType as
|
|
530
|
+
ComponentType as ComponentType7,
|
|
420
531
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType2
|
|
421
532
|
} from "discord-api-types/v10";
|
|
422
533
|
|
|
@@ -520,7 +631,7 @@ var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
520
631
|
*/
|
|
521
632
|
constructor(data = {}) {
|
|
522
633
|
super();
|
|
523
|
-
this.data = { ...structuredClone(data), type:
|
|
634
|
+
this.data = { ...structuredClone(data), type: ComponentType7.ChannelSelect };
|
|
524
635
|
}
|
|
525
636
|
/**
|
|
526
637
|
* Adds channel types to this select menu.
|
|
@@ -585,7 +696,7 @@ var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
585
696
|
|
|
586
697
|
// src/components/selectMenu/MentionableSelectMenu.ts
|
|
587
698
|
import {
|
|
588
|
-
ComponentType as
|
|
699
|
+
ComponentType as ComponentType8,
|
|
589
700
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType3
|
|
590
701
|
} from "discord-api-types/v10";
|
|
591
702
|
var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
@@ -617,7 +728,7 @@ var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
617
728
|
*/
|
|
618
729
|
constructor(data = {}) {
|
|
619
730
|
super();
|
|
620
|
-
this.data = { ...structuredClone(data), type:
|
|
731
|
+
this.data = { ...structuredClone(data), type: ComponentType8.MentionableSelect };
|
|
621
732
|
}
|
|
622
733
|
/**
|
|
623
734
|
* Adds default roles to this auto populated select menu.
|
|
@@ -684,7 +795,7 @@ var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
684
795
|
|
|
685
796
|
// src/components/selectMenu/RoleSelectMenu.ts
|
|
686
797
|
import {
|
|
687
|
-
ComponentType as
|
|
798
|
+
ComponentType as ComponentType9,
|
|
688
799
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType4
|
|
689
800
|
} from "discord-api-types/v10";
|
|
690
801
|
var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
@@ -716,7 +827,7 @@ var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
716
827
|
*/
|
|
717
828
|
constructor(data = {}) {
|
|
718
829
|
super();
|
|
719
|
-
this.data = { ...structuredClone(data), type:
|
|
830
|
+
this.data = { ...structuredClone(data), type: ComponentType9.RoleSelect };
|
|
720
831
|
}
|
|
721
832
|
/**
|
|
722
833
|
* Adds default roles to this auto populated select menu.
|
|
@@ -758,7 +869,7 @@ var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
758
869
|
};
|
|
759
870
|
|
|
760
871
|
// src/components/selectMenu/StringSelectMenu.ts
|
|
761
|
-
import { ComponentType as
|
|
872
|
+
import { ComponentType as ComponentType10 } from "discord-api-types/v10";
|
|
762
873
|
|
|
763
874
|
// src/components/selectMenu/StringSelectMenuOption.ts
|
|
764
875
|
var StringSelectMenuOptionBuilder = class {
|
|
@@ -909,7 +1020,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
909
1020
|
this.data = {
|
|
910
1021
|
...structuredClone(rest),
|
|
911
1022
|
options: options.map((option) => new StringSelectMenuOptionBuilder(option)),
|
|
912
|
-
type:
|
|
1023
|
+
type: ComponentType10.StringSelect
|
|
913
1024
|
};
|
|
914
1025
|
}
|
|
915
1026
|
/**
|
|
@@ -981,7 +1092,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
981
1092
|
|
|
982
1093
|
// src/components/selectMenu/UserSelectMenu.ts
|
|
983
1094
|
import {
|
|
984
|
-
ComponentType as
|
|
1095
|
+
ComponentType as ComponentType11,
|
|
985
1096
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType5
|
|
986
1097
|
} from "discord-api-types/v10";
|
|
987
1098
|
var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
@@ -1013,7 +1124,7 @@ var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1013
1124
|
*/
|
|
1014
1125
|
constructor(data = {}) {
|
|
1015
1126
|
super();
|
|
1016
|
-
this.data = { ...structuredClone(data), type:
|
|
1127
|
+
this.data = { ...structuredClone(data), type: ComponentType11.UserSelect };
|
|
1017
1128
|
}
|
|
1018
1129
|
/**
|
|
1019
1130
|
* Adds default users to this auto populated select menu.
|
|
@@ -1055,21 +1166,21 @@ var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1055
1166
|
};
|
|
1056
1167
|
|
|
1057
1168
|
// src/components/textInput/TextInput.ts
|
|
1058
|
-
import { ComponentType as
|
|
1169
|
+
import { ComponentType as ComponentType13 } from "discord-api-types/v10";
|
|
1059
1170
|
|
|
1060
1171
|
// src/components/textInput/Assertions.ts
|
|
1061
|
-
import { ComponentType as
|
|
1062
|
-
import { z as
|
|
1063
|
-
var textInputPredicate =
|
|
1172
|
+
import { ComponentType as ComponentType12, TextInputStyle } from "discord-api-types/v10";
|
|
1173
|
+
import { z as z5 } from "zod";
|
|
1174
|
+
var textInputPredicate = z5.object({
|
|
1064
1175
|
id: idPredicate,
|
|
1065
|
-
type:
|
|
1176
|
+
type: z5.literal(ComponentType12.TextInput),
|
|
1066
1177
|
custom_id: customIdPredicate,
|
|
1067
|
-
style:
|
|
1068
|
-
min_length:
|
|
1069
|
-
max_length:
|
|
1070
|
-
placeholder:
|
|
1071
|
-
value:
|
|
1072
|
-
required:
|
|
1178
|
+
style: z5.enum(TextInputStyle),
|
|
1179
|
+
min_length: z5.number().min(0).max(4e3).optional(),
|
|
1180
|
+
max_length: z5.number().min(1).max(4e3).optional(),
|
|
1181
|
+
placeholder: z5.string().max(100).optional(),
|
|
1182
|
+
value: z5.string().min(0).max(4e3).optional(),
|
|
1183
|
+
required: z5.boolean().optional()
|
|
1073
1184
|
});
|
|
1074
1185
|
|
|
1075
1186
|
// src/components/textInput/TextInput.ts
|
|
@@ -1106,7 +1217,7 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1106
1217
|
*/
|
|
1107
1218
|
constructor(data = {}) {
|
|
1108
1219
|
super();
|
|
1109
|
-
this.data = { ...structuredClone(data), type:
|
|
1220
|
+
this.data = { ...structuredClone(data), type: ComponentType13.TextInput };
|
|
1110
1221
|
}
|
|
1111
1222
|
/**
|
|
1112
1223
|
* Sets the custom id for this text input.
|
|
@@ -1264,7 +1375,7 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
1264
1375
|
this.data = {
|
|
1265
1376
|
...structuredClone(rest),
|
|
1266
1377
|
components: components.map((component) => createComponentBuilder(component)),
|
|
1267
|
-
type:
|
|
1378
|
+
type: ComponentType14.ActionRow
|
|
1268
1379
|
};
|
|
1269
1380
|
}
|
|
1270
1381
|
/**
|
|
@@ -1441,67 +1552,67 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
1441
1552
|
|
|
1442
1553
|
// src/components/v2/Container.ts
|
|
1443
1554
|
import {
|
|
1444
|
-
ComponentType as
|
|
1555
|
+
ComponentType as ComponentType22
|
|
1445
1556
|
} from "discord-api-types/v10";
|
|
1446
1557
|
|
|
1447
1558
|
// src/components/v2/Assertions.ts
|
|
1448
|
-
import { ComponentType as
|
|
1449
|
-
import { z as
|
|
1450
|
-
var unfurledMediaItemPredicate =
|
|
1451
|
-
url:
|
|
1559
|
+
import { ComponentType as ComponentType15, SeparatorSpacingSize } from "discord-api-types/v10";
|
|
1560
|
+
import { z as z6 } from "zod";
|
|
1561
|
+
var unfurledMediaItemPredicate = z6.object({
|
|
1562
|
+
url: z6.url({ protocol: /^(?:https?|attachment)$/ })
|
|
1452
1563
|
});
|
|
1453
|
-
var thumbnailPredicate =
|
|
1454
|
-
type:
|
|
1564
|
+
var thumbnailPredicate = z6.object({
|
|
1565
|
+
type: z6.literal(ComponentType15.Thumbnail),
|
|
1455
1566
|
id: idPredicate,
|
|
1456
1567
|
media: unfurledMediaItemPredicate,
|
|
1457
|
-
description:
|
|
1458
|
-
spoiler:
|
|
1568
|
+
description: z6.string().min(1).max(1024).nullish(),
|
|
1569
|
+
spoiler: z6.boolean().optional()
|
|
1459
1570
|
});
|
|
1460
|
-
var unfurledMediaItemAttachmentOnlyPredicate =
|
|
1461
|
-
url:
|
|
1571
|
+
var unfurledMediaItemAttachmentOnlyPredicate = z6.object({
|
|
1572
|
+
url: z6.url({ protocol: /^attachment$/ })
|
|
1462
1573
|
});
|
|
1463
|
-
var filePredicate =
|
|
1464
|
-
type:
|
|
1574
|
+
var filePredicate = z6.object({
|
|
1575
|
+
type: z6.literal(ComponentType15.File),
|
|
1465
1576
|
id: idPredicate,
|
|
1466
1577
|
file: unfurledMediaItemAttachmentOnlyPredicate,
|
|
1467
|
-
spoiler:
|
|
1578
|
+
spoiler: z6.boolean().optional()
|
|
1468
1579
|
});
|
|
1469
|
-
var separatorPredicate =
|
|
1470
|
-
type:
|
|
1580
|
+
var separatorPredicate = z6.object({
|
|
1581
|
+
type: z6.literal(ComponentType15.Separator),
|
|
1471
1582
|
id: idPredicate,
|
|
1472
|
-
divider:
|
|
1473
|
-
spacing:
|
|
1583
|
+
divider: z6.boolean().optional(),
|
|
1584
|
+
spacing: z6.enum(SeparatorSpacingSize).optional()
|
|
1474
1585
|
});
|
|
1475
|
-
var textDisplayPredicate =
|
|
1476
|
-
type:
|
|
1586
|
+
var textDisplayPredicate = z6.object({
|
|
1587
|
+
type: z6.literal(ComponentType15.TextDisplay),
|
|
1477
1588
|
id: idPredicate,
|
|
1478
|
-
content:
|
|
1589
|
+
content: z6.string().min(1).max(4e3)
|
|
1479
1590
|
});
|
|
1480
|
-
var mediaGalleryItemPredicate =
|
|
1591
|
+
var mediaGalleryItemPredicate = z6.object({
|
|
1481
1592
|
id: idPredicate,
|
|
1482
1593
|
media: unfurledMediaItemPredicate,
|
|
1483
|
-
description:
|
|
1484
|
-
spoiler:
|
|
1594
|
+
description: z6.string().min(1).max(1024).nullish(),
|
|
1595
|
+
spoiler: z6.boolean().optional()
|
|
1485
1596
|
});
|
|
1486
|
-
var mediaGalleryPredicate =
|
|
1487
|
-
type:
|
|
1597
|
+
var mediaGalleryPredicate = z6.object({
|
|
1598
|
+
type: z6.literal(ComponentType15.MediaGallery),
|
|
1488
1599
|
id: idPredicate,
|
|
1489
|
-
items:
|
|
1600
|
+
items: z6.array(mediaGalleryItemPredicate).min(1).max(10)
|
|
1490
1601
|
});
|
|
1491
|
-
var sectionPredicate =
|
|
1492
|
-
type:
|
|
1602
|
+
var sectionPredicate = z6.object({
|
|
1603
|
+
type: z6.literal(ComponentType15.Section),
|
|
1493
1604
|
id: idPredicate,
|
|
1494
|
-
components:
|
|
1495
|
-
accessory:
|
|
1496
|
-
|
|
1497
|
-
|
|
1605
|
+
components: z6.array(textDisplayPredicate).min(1).max(3),
|
|
1606
|
+
accessory: z6.union([
|
|
1607
|
+
z6.object({ type: z6.literal(ComponentType15.Button) }),
|
|
1608
|
+
z6.object({ type: z6.literal(ComponentType15.Thumbnail) })
|
|
1498
1609
|
])
|
|
1499
1610
|
});
|
|
1500
|
-
var containerPredicate =
|
|
1501
|
-
type:
|
|
1611
|
+
var containerPredicate = z6.object({
|
|
1612
|
+
type: z6.literal(ComponentType15.Container),
|
|
1502
1613
|
id: idPredicate,
|
|
1503
|
-
components:
|
|
1504
|
-
|
|
1614
|
+
components: z6.array(
|
|
1615
|
+
z6.union([
|
|
1505
1616
|
actionRowPredicate,
|
|
1506
1617
|
filePredicate,
|
|
1507
1618
|
mediaGalleryPredicate,
|
|
@@ -1510,12 +1621,12 @@ var containerPredicate = z5.object({
|
|
|
1510
1621
|
textDisplayPredicate
|
|
1511
1622
|
])
|
|
1512
1623
|
).min(1),
|
|
1513
|
-
spoiler:
|
|
1514
|
-
accent_color:
|
|
1624
|
+
spoiler: z6.boolean().optional(),
|
|
1625
|
+
accent_color: z6.int().min(0).max(16777215).nullish()
|
|
1515
1626
|
});
|
|
1516
1627
|
|
|
1517
1628
|
// src/components/v2/File.ts
|
|
1518
|
-
import { ComponentType as
|
|
1629
|
+
import { ComponentType as ComponentType16 } from "discord-api-types/v10";
|
|
1519
1630
|
var FileBuilder = class extends ComponentBuilder {
|
|
1520
1631
|
static {
|
|
1521
1632
|
__name(this, "FileBuilder");
|
|
@@ -1555,7 +1666,7 @@ var FileBuilder = class extends ComponentBuilder {
|
|
|
1555
1666
|
this.data = {
|
|
1556
1667
|
...structuredClone(rest),
|
|
1557
1668
|
file: file && { url: file.url },
|
|
1558
|
-
type:
|
|
1669
|
+
type: ComponentType16.File
|
|
1559
1670
|
};
|
|
1560
1671
|
}
|
|
1561
1672
|
/**
|
|
@@ -1587,7 +1698,7 @@ var FileBuilder = class extends ComponentBuilder {
|
|
|
1587
1698
|
};
|
|
1588
1699
|
|
|
1589
1700
|
// src/components/v2/MediaGallery.ts
|
|
1590
|
-
import { ComponentType as
|
|
1701
|
+
import { ComponentType as ComponentType17 } from "discord-api-types/v10";
|
|
1591
1702
|
|
|
1592
1703
|
// src/components/v2/MediaGalleryItem.ts
|
|
1593
1704
|
var MediaGalleryItemBuilder = class {
|
|
@@ -1722,7 +1833,7 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
|
1722
1833
|
this.data = {
|
|
1723
1834
|
...structuredClone(rest),
|
|
1724
1835
|
items: items.map((item) => new MediaGalleryItemBuilder(item)),
|
|
1725
|
-
type:
|
|
1836
|
+
type: ComponentType17.MediaGallery
|
|
1726
1837
|
};
|
|
1727
1838
|
}
|
|
1728
1839
|
/**
|
|
@@ -1764,10 +1875,10 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
|
1764
1875
|
};
|
|
1765
1876
|
|
|
1766
1877
|
// src/components/v2/Section.ts
|
|
1767
|
-
import { ComponentType as
|
|
1878
|
+
import { ComponentType as ComponentType20 } from "discord-api-types/v10";
|
|
1768
1879
|
|
|
1769
1880
|
// src/components/v2/TextDisplay.ts
|
|
1770
|
-
import { ComponentType as
|
|
1881
|
+
import { ComponentType as ComponentType18 } from "discord-api-types/v10";
|
|
1771
1882
|
var TextDisplayBuilder = class extends ComponentBuilder {
|
|
1772
1883
|
static {
|
|
1773
1884
|
__name(this, "TextDisplayBuilder");
|
|
@@ -1800,7 +1911,7 @@ var TextDisplayBuilder = class extends ComponentBuilder {
|
|
|
1800
1911
|
super();
|
|
1801
1912
|
this.data = {
|
|
1802
1913
|
...structuredClone(data),
|
|
1803
|
-
type:
|
|
1914
|
+
type: ComponentType18.TextDisplay
|
|
1804
1915
|
};
|
|
1805
1916
|
}
|
|
1806
1917
|
/**
|
|
@@ -1823,7 +1934,7 @@ var TextDisplayBuilder = class extends ComponentBuilder {
|
|
|
1823
1934
|
};
|
|
1824
1935
|
|
|
1825
1936
|
// src/components/v2/Thumbnail.ts
|
|
1826
|
-
import { ComponentType as
|
|
1937
|
+
import { ComponentType as ComponentType19 } from "discord-api-types/v10";
|
|
1827
1938
|
var ThumbnailBuilder = class extends ComponentBuilder {
|
|
1828
1939
|
static {
|
|
1829
1940
|
__name(this, "ThumbnailBuilder");
|
|
@@ -1863,7 +1974,7 @@ var ThumbnailBuilder = class extends ComponentBuilder {
|
|
|
1863
1974
|
this.data = {
|
|
1864
1975
|
...structuredClone(rest),
|
|
1865
1976
|
media: media && { url: media.url },
|
|
1866
|
-
type:
|
|
1977
|
+
type: ComponentType19.Thumbnail
|
|
1867
1978
|
};
|
|
1868
1979
|
}
|
|
1869
1980
|
/**
|
|
@@ -1967,7 +2078,7 @@ var SectionBuilder = class extends ComponentBuilder {
|
|
|
1967
2078
|
...structuredClone(rest),
|
|
1968
2079
|
accessory: accessory && resolveAccessoryComponent(accessory),
|
|
1969
2080
|
components: components.map((component) => new TextDisplayBuilder(component)),
|
|
1970
|
-
type:
|
|
2081
|
+
type: ComponentType20.Section
|
|
1971
2082
|
};
|
|
1972
2083
|
}
|
|
1973
2084
|
/**
|
|
@@ -2080,7 +2191,7 @@ var SectionBuilder = class extends ComponentBuilder {
|
|
|
2080
2191
|
};
|
|
2081
2192
|
|
|
2082
2193
|
// src/components/v2/Separator.ts
|
|
2083
|
-
import { ComponentType as
|
|
2194
|
+
import { ComponentType as ComponentType21 } from "discord-api-types/v10";
|
|
2084
2195
|
var SeparatorBuilder = class extends ComponentBuilder {
|
|
2085
2196
|
static {
|
|
2086
2197
|
__name(this, "SeparatorBuilder");
|
|
@@ -2114,7 +2225,7 @@ var SeparatorBuilder = class extends ComponentBuilder {
|
|
|
2114
2225
|
super();
|
|
2115
2226
|
this.data = {
|
|
2116
2227
|
...structuredClone(data),
|
|
2117
|
-
type:
|
|
2228
|
+
type: ComponentType21.Separator
|
|
2118
2229
|
};
|
|
2119
2230
|
}
|
|
2120
2231
|
/**
|
|
@@ -2178,7 +2289,7 @@ var ContainerBuilder = class extends ComponentBuilder {
|
|
|
2178
2289
|
this.data = {
|
|
2179
2290
|
...structuredClone(rest),
|
|
2180
2291
|
components: components.map((component) => createComponentBuilder(component)),
|
|
2181
|
-
type:
|
|
2292
|
+
type: ComponentType22.Container
|
|
2182
2293
|
};
|
|
2183
2294
|
}
|
|
2184
2295
|
/**
|
|
@@ -2328,38 +2439,40 @@ function createComponentBuilder(data) {
|
|
|
2328
2439
|
return data;
|
|
2329
2440
|
}
|
|
2330
2441
|
switch (data.type) {
|
|
2331
|
-
case
|
|
2442
|
+
case ComponentType23.ActionRow:
|
|
2332
2443
|
return new ActionRowBuilder(data);
|
|
2333
|
-
case
|
|
2444
|
+
case ComponentType23.Button:
|
|
2334
2445
|
return createButtonBuilder(data);
|
|
2335
|
-
case
|
|
2446
|
+
case ComponentType23.StringSelect:
|
|
2336
2447
|
return new StringSelectMenuBuilder(data);
|
|
2337
|
-
case
|
|
2448
|
+
case ComponentType23.TextInput:
|
|
2338
2449
|
return new TextInputBuilder(data);
|
|
2339
|
-
case
|
|
2450
|
+
case ComponentType23.UserSelect:
|
|
2340
2451
|
return new UserSelectMenuBuilder(data);
|
|
2341
|
-
case
|
|
2452
|
+
case ComponentType23.RoleSelect:
|
|
2342
2453
|
return new RoleSelectMenuBuilder(data);
|
|
2343
|
-
case
|
|
2454
|
+
case ComponentType23.MentionableSelect:
|
|
2344
2455
|
return new MentionableSelectMenuBuilder(data);
|
|
2345
|
-
case
|
|
2456
|
+
case ComponentType23.ChannelSelect:
|
|
2346
2457
|
return new ChannelSelectMenuBuilder(data);
|
|
2347
|
-
case
|
|
2458
|
+
case ComponentType23.Thumbnail:
|
|
2348
2459
|
return new ThumbnailBuilder(data);
|
|
2349
|
-
case
|
|
2460
|
+
case ComponentType23.File:
|
|
2350
2461
|
return new FileBuilder(data);
|
|
2351
|
-
case
|
|
2462
|
+
case ComponentType23.Separator:
|
|
2352
2463
|
return new SeparatorBuilder(data);
|
|
2353
|
-
case
|
|
2464
|
+
case ComponentType23.TextDisplay:
|
|
2354
2465
|
return new TextDisplayBuilder(data);
|
|
2355
|
-
case
|
|
2466
|
+
case ComponentType23.MediaGallery:
|
|
2356
2467
|
return new MediaGalleryBuilder(data);
|
|
2357
|
-
case
|
|
2468
|
+
case ComponentType23.Section:
|
|
2358
2469
|
return new SectionBuilder(data);
|
|
2359
|
-
case
|
|
2470
|
+
case ComponentType23.Container:
|
|
2360
2471
|
return new ContainerBuilder(data);
|
|
2361
|
-
case
|
|
2472
|
+
case ComponentType23.Label:
|
|
2362
2473
|
return new LabelBuilder(data);
|
|
2474
|
+
case ComponentType23.FileUpload:
|
|
2475
|
+
return new FileUploadBuilder(data);
|
|
2363
2476
|
default:
|
|
2364
2477
|
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
|
2365
2478
|
}
|
|
@@ -2386,9 +2499,9 @@ function createButtonBuilder(data) {
|
|
|
2386
2499
|
__name(createButtonBuilder, "createButtonBuilder");
|
|
2387
2500
|
function resolveAccessoryComponent(component) {
|
|
2388
2501
|
switch (component.type) {
|
|
2389
|
-
case
|
|
2502
|
+
case ComponentType23.Button:
|
|
2390
2503
|
return createButtonBuilder(component);
|
|
2391
|
-
case
|
|
2504
|
+
case ComponentType23.Thumbnail:
|
|
2392
2505
|
return new ThumbnailBuilder(component);
|
|
2393
2506
|
default:
|
|
2394
2507
|
throw new Error(`Cannot properly serialize section accessory component: ${component.type}`);
|
|
@@ -2397,20 +2510,21 @@ function resolveAccessoryComponent(component) {
|
|
|
2397
2510
|
__name(resolveAccessoryComponent, "resolveAccessoryComponent");
|
|
2398
2511
|
|
|
2399
2512
|
// src/components/label/Assertions.ts
|
|
2400
|
-
import { ComponentType as
|
|
2401
|
-
import { z as
|
|
2402
|
-
var labelPredicate2 =
|
|
2513
|
+
import { ComponentType as ComponentType24 } from "discord-api-types/v10";
|
|
2514
|
+
import { z as z7 } from "zod";
|
|
2515
|
+
var labelPredicate2 = z7.object({
|
|
2403
2516
|
id: idPredicate,
|
|
2404
|
-
type:
|
|
2405
|
-
label:
|
|
2406
|
-
description:
|
|
2407
|
-
component:
|
|
2517
|
+
type: z7.literal(ComponentType24.Label),
|
|
2518
|
+
label: z7.string().min(1).max(45),
|
|
2519
|
+
description: z7.string().min(1).max(100).optional(),
|
|
2520
|
+
component: z7.union([
|
|
2408
2521
|
selectMenuStringPredicate,
|
|
2409
2522
|
textInputPredicate,
|
|
2410
2523
|
selectMenuUserPredicate,
|
|
2411
2524
|
selectMenuRolePredicate,
|
|
2412
2525
|
selectMenuMentionablePredicate,
|
|
2413
|
-
selectMenuChannelPredicate
|
|
2526
|
+
selectMenuChannelPredicate,
|
|
2527
|
+
fileUploadPredicate
|
|
2414
2528
|
])
|
|
2415
2529
|
});
|
|
2416
2530
|
|
|
@@ -2449,9 +2563,8 @@ var LabelBuilder = class extends ComponentBuilder {
|
|
|
2449
2563
|
const { component, ...rest } = data;
|
|
2450
2564
|
this.data = {
|
|
2451
2565
|
...structuredClone(rest),
|
|
2452
|
-
// @ts-expect-error fixed in https://github.com/discordjs/discord.js/pull/11108
|
|
2453
2566
|
component: component ? createComponentBuilder(component) : void 0,
|
|
2454
|
-
type:
|
|
2567
|
+
type: ComponentType25.Label
|
|
2455
2568
|
};
|
|
2456
2569
|
}
|
|
2457
2570
|
/**
|
|
@@ -2533,6 +2646,15 @@ var LabelBuilder = class extends ComponentBuilder {
|
|
|
2533
2646
|
this.data.component = resolveBuilder(input, TextInputBuilder);
|
|
2534
2647
|
return this;
|
|
2535
2648
|
}
|
|
2649
|
+
/**
|
|
2650
|
+
* Sets a file upload component to this label.
|
|
2651
|
+
*
|
|
2652
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
2653
|
+
*/
|
|
2654
|
+
setFileUploadComponent(input) {
|
|
2655
|
+
this.data.component = resolveBuilder(input, FileUploadBuilder);
|
|
2656
|
+
return this;
|
|
2657
|
+
}
|
|
2536
2658
|
/**
|
|
2537
2659
|
* {@inheritDoc ComponentBuilder.toJSON}
|
|
2538
2660
|
*/
|
|
@@ -2792,33 +2914,33 @@ import {
|
|
|
2792
2914
|
InteractionContextType,
|
|
2793
2915
|
ApplicationCommandOptionType
|
|
2794
2916
|
} from "discord-api-types/v10";
|
|
2795
|
-
import { z as
|
|
2796
|
-
var namePredicate =
|
|
2797
|
-
var descriptionPredicate =
|
|
2798
|
-
var sharedNameAndDescriptionPredicate =
|
|
2917
|
+
import { z as z8 } from "zod";
|
|
2918
|
+
var namePredicate = z8.string().min(1).max(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u);
|
|
2919
|
+
var descriptionPredicate = z8.string().min(1).max(100);
|
|
2920
|
+
var sharedNameAndDescriptionPredicate = z8.object({
|
|
2799
2921
|
name: namePredicate,
|
|
2800
2922
|
name_localizations: localeMapPredicate.optional(),
|
|
2801
2923
|
description: descriptionPredicate,
|
|
2802
2924
|
description_localizations: localeMapPredicate.optional()
|
|
2803
2925
|
});
|
|
2804
|
-
var numericMixinNumberOptionPredicate =
|
|
2805
|
-
max_value:
|
|
2806
|
-
min_value:
|
|
2926
|
+
var numericMixinNumberOptionPredicate = z8.object({
|
|
2927
|
+
max_value: z8.float32().optional(),
|
|
2928
|
+
min_value: z8.float32().optional()
|
|
2807
2929
|
});
|
|
2808
|
-
var numericMixinIntegerOptionPredicate =
|
|
2809
|
-
max_value:
|
|
2810
|
-
min_value:
|
|
2930
|
+
var numericMixinIntegerOptionPredicate = z8.object({
|
|
2931
|
+
max_value: z8.int().optional(),
|
|
2932
|
+
min_value: z8.int().optional()
|
|
2811
2933
|
});
|
|
2812
|
-
var channelMixinOptionPredicate =
|
|
2813
|
-
channel_types:
|
|
2934
|
+
var channelMixinOptionPredicate = z8.object({
|
|
2935
|
+
channel_types: z8.literal(ApplicationCommandOptionAllowedChannelTypes).array().optional()
|
|
2814
2936
|
});
|
|
2815
|
-
var autocompleteMixinOptionPredicate =
|
|
2816
|
-
autocomplete:
|
|
2817
|
-
choices:
|
|
2937
|
+
var autocompleteMixinOptionPredicate = z8.object({
|
|
2938
|
+
autocomplete: z8.literal(true),
|
|
2939
|
+
choices: z8.union([z8.never(), z8.never().array(), z8.undefined()])
|
|
2818
2940
|
});
|
|
2819
|
-
var choiceValueStringPredicate =
|
|
2820
|
-
var choiceValueNumberPredicate =
|
|
2821
|
-
var choiceBasePredicate =
|
|
2941
|
+
var choiceValueStringPredicate = z8.string().min(1).max(100);
|
|
2942
|
+
var choiceValueNumberPredicate = z8.number();
|
|
2943
|
+
var choiceBasePredicate = z8.object({
|
|
2822
2944
|
name: choiceValueStringPredicate,
|
|
2823
2945
|
name_localizations: localeMapPredicate.optional()
|
|
2824
2946
|
});
|
|
@@ -2828,8 +2950,8 @@ var choiceStringPredicate = choiceBasePredicate.extend({
|
|
|
2828
2950
|
var choiceNumberPredicate = choiceBasePredicate.extend({
|
|
2829
2951
|
value: choiceValueNumberPredicate
|
|
2830
2952
|
});
|
|
2831
|
-
var choiceBaseMixinPredicate =
|
|
2832
|
-
autocomplete:
|
|
2953
|
+
var choiceBaseMixinPredicate = z8.object({
|
|
2954
|
+
autocomplete: z8.literal(false).optional()
|
|
2833
2955
|
});
|
|
2834
2956
|
var choiceStringMixinPredicate = choiceBaseMixinPredicate.extend({
|
|
2835
2957
|
choices: choiceStringPredicate.array().max(25).optional()
|
|
@@ -2837,7 +2959,7 @@ var choiceStringMixinPredicate = choiceBaseMixinPredicate.extend({
|
|
|
2837
2959
|
var choiceNumberMixinPredicate = choiceBaseMixinPredicate.extend({
|
|
2838
2960
|
choices: choiceNumberPredicate.array().max(25).optional()
|
|
2839
2961
|
});
|
|
2840
|
-
var basicOptionTypesPredicate =
|
|
2962
|
+
var basicOptionTypesPredicate = z8.literal([
|
|
2841
2963
|
ApplicationCommandOptionType.Attachment,
|
|
2842
2964
|
ApplicationCommandOptionType.Boolean,
|
|
2843
2965
|
ApplicationCommandOptionType.Channel,
|
|
@@ -2849,54 +2971,54 @@ var basicOptionTypesPredicate = z7.literal([
|
|
|
2849
2971
|
ApplicationCommandOptionType.User
|
|
2850
2972
|
]);
|
|
2851
2973
|
var basicOptionPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
2852
|
-
required:
|
|
2974
|
+
required: z8.boolean().optional(),
|
|
2853
2975
|
type: basicOptionTypesPredicate
|
|
2854
2976
|
});
|
|
2855
|
-
var autocompleteOrStringChoicesMixinOptionPredicate =
|
|
2977
|
+
var autocompleteOrStringChoicesMixinOptionPredicate = z8.discriminatedUnion("autocomplete", [
|
|
2856
2978
|
autocompleteMixinOptionPredicate,
|
|
2857
2979
|
choiceStringMixinPredicate
|
|
2858
2980
|
]);
|
|
2859
|
-
var autocompleteOrNumberChoicesMixinOptionPredicate =
|
|
2981
|
+
var autocompleteOrNumberChoicesMixinOptionPredicate = z8.discriminatedUnion("autocomplete", [
|
|
2860
2982
|
autocompleteMixinOptionPredicate,
|
|
2861
2983
|
choiceNumberMixinPredicate
|
|
2862
2984
|
]);
|
|
2863
|
-
var channelOptionPredicate =
|
|
2985
|
+
var channelOptionPredicate = z8.object({
|
|
2864
2986
|
...basicOptionPredicate.shape,
|
|
2865
2987
|
...channelMixinOptionPredicate.shape
|
|
2866
2988
|
});
|
|
2867
|
-
var integerOptionPredicate =
|
|
2989
|
+
var integerOptionPredicate = z8.object({
|
|
2868
2990
|
...basicOptionPredicate.shape,
|
|
2869
2991
|
...numericMixinIntegerOptionPredicate.shape
|
|
2870
2992
|
}).and(autocompleteOrNumberChoicesMixinOptionPredicate);
|
|
2871
|
-
var numberOptionPredicate =
|
|
2993
|
+
var numberOptionPredicate = z8.object({
|
|
2872
2994
|
...basicOptionPredicate.shape,
|
|
2873
2995
|
...numericMixinNumberOptionPredicate.shape
|
|
2874
2996
|
}).and(autocompleteOrNumberChoicesMixinOptionPredicate);
|
|
2875
2997
|
var stringOptionPredicate = basicOptionPredicate.extend({
|
|
2876
|
-
max_length:
|
|
2877
|
-
min_length:
|
|
2998
|
+
max_length: z8.number().min(0).max(6e3).optional(),
|
|
2999
|
+
min_length: z8.number().min(1).max(6e3).optional()
|
|
2878
3000
|
}).and(autocompleteOrStringChoicesMixinOptionPredicate);
|
|
2879
3001
|
var baseChatInputCommandPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
2880
|
-
contexts:
|
|
3002
|
+
contexts: z8.array(z8.enum(InteractionContextType)).optional(),
|
|
2881
3003
|
default_member_permissions: memberPermissionsPredicate.optional(),
|
|
2882
|
-
integration_types:
|
|
2883
|
-
nsfw:
|
|
3004
|
+
integration_types: z8.array(z8.enum(ApplicationIntegrationType)).optional(),
|
|
3005
|
+
nsfw: z8.boolean().optional()
|
|
2884
3006
|
});
|
|
2885
|
-
var chatInputCommandOptionsPredicate =
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
3007
|
+
var chatInputCommandOptionsPredicate = z8.union([
|
|
3008
|
+
z8.object({ type: basicOptionTypesPredicate }).array(),
|
|
3009
|
+
z8.object({ type: z8.literal(ApplicationCommandOptionType.Subcommand) }).array(),
|
|
3010
|
+
z8.object({ type: z8.literal(ApplicationCommandOptionType.SubcommandGroup) }).array()
|
|
2889
3011
|
]);
|
|
2890
3012
|
var chatInputCommandPredicate = baseChatInputCommandPredicate.extend({
|
|
2891
3013
|
options: chatInputCommandOptionsPredicate.optional()
|
|
2892
3014
|
});
|
|
2893
3015
|
var chatInputCommandSubcommandGroupPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
2894
|
-
type:
|
|
2895
|
-
options:
|
|
3016
|
+
type: z8.literal(ApplicationCommandOptionType.SubcommandGroup),
|
|
3017
|
+
options: z8.array(z8.object({ type: z8.literal(ApplicationCommandOptionType.Subcommand) })).min(1).max(25)
|
|
2896
3018
|
});
|
|
2897
3019
|
var chatInputCommandSubcommandPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
2898
|
-
type:
|
|
2899
|
-
options:
|
|
3020
|
+
type: z8.literal(ApplicationCommandOptionType.Subcommand),
|
|
3021
|
+
options: z8.array(z8.object({ type: basicOptionTypesPredicate })).max(25)
|
|
2900
3022
|
});
|
|
2901
3023
|
|
|
2902
3024
|
// src/interactions/commands/chatInput/options/ApplicationCommandOptionBase.ts
|
|
@@ -3445,25 +3567,25 @@ var ChatInputCommandBuilder = class extends Mixin8(
|
|
|
3445
3567
|
|
|
3446
3568
|
// src/interactions/commands/contextMenu/Assertions.ts
|
|
3447
3569
|
import { ApplicationCommandType as ApplicationCommandType2, ApplicationIntegrationType as ApplicationIntegrationType2, InteractionContextType as InteractionContextType2 } from "discord-api-types/v10";
|
|
3448
|
-
import { z as
|
|
3449
|
-
var namePredicate2 =
|
|
3570
|
+
import { z as z9 } from "zod";
|
|
3571
|
+
var namePredicate2 = z9.string().min(1).max(32).refine((val) => val.trim().length > 0, {
|
|
3450
3572
|
error: "Must not consist of only whitespace."
|
|
3451
3573
|
});
|
|
3452
|
-
var contextsPredicate =
|
|
3453
|
-
var integrationTypesPredicate =
|
|
3454
|
-
var baseContextMenuCommandPredicate =
|
|
3574
|
+
var contextsPredicate = z9.array(z9.enum(InteractionContextType2));
|
|
3575
|
+
var integrationTypesPredicate = z9.array(z9.enum(ApplicationIntegrationType2));
|
|
3576
|
+
var baseContextMenuCommandPredicate = z9.object({
|
|
3455
3577
|
contexts: contextsPredicate.optional(),
|
|
3456
3578
|
default_member_permissions: memberPermissionsPredicate.optional(),
|
|
3457
3579
|
name: namePredicate2,
|
|
3458
3580
|
name_localizations: localeMapPredicate.optional(),
|
|
3459
3581
|
integration_types: integrationTypesPredicate.optional(),
|
|
3460
|
-
nsfw:
|
|
3582
|
+
nsfw: z9.boolean().optional()
|
|
3461
3583
|
});
|
|
3462
3584
|
var userCommandPredicate = baseContextMenuCommandPredicate.extend({
|
|
3463
|
-
type:
|
|
3585
|
+
type: z9.literal(ApplicationCommandType2.User)
|
|
3464
3586
|
});
|
|
3465
3587
|
var messageCommandPredicate = baseContextMenuCommandPredicate.extend({
|
|
3466
|
-
type:
|
|
3588
|
+
type: z9.literal(ApplicationCommandType2.Message)
|
|
3467
3589
|
});
|
|
3468
3590
|
|
|
3469
3591
|
// src/interactions/commands/contextMenu/ContextMenuCommand.ts
|
|
@@ -3525,16 +3647,16 @@ var UserContextCommandBuilder = class extends ContextMenuCommandBuilder {
|
|
|
3525
3647
|
};
|
|
3526
3648
|
|
|
3527
3649
|
// src/interactions/modals/Assertions.ts
|
|
3528
|
-
import { ComponentType as
|
|
3529
|
-
import { z as
|
|
3530
|
-
var titlePredicate =
|
|
3531
|
-
var modalPredicate =
|
|
3650
|
+
import { ComponentType as ComponentType26 } from "discord-api-types/v10";
|
|
3651
|
+
import { z as z10 } from "zod";
|
|
3652
|
+
var titlePredicate = z10.string().min(1).max(45);
|
|
3653
|
+
var modalPredicate = z10.object({
|
|
3532
3654
|
title: titlePredicate,
|
|
3533
3655
|
custom_id: customIdPredicate,
|
|
3534
|
-
components:
|
|
3535
|
-
|
|
3536
|
-
type:
|
|
3537
|
-
components:
|
|
3656
|
+
components: z10.union([
|
|
3657
|
+
z10.object({
|
|
3658
|
+
type: z10.literal(ComponentType26.ActionRow),
|
|
3659
|
+
components: z10.object({ type: z10.literal(ComponentType26.TextInput) }).array().length(1)
|
|
3538
3660
|
}),
|
|
3539
3661
|
labelPredicate2,
|
|
3540
3662
|
textDisplayPredicate
|
|
@@ -3565,7 +3687,6 @@ var ModalBuilder = class {
|
|
|
3565
3687
|
const { components = [], ...rest } = data;
|
|
3566
3688
|
this.data = {
|
|
3567
3689
|
...structuredClone(rest),
|
|
3568
|
-
// @ts-expect-error fixed in https://github.com/discordjs/discord.js/pull/11108
|
|
3569
3690
|
components: components.map((component) => createComponentBuilder(component))
|
|
3570
3691
|
};
|
|
3571
3692
|
}
|
|
@@ -3661,7 +3782,7 @@ var ModalBuilder = class {
|
|
|
3661
3782
|
};
|
|
3662
3783
|
|
|
3663
3784
|
// src/messages/embed/Assertions.ts
|
|
3664
|
-
import { z as
|
|
3785
|
+
import { z as z11 } from "zod";
|
|
3665
3786
|
|
|
3666
3787
|
// src/util/componentUtil.ts
|
|
3667
3788
|
function embedLength(data) {
|
|
@@ -3670,34 +3791,34 @@ function embedLength(data) {
|
|
|
3670
3791
|
__name(embedLength, "embedLength");
|
|
3671
3792
|
|
|
3672
3793
|
// src/messages/embed/Assertions.ts
|
|
3673
|
-
var namePredicate3 =
|
|
3674
|
-
var URLPredicate =
|
|
3675
|
-
var URLWithAttachmentProtocolPredicate =
|
|
3676
|
-
var embedFieldPredicate =
|
|
3794
|
+
var namePredicate3 = z11.string().max(256);
|
|
3795
|
+
var URLPredicate = z11.url({ protocol: /^https?$/ });
|
|
3796
|
+
var URLWithAttachmentProtocolPredicate = z11.url({ protocol: /^(?:https?|attachment)$/ });
|
|
3797
|
+
var embedFieldPredicate = z11.object({
|
|
3677
3798
|
name: namePredicate3,
|
|
3678
|
-
value:
|
|
3679
|
-
inline:
|
|
3799
|
+
value: z11.string().max(1024),
|
|
3800
|
+
inline: z11.boolean().optional()
|
|
3680
3801
|
});
|
|
3681
|
-
var embedAuthorPredicate =
|
|
3802
|
+
var embedAuthorPredicate = z11.object({
|
|
3682
3803
|
name: namePredicate3.min(1),
|
|
3683
3804
|
icon_url: URLWithAttachmentProtocolPredicate.optional(),
|
|
3684
3805
|
url: URLPredicate.optional()
|
|
3685
3806
|
});
|
|
3686
|
-
var embedFooterPredicate =
|
|
3687
|
-
text:
|
|
3807
|
+
var embedFooterPredicate = z11.object({
|
|
3808
|
+
text: z11.string().min(1).max(2048),
|
|
3688
3809
|
icon_url: URLWithAttachmentProtocolPredicate.optional()
|
|
3689
3810
|
});
|
|
3690
|
-
var embedPredicate =
|
|
3811
|
+
var embedPredicate = z11.object({
|
|
3691
3812
|
title: namePredicate3.min(1).optional(),
|
|
3692
|
-
description:
|
|
3813
|
+
description: z11.string().min(1).max(4096).optional(),
|
|
3693
3814
|
url: URLPredicate.optional(),
|
|
3694
|
-
timestamp:
|
|
3695
|
-
color:
|
|
3815
|
+
timestamp: z11.string().optional(),
|
|
3816
|
+
color: z11.int().min(0).max(16777215).optional(),
|
|
3696
3817
|
footer: embedFooterPredicate.optional(),
|
|
3697
|
-
image:
|
|
3698
|
-
thumbnail:
|
|
3818
|
+
image: z11.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
|
|
3819
|
+
thumbnail: z11.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
|
|
3699
3820
|
author: embedAuthorPredicate.optional(),
|
|
3700
|
-
fields:
|
|
3821
|
+
fields: z11.array(embedFieldPredicate).max(25).optional()
|
|
3701
3822
|
}).refine(
|
|
3702
3823
|
(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
3824
|
{
|
|
@@ -4183,19 +4304,19 @@ var EmbedBuilder = class {
|
|
|
4183
4304
|
|
|
4184
4305
|
// src/messages/poll/Assertions.ts
|
|
4185
4306
|
import { PollLayoutType } from "discord-api-types/v10";
|
|
4186
|
-
import { z as
|
|
4187
|
-
var pollQuestionPredicate =
|
|
4188
|
-
var pollAnswerMediaPredicate =
|
|
4189
|
-
text:
|
|
4307
|
+
import { z as z12 } from "zod";
|
|
4308
|
+
var pollQuestionPredicate = z12.object({ text: z12.string().min(1).max(300) });
|
|
4309
|
+
var pollAnswerMediaPredicate = z12.object({
|
|
4310
|
+
text: z12.string().min(1).max(55),
|
|
4190
4311
|
emoji: emojiPredicate.optional()
|
|
4191
4312
|
});
|
|
4192
|
-
var pollAnswerPredicate =
|
|
4193
|
-
var pollPredicate =
|
|
4313
|
+
var pollAnswerPredicate = z12.object({ poll_media: pollAnswerMediaPredicate });
|
|
4314
|
+
var pollPredicate = z12.object({
|
|
4194
4315
|
question: pollQuestionPredicate,
|
|
4195
|
-
answers:
|
|
4196
|
-
duration:
|
|
4197
|
-
allow_multiselect:
|
|
4198
|
-
layout_type:
|
|
4316
|
+
answers: z12.array(pollAnswerPredicate).min(1).max(10),
|
|
4317
|
+
duration: z12.number().min(1).max(768).optional(),
|
|
4318
|
+
allow_multiselect: z12.boolean().optional(),
|
|
4319
|
+
layout_type: z12.enum(PollLayoutType).optional()
|
|
4199
4320
|
});
|
|
4200
4321
|
|
|
4201
4322
|
// src/messages/poll/PollMedia.ts
|
|
@@ -4524,95 +4645,95 @@ var PollBuilder = class {
|
|
|
4524
4645
|
};
|
|
4525
4646
|
|
|
4526
4647
|
// src/messages/Assertions.ts
|
|
4527
|
-
import { AllowedMentionsTypes, ComponentType as
|
|
4528
|
-
import { z as
|
|
4529
|
-
var attachmentPredicate =
|
|
4530
|
-
id:
|
|
4531
|
-
description:
|
|
4532
|
-
duration_secs:
|
|
4533
|
-
filename:
|
|
4534
|
-
title:
|
|
4535
|
-
waveform:
|
|
4648
|
+
import { AllowedMentionsTypes, ComponentType as ComponentType27, MessageFlags, MessageReferenceType } from "discord-api-types/v10";
|
|
4649
|
+
import { z as z13 } from "zod";
|
|
4650
|
+
var attachmentPredicate = z13.object({
|
|
4651
|
+
id: z13.union([z13.string(), z13.number()]),
|
|
4652
|
+
description: z13.string().max(1024).optional(),
|
|
4653
|
+
duration_secs: z13.number().max(2 ** 31 - 1).optional(),
|
|
4654
|
+
filename: z13.string().max(1024).optional(),
|
|
4655
|
+
title: z13.string().max(1024).optional(),
|
|
4656
|
+
waveform: z13.string().max(400).optional()
|
|
4536
4657
|
});
|
|
4537
|
-
var allowedMentionPredicate =
|
|
4538
|
-
parse:
|
|
4539
|
-
roles:
|
|
4540
|
-
users:
|
|
4541
|
-
replied_user:
|
|
4658
|
+
var allowedMentionPredicate = z13.object({
|
|
4659
|
+
parse: z13.enum(AllowedMentionsTypes).array().optional(),
|
|
4660
|
+
roles: z13.string().array().max(100).optional(),
|
|
4661
|
+
users: z13.string().array().max(100).optional(),
|
|
4662
|
+
replied_user: z13.boolean().optional()
|
|
4542
4663
|
}).refine(
|
|
4543
4664
|
(data) => !(data.parse?.includes(AllowedMentionsTypes.User) && data.users?.length || data.parse?.includes(AllowedMentionsTypes.Role) && data.roles?.length),
|
|
4544
4665
|
{
|
|
4545
4666
|
error: 'Cannot specify both parse: ["users"] and non-empty users array, or parse: ["roles"] and non-empty roles array. These are mutually exclusive'
|
|
4546
4667
|
}
|
|
4547
4668
|
);
|
|
4548
|
-
var messageReferencePredicate =
|
|
4549
|
-
channel_id:
|
|
4550
|
-
fail_if_not_exists:
|
|
4551
|
-
guild_id:
|
|
4552
|
-
message_id:
|
|
4553
|
-
type:
|
|
4669
|
+
var messageReferencePredicate = z13.object({
|
|
4670
|
+
channel_id: z13.string().optional(),
|
|
4671
|
+
fail_if_not_exists: z13.boolean().optional(),
|
|
4672
|
+
guild_id: z13.string().optional(),
|
|
4673
|
+
message_id: z13.string(),
|
|
4674
|
+
type: z13.enum(MessageReferenceType).optional()
|
|
4554
4675
|
});
|
|
4555
|
-
var baseMessagePredicate =
|
|
4556
|
-
nonce:
|
|
4557
|
-
tts:
|
|
4676
|
+
var baseMessagePredicate = z13.object({
|
|
4677
|
+
nonce: z13.union([z13.string().max(25), z13.number()]).optional(),
|
|
4678
|
+
tts: z13.boolean().optional(),
|
|
4558
4679
|
allowed_mentions: allowedMentionPredicate.optional(),
|
|
4559
4680
|
message_reference: messageReferencePredicate.optional(),
|
|
4560
4681
|
attachments: attachmentPredicate.array().max(10).optional(),
|
|
4561
|
-
enforce_nonce:
|
|
4682
|
+
enforce_nonce: z13.boolean().optional()
|
|
4562
4683
|
});
|
|
4563
|
-
var basicActionRowPredicate =
|
|
4564
|
-
type:
|
|
4565
|
-
components:
|
|
4566
|
-
type:
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4684
|
+
var basicActionRowPredicate = z13.object({
|
|
4685
|
+
type: z13.literal(ComponentType27.ActionRow),
|
|
4686
|
+
components: z13.object({
|
|
4687
|
+
type: z13.literal([
|
|
4688
|
+
ComponentType27.Button,
|
|
4689
|
+
ComponentType27.ChannelSelect,
|
|
4690
|
+
ComponentType27.MentionableSelect,
|
|
4691
|
+
ComponentType27.RoleSelect,
|
|
4692
|
+
ComponentType27.StringSelect,
|
|
4693
|
+
ComponentType27.UserSelect
|
|
4573
4694
|
])
|
|
4574
4695
|
}).array()
|
|
4575
4696
|
});
|
|
4576
4697
|
var messageNoComponentsV2Predicate = baseMessagePredicate.extend({
|
|
4577
|
-
content:
|
|
4698
|
+
content: z13.string().max(2e3).optional(),
|
|
4578
4699
|
embeds: embedPredicate.array().max(10).optional(),
|
|
4579
|
-
sticker_ids:
|
|
4700
|
+
sticker_ids: z13.array(z13.string()).max(3).optional(),
|
|
4580
4701
|
poll: pollPredicate.optional(),
|
|
4581
4702
|
components: basicActionRowPredicate.array().max(5).optional(),
|
|
4582
|
-
flags:
|
|
4703
|
+
flags: z13.int().optional().refine((flags) => !flags || (flags & MessageFlags.IsComponentsV2) === 0, {
|
|
4583
4704
|
error: "Cannot set content, embeds, stickers, or poll with IsComponentsV2 flag set"
|
|
4584
4705
|
})
|
|
4585
4706
|
}).refine(
|
|
4586
4707
|
(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
4708
|
{ error: "Messages must have content, embeds, a poll, attachments, components or stickers" }
|
|
4588
4709
|
);
|
|
4589
|
-
var allTopLevelComponentsPredicate =
|
|
4710
|
+
var allTopLevelComponentsPredicate = z13.union([
|
|
4590
4711
|
basicActionRowPredicate,
|
|
4591
|
-
|
|
4592
|
-
type:
|
|
4712
|
+
z13.object({
|
|
4713
|
+
type: z13.literal([
|
|
4593
4714
|
// Components v2
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4715
|
+
ComponentType27.Container,
|
|
4716
|
+
ComponentType27.File,
|
|
4717
|
+
ComponentType27.MediaGallery,
|
|
4718
|
+
ComponentType27.Section,
|
|
4719
|
+
ComponentType27.Separator,
|
|
4720
|
+
ComponentType27.TextDisplay,
|
|
4721
|
+
ComponentType27.Thumbnail
|
|
4601
4722
|
])
|
|
4602
4723
|
})
|
|
4603
4724
|
]).array().min(1).max(10);
|
|
4604
4725
|
var messageComponentsV2Predicate = baseMessagePredicate.extend({
|
|
4605
4726
|
components: allTopLevelComponentsPredicate,
|
|
4606
|
-
flags:
|
|
4727
|
+
flags: z13.int().refine((flags) => (flags & MessageFlags.IsComponentsV2) === MessageFlags.IsComponentsV2, {
|
|
4607
4728
|
error: "Must set IsComponentsV2 flag to use Components V2"
|
|
4608
4729
|
}),
|
|
4609
4730
|
// These fields cannot be set
|
|
4610
|
-
content:
|
|
4611
|
-
embeds:
|
|
4612
|
-
sticker_ids:
|
|
4613
|
-
poll:
|
|
4731
|
+
content: z13.string().length(0).nullish(),
|
|
4732
|
+
embeds: z13.array(z13.never()).nullish(),
|
|
4733
|
+
sticker_ids: z13.array(z13.never()).nullish(),
|
|
4734
|
+
poll: z13.null().optional()
|
|
4614
4735
|
});
|
|
4615
|
-
var messagePredicate =
|
|
4736
|
+
var messagePredicate = z13.union([messageNoComponentsV2Predicate, messageComponentsV2Predicate]);
|
|
4616
4737
|
|
|
4617
4738
|
// src/messages/AllowedMentions.ts
|
|
4618
4739
|
var AllowedMentionsBuilder = class {
|
|
@@ -5502,7 +5623,7 @@ var MessageBuilder = class {
|
|
|
5502
5623
|
};
|
|
5503
5624
|
|
|
5504
5625
|
// src/index.ts
|
|
5505
|
-
var version = "2.0.0-
|
|
5626
|
+
var version = "2.0.0-djs-file-upload.1761302390-5ae769c9e";
|
|
5506
5627
|
export {
|
|
5507
5628
|
ActionRowBuilder,
|
|
5508
5629
|
AllowedMentionsBuilder,
|
|
@@ -5540,6 +5661,7 @@ export {
|
|
|
5540
5661
|
EmbedFooterBuilder,
|
|
5541
5662
|
EmojiOrLabelButtonMixin,
|
|
5542
5663
|
FileBuilder,
|
|
5664
|
+
FileUploadBuilder,
|
|
5543
5665
|
LabelBuilder,
|
|
5544
5666
|
LinkButtonBuilder,
|
|
5545
5667
|
MediaGalleryBuilder,
|
|
@@ -5594,6 +5716,7 @@ export {
|
|
|
5594
5716
|
emojiPredicate,
|
|
5595
5717
|
enableValidators,
|
|
5596
5718
|
filePredicate,
|
|
5719
|
+
fileUploadPredicate,
|
|
5597
5720
|
idPredicate,
|
|
5598
5721
|
integerOptionPredicate,
|
|
5599
5722
|
isValidationEnabled,
|