@discordjs/builders 1.10.1 → 1.11.1
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 +630 -62
- package/dist/index.d.ts +630 -62
- package/dist/index.js +950 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +902 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -51,21 +51,28 @@ __export(src_exports, {
|
|
|
51
51
|
ChannelSelectMenuBuilder: () => ChannelSelectMenuBuilder,
|
|
52
52
|
ComponentAssertions: () => Assertions_exports2,
|
|
53
53
|
ComponentBuilder: () => ComponentBuilder,
|
|
54
|
-
|
|
54
|
+
ComponentsV2Assertions: () => Assertions_exports4,
|
|
55
|
+
ContainerBuilder: () => ContainerBuilder,
|
|
56
|
+
ContextMenuCommandAssertions: () => Assertions_exports7,
|
|
55
57
|
ContextMenuCommandBuilder: () => ContextMenuCommandBuilder,
|
|
56
58
|
EmbedAssertions: () => Assertions_exports,
|
|
57
59
|
EmbedBuilder: () => EmbedBuilder,
|
|
60
|
+
FileBuilder: () => FileBuilder,
|
|
61
|
+
MediaGalleryBuilder: () => MediaGalleryBuilder,
|
|
62
|
+
MediaGalleryItemBuilder: () => MediaGalleryItemBuilder,
|
|
58
63
|
MentionableSelectMenuBuilder: () => MentionableSelectMenuBuilder,
|
|
59
|
-
ModalAssertions: () =>
|
|
64
|
+
ModalAssertions: () => Assertions_exports5,
|
|
60
65
|
ModalBuilder: () => ModalBuilder,
|
|
61
66
|
RoleSelectMenuBuilder: () => RoleSelectMenuBuilder,
|
|
67
|
+
SectionBuilder: () => SectionBuilder,
|
|
62
68
|
SelectMenuBuilder: () => StringSelectMenuBuilder,
|
|
63
69
|
SelectMenuOptionBuilder: () => StringSelectMenuOptionBuilder,
|
|
70
|
+
SeparatorBuilder: () => SeparatorBuilder,
|
|
64
71
|
SharedNameAndDescription: () => SharedNameAndDescription,
|
|
65
72
|
SharedSlashCommand: () => SharedSlashCommand,
|
|
66
73
|
SharedSlashCommandOptions: () => SharedSlashCommandOptions,
|
|
67
74
|
SharedSlashCommandSubcommands: () => SharedSlashCommandSubcommands,
|
|
68
|
-
SlashCommandAssertions: () =>
|
|
75
|
+
SlashCommandAssertions: () => Assertions_exports6,
|
|
69
76
|
SlashCommandAttachmentOption: () => SlashCommandAttachmentOption,
|
|
70
77
|
SlashCommandBooleanOption: () => SlashCommandBooleanOption,
|
|
71
78
|
SlashCommandBuilder: () => SlashCommandBuilder,
|
|
@@ -80,8 +87,10 @@ __export(src_exports, {
|
|
|
80
87
|
SlashCommandUserOption: () => SlashCommandUserOption,
|
|
81
88
|
StringSelectMenuBuilder: () => StringSelectMenuBuilder,
|
|
82
89
|
StringSelectMenuOptionBuilder: () => StringSelectMenuOptionBuilder,
|
|
90
|
+
TextDisplayBuilder: () => TextDisplayBuilder,
|
|
83
91
|
TextInputAssertions: () => Assertions_exports3,
|
|
84
92
|
TextInputBuilder: () => TextInputBuilder,
|
|
93
|
+
ThumbnailBuilder: () => ThumbnailBuilder,
|
|
85
94
|
UserSelectMenuBuilder: () => UserSelectMenuBuilder,
|
|
86
95
|
createComponentBuilder: () => createComponentBuilder,
|
|
87
96
|
disableValidators: () => disableValidators,
|
|
@@ -89,6 +98,7 @@ __export(src_exports, {
|
|
|
89
98
|
enableValidators: () => enableValidators,
|
|
90
99
|
isValidationEnabled: () => isValidationEnabled,
|
|
91
100
|
normalizeArray: () => normalizeArray,
|
|
101
|
+
resolveBuilder: () => resolveBuilder,
|
|
92
102
|
version: () => version
|
|
93
103
|
});
|
|
94
104
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -405,6 +415,7 @@ __export(Assertions_exports2, {
|
|
|
405
415
|
defaultValidator: () => defaultValidator,
|
|
406
416
|
disabledValidator: () => disabledValidator,
|
|
407
417
|
emojiValidator: () => emojiValidator,
|
|
418
|
+
idValidator: () => idValidator,
|
|
408
419
|
jsonOptionValidator: () => jsonOptionValidator,
|
|
409
420
|
labelValueDescriptionValidator: () => labelValueDescriptionValidator,
|
|
410
421
|
minMaxValidator: () => minMaxValidator,
|
|
@@ -507,6 +518,7 @@ var StringSelectMenuOptionBuilder = class {
|
|
|
507
518
|
};
|
|
508
519
|
|
|
509
520
|
// src/components/Assertions.ts
|
|
521
|
+
var idValidator = import_shapeshift2.s.number().safeInt().greaterThanOrEqual(1).lessThan(4294967296).setValidationEnabled(isValidationEnabled);
|
|
510
522
|
var customIdValidator = import_shapeshift2.s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
511
523
|
var emojiValidator = import_shapeshift2.s.object({
|
|
512
524
|
id: import_shapeshift2.s.string(),
|
|
@@ -574,7 +586,7 @@ function validateRequiredButtonParameters(style, label, emoji, customId, skuId,
|
|
|
574
586
|
__name(validateRequiredButtonParameters, "validateRequiredButtonParameters");
|
|
575
587
|
|
|
576
588
|
// src/components/ActionRow.ts
|
|
577
|
-
var
|
|
589
|
+
var import_v1019 = require("discord-api-types/v10");
|
|
578
590
|
|
|
579
591
|
// src/components/Component.ts
|
|
580
592
|
var ComponentBuilder = class {
|
|
@@ -593,10 +605,26 @@ var ComponentBuilder = class {
|
|
|
593
605
|
constructor(data) {
|
|
594
606
|
this.data = data;
|
|
595
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* Sets the id (not the custom id) for this component.
|
|
610
|
+
*
|
|
611
|
+
* @param id - The id for this component
|
|
612
|
+
*/
|
|
613
|
+
setId(id) {
|
|
614
|
+
this.data.id = idValidator.parse(id);
|
|
615
|
+
return this;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Clears the id of this component, defaulting to a default incremented id.
|
|
619
|
+
*/
|
|
620
|
+
clearId() {
|
|
621
|
+
this.data.id = void 0;
|
|
622
|
+
return this;
|
|
623
|
+
}
|
|
596
624
|
};
|
|
597
625
|
|
|
598
626
|
// src/components/Components.ts
|
|
599
|
-
var
|
|
627
|
+
var import_v1018 = require("discord-api-types/v10");
|
|
600
628
|
|
|
601
629
|
// src/components/button/Button.ts
|
|
602
630
|
var import_v102 = require("discord-api-types/v10");
|
|
@@ -1377,33 +1405,828 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1377
1405
|
}
|
|
1378
1406
|
};
|
|
1379
1407
|
|
|
1408
|
+
// src/components/v2/Container.ts
|
|
1409
|
+
var import_v1015 = require("discord-api-types/v10");
|
|
1410
|
+
|
|
1411
|
+
// src/components/v2/Assertions.ts
|
|
1412
|
+
var Assertions_exports4 = {};
|
|
1413
|
+
__export(Assertions_exports4, {
|
|
1414
|
+
accessoryPredicate: () => accessoryPredicate,
|
|
1415
|
+
assertReturnOfBuilder: () => assertReturnOfBuilder,
|
|
1416
|
+
containerColorPredicate: () => containerColorPredicate,
|
|
1417
|
+
descriptionPredicate: () => descriptionPredicate2,
|
|
1418
|
+
dividerPredicate: () => dividerPredicate,
|
|
1419
|
+
filePredicate: () => filePredicate,
|
|
1420
|
+
spacingPredicate: () => spacingPredicate,
|
|
1421
|
+
spoilerPredicate: () => spoilerPredicate,
|
|
1422
|
+
textDisplayContentPredicate: () => textDisplayContentPredicate,
|
|
1423
|
+
unfurledMediaItemPredicate: () => unfurledMediaItemPredicate,
|
|
1424
|
+
validateComponentArray: () => validateComponentArray
|
|
1425
|
+
});
|
|
1426
|
+
var import_shapeshift4 = require("@sapphire/shapeshift");
|
|
1427
|
+
var import_v1011 = require("discord-api-types/v10");
|
|
1428
|
+
|
|
1429
|
+
// src/components/v2/Thumbnail.ts
|
|
1430
|
+
var import_v1010 = require("discord-api-types/v10");
|
|
1431
|
+
var ThumbnailBuilder = class extends ComponentBuilder {
|
|
1432
|
+
static {
|
|
1433
|
+
__name(this, "ThumbnailBuilder");
|
|
1434
|
+
}
|
|
1435
|
+
/**
|
|
1436
|
+
* Creates a new thumbnail from API data.
|
|
1437
|
+
*
|
|
1438
|
+
* @param data - The API data to create this thumbnail with
|
|
1439
|
+
* @example
|
|
1440
|
+
* Creating a thumbnail from an API data object:
|
|
1441
|
+
* ```ts
|
|
1442
|
+
* const thumbnaik = new ThumbnailBuilder({
|
|
1443
|
+
* description: 'some text',
|
|
1444
|
+
* media: {
|
|
1445
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/4.png',
|
|
1446
|
+
* },
|
|
1447
|
+
* });
|
|
1448
|
+
* ```
|
|
1449
|
+
* @example
|
|
1450
|
+
* Creating a thumbnail using setters and API data:
|
|
1451
|
+
* ```ts
|
|
1452
|
+
* const thumbnail = new ThumbnailBuilder({
|
|
1453
|
+
* media: {
|
|
1454
|
+
* url: 'attachment://image.png',
|
|
1455
|
+
* },
|
|
1456
|
+
* })
|
|
1457
|
+
* .setDescription('alt text');
|
|
1458
|
+
* ```
|
|
1459
|
+
*/
|
|
1460
|
+
constructor(data = {}) {
|
|
1461
|
+
super({
|
|
1462
|
+
type: import_v1010.ComponentType.Thumbnail,
|
|
1463
|
+
...data,
|
|
1464
|
+
media: data.media ? { url: data.media.url } : void 0
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Sets the description of this thumbnail.
|
|
1469
|
+
*
|
|
1470
|
+
* @param description - The description to use
|
|
1471
|
+
*/
|
|
1472
|
+
setDescription(description) {
|
|
1473
|
+
this.data.description = descriptionPredicate2.parse(description);
|
|
1474
|
+
return this;
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Clears the description of this thumbnail.
|
|
1478
|
+
*/
|
|
1479
|
+
clearDescription() {
|
|
1480
|
+
this.data.description = void 0;
|
|
1481
|
+
return this;
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Sets the spoiler status of this thumbnail.
|
|
1485
|
+
*
|
|
1486
|
+
* @param spoiler - The spoiler status to use
|
|
1487
|
+
*/
|
|
1488
|
+
setSpoiler(spoiler = true) {
|
|
1489
|
+
this.data.spoiler = spoilerPredicate.parse(spoiler);
|
|
1490
|
+
return this;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Sets the media URL of this thumbnail.
|
|
1494
|
+
*
|
|
1495
|
+
* @param url - The URL to use
|
|
1496
|
+
*/
|
|
1497
|
+
setURL(url) {
|
|
1498
|
+
this.data.media = unfurledMediaItemPredicate.parse({ url });
|
|
1499
|
+
return this;
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* {@inheritdoc ComponentBuilder.toJSON}
|
|
1503
|
+
*/
|
|
1504
|
+
toJSON() {
|
|
1505
|
+
unfurledMediaItemPredicate.parse(this.data.media);
|
|
1506
|
+
return { ...this.data };
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
|
|
1510
|
+
// src/components/v2/Assertions.ts
|
|
1511
|
+
var unfurledMediaItemPredicate = import_shapeshift4.s.object({
|
|
1512
|
+
url: import_shapeshift4.s.string().url(
|
|
1513
|
+
{ allowedProtocols: ["http:", "https:", "attachment:"] },
|
|
1514
|
+
{ message: "Invalid protocol for media URL. Must be http:, https:, or attachment:" }
|
|
1515
|
+
)
|
|
1516
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
1517
|
+
var descriptionPredicate2 = import_shapeshift4.s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(1024).setValidationEnabled(isValidationEnabled);
|
|
1518
|
+
var filePredicate = import_shapeshift4.s.object({
|
|
1519
|
+
url: import_shapeshift4.s.string().url({ allowedProtocols: ["attachment:"] }, { message: "Invalid protocol for file URL. Must be attachment:" })
|
|
1520
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
1521
|
+
var spoilerPredicate = import_shapeshift4.s.boolean();
|
|
1522
|
+
var dividerPredicate = import_shapeshift4.s.boolean();
|
|
1523
|
+
var spacingPredicate = import_shapeshift4.s.nativeEnum(import_v1011.SeparatorSpacingSize);
|
|
1524
|
+
var textDisplayContentPredicate = import_shapeshift4.s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
1525
|
+
var accessoryPredicate = import_shapeshift4.s.instance(ButtonBuilder).or(import_shapeshift4.s.instance(ThumbnailBuilder)).setValidationEnabled(isValidationEnabled);
|
|
1526
|
+
var containerColorPredicate = colorPredicate.nullish();
|
|
1527
|
+
function assertReturnOfBuilder(input, ExpectedInstanceOf) {
|
|
1528
|
+
import_shapeshift4.s.instance(ExpectedInstanceOf).parse(input);
|
|
1529
|
+
}
|
|
1530
|
+
__name(assertReturnOfBuilder, "assertReturnOfBuilder");
|
|
1531
|
+
function validateComponentArray(input, min, max, ExpectedInstanceOf) {
|
|
1532
|
+
(ExpectedInstanceOf ? import_shapeshift4.s.instance(ExpectedInstanceOf) : import_shapeshift4.s.instance(ComponentBuilder)).array().lengthGreaterThanOrEqual(min).lengthLessThanOrEqual(max).parse(input);
|
|
1533
|
+
}
|
|
1534
|
+
__name(validateComponentArray, "validateComponentArray");
|
|
1535
|
+
|
|
1536
|
+
// src/components/v2/File.ts
|
|
1537
|
+
var import_v1012 = require("discord-api-types/v10");
|
|
1538
|
+
var FileBuilder = class extends ComponentBuilder {
|
|
1539
|
+
static {
|
|
1540
|
+
__name(this, "FileBuilder");
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Creates a new file from API data.
|
|
1544
|
+
*
|
|
1545
|
+
* @param data - The API data to create this file with
|
|
1546
|
+
* @example
|
|
1547
|
+
* Creating a file from an API data object:
|
|
1548
|
+
* ```ts
|
|
1549
|
+
* const file = new FileBuilder({
|
|
1550
|
+
* spoiler: true,
|
|
1551
|
+
* file: {
|
|
1552
|
+
* url: 'attachment://file.png',
|
|
1553
|
+
* },
|
|
1554
|
+
* });
|
|
1555
|
+
* ```
|
|
1556
|
+
* @example
|
|
1557
|
+
* Creating a file using setters and API data:
|
|
1558
|
+
* ```ts
|
|
1559
|
+
* const file = new FileBuilder({
|
|
1560
|
+
* file: {
|
|
1561
|
+
* url: 'attachment://image.jpg',
|
|
1562
|
+
* },
|
|
1563
|
+
* })
|
|
1564
|
+
* .setSpoiler(false);
|
|
1565
|
+
* ```
|
|
1566
|
+
*/
|
|
1567
|
+
constructor(data = {}) {
|
|
1568
|
+
super({ type: import_v1012.ComponentType.File, ...data, file: data.file ? { url: data.file.url } : void 0 });
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Sets the spoiler status of this file.
|
|
1572
|
+
*
|
|
1573
|
+
* @param spoiler - The spoiler status to use
|
|
1574
|
+
*/
|
|
1575
|
+
setSpoiler(spoiler = true) {
|
|
1576
|
+
this.data.spoiler = spoilerPredicate.parse(spoiler);
|
|
1577
|
+
return this;
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Sets the media URL of this file.
|
|
1581
|
+
*
|
|
1582
|
+
* @param url - The URL to use
|
|
1583
|
+
*/
|
|
1584
|
+
setURL(url) {
|
|
1585
|
+
this.data.file = filePredicate.parse({ url });
|
|
1586
|
+
return this;
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1590
|
+
*/
|
|
1591
|
+
toJSON() {
|
|
1592
|
+
filePredicate.parse(this.data.file);
|
|
1593
|
+
return { ...this.data, file: { ...this.data.file } };
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1597
|
+
// src/components/v2/Separator.ts
|
|
1598
|
+
var import_v1013 = require("discord-api-types/v10");
|
|
1599
|
+
var SeparatorBuilder = class extends ComponentBuilder {
|
|
1600
|
+
static {
|
|
1601
|
+
__name(this, "SeparatorBuilder");
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Creates a new separator from API data.
|
|
1605
|
+
*
|
|
1606
|
+
* @param data - The API data to create this separator with
|
|
1607
|
+
* @example
|
|
1608
|
+
* Creating a separator from an API data object:
|
|
1609
|
+
* ```ts
|
|
1610
|
+
* const separator = new SeparatorBuilder({
|
|
1611
|
+
* spacing: SeparatorSpacingSize.Small,
|
|
1612
|
+
* divider: true,
|
|
1613
|
+
* });
|
|
1614
|
+
* ```
|
|
1615
|
+
* @example
|
|
1616
|
+
* Creating a separator using setters and API data:
|
|
1617
|
+
* ```ts
|
|
1618
|
+
* const separator = new SeparatorBuilder({
|
|
1619
|
+
* spacing: SeparatorSpacingSize.Large,
|
|
1620
|
+
* })
|
|
1621
|
+
* .setDivider(false);
|
|
1622
|
+
* ```
|
|
1623
|
+
*/
|
|
1624
|
+
constructor(data = {}) {
|
|
1625
|
+
super({
|
|
1626
|
+
type: import_v1013.ComponentType.Separator,
|
|
1627
|
+
...data
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Sets whether this separator should show a divider line.
|
|
1632
|
+
*
|
|
1633
|
+
* @param divider - Whether to show a divider line
|
|
1634
|
+
*/
|
|
1635
|
+
setDivider(divider = true) {
|
|
1636
|
+
this.data.divider = dividerPredicate.parse(divider);
|
|
1637
|
+
return this;
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* Sets the spacing of this separator.
|
|
1641
|
+
*
|
|
1642
|
+
* @param spacing - The spacing to use
|
|
1643
|
+
*/
|
|
1644
|
+
setSpacing(spacing) {
|
|
1645
|
+
this.data.spacing = spacingPredicate.parse(spacing);
|
|
1646
|
+
return this;
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* Clears the spacing of this separator.
|
|
1650
|
+
*/
|
|
1651
|
+
clearSpacing() {
|
|
1652
|
+
this.data.spacing = void 0;
|
|
1653
|
+
return this;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1657
|
+
*/
|
|
1658
|
+
toJSON() {
|
|
1659
|
+
return { ...this.data };
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
// src/components/v2/TextDisplay.ts
|
|
1664
|
+
var import_v1014 = require("discord-api-types/v10");
|
|
1665
|
+
var TextDisplayBuilder = class extends ComponentBuilder {
|
|
1666
|
+
static {
|
|
1667
|
+
__name(this, "TextDisplayBuilder");
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Creates a new text display from API data.
|
|
1671
|
+
*
|
|
1672
|
+
* @param data - The API data to create this text display with
|
|
1673
|
+
* @example
|
|
1674
|
+
* Creating a text display from an API data object:
|
|
1675
|
+
* ```ts
|
|
1676
|
+
* const textDisplay = new TextDisplayBuilder({
|
|
1677
|
+
* content: 'some text',
|
|
1678
|
+
* });
|
|
1679
|
+
* ```
|
|
1680
|
+
* @example
|
|
1681
|
+
* Creating a text display using setters and API data:
|
|
1682
|
+
* ```ts
|
|
1683
|
+
* const textDisplay = new TextDisplayBuilder({
|
|
1684
|
+
* content: 'old text',
|
|
1685
|
+
* })
|
|
1686
|
+
* .setContent('new text');
|
|
1687
|
+
* ```
|
|
1688
|
+
*/
|
|
1689
|
+
constructor(data = {}) {
|
|
1690
|
+
super({
|
|
1691
|
+
type: import_v1014.ComponentType.TextDisplay,
|
|
1692
|
+
...data
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Sets the text of this text display.
|
|
1697
|
+
*
|
|
1698
|
+
* @param content - The text to use
|
|
1699
|
+
*/
|
|
1700
|
+
setContent(content) {
|
|
1701
|
+
this.data.content = textDisplayContentPredicate.parse(content);
|
|
1702
|
+
return this;
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1706
|
+
*/
|
|
1707
|
+
toJSON() {
|
|
1708
|
+
textDisplayContentPredicate.parse(this.data.content);
|
|
1709
|
+
return { ...this.data };
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1713
|
+
// src/components/v2/Container.ts
|
|
1714
|
+
var ContainerBuilder = class extends ComponentBuilder {
|
|
1715
|
+
static {
|
|
1716
|
+
__name(this, "ContainerBuilder");
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* The components within this container.
|
|
1720
|
+
*/
|
|
1721
|
+
components;
|
|
1722
|
+
/**
|
|
1723
|
+
* Creates a new container from API data.
|
|
1724
|
+
*
|
|
1725
|
+
* @param data - The API data to create this container with
|
|
1726
|
+
* @example
|
|
1727
|
+
* Creating a container from an API data object:
|
|
1728
|
+
* ```ts
|
|
1729
|
+
* const container = new ContainerBuilder({
|
|
1730
|
+
* components: [
|
|
1731
|
+
* {
|
|
1732
|
+
* content: "Some text here",
|
|
1733
|
+
* type: ComponentType.TextDisplay,
|
|
1734
|
+
* },
|
|
1735
|
+
* ],
|
|
1736
|
+
* });
|
|
1737
|
+
* ```
|
|
1738
|
+
* @example
|
|
1739
|
+
* Creating a container using setters and API data:
|
|
1740
|
+
* ```ts
|
|
1741
|
+
* const container = new ContainerBuilder({
|
|
1742
|
+
* components: [
|
|
1743
|
+
* {
|
|
1744
|
+
* content: "# Heading",
|
|
1745
|
+
* type: ComponentType.TextDisplay,
|
|
1746
|
+
* },
|
|
1747
|
+
* ],
|
|
1748
|
+
* })
|
|
1749
|
+
* .addComponents(separator, section);
|
|
1750
|
+
* ```
|
|
1751
|
+
*/
|
|
1752
|
+
constructor({ components, ...data } = {}) {
|
|
1753
|
+
super({ type: import_v1015.ComponentType.Container, ...data });
|
|
1754
|
+
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* Sets the accent color of this container.
|
|
1758
|
+
*
|
|
1759
|
+
* @param color - The color to use
|
|
1760
|
+
*/
|
|
1761
|
+
setAccentColor(color) {
|
|
1762
|
+
containerColorPredicate.parse(color);
|
|
1763
|
+
if (Array.isArray(color)) {
|
|
1764
|
+
const [red, green, blue] = color;
|
|
1765
|
+
this.data.accent_color = (red << 16) + (green << 8) + blue;
|
|
1766
|
+
return this;
|
|
1767
|
+
}
|
|
1768
|
+
this.data.accent_color = color;
|
|
1769
|
+
return this;
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Clears the accent color of this container.
|
|
1773
|
+
*/
|
|
1774
|
+
clearAccentColor() {
|
|
1775
|
+
this.data.accent_color = void 0;
|
|
1776
|
+
return this;
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Adds action row components to this container.
|
|
1780
|
+
*
|
|
1781
|
+
* @param components - The action row components to add
|
|
1782
|
+
*/
|
|
1783
|
+
addActionRowComponents(...components) {
|
|
1784
|
+
this.components.push(
|
|
1785
|
+
...normalizeArray(components).map((component) => resolveBuilder(component, ActionRowBuilder))
|
|
1786
|
+
);
|
|
1787
|
+
return this;
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Adds file components to this container.
|
|
1791
|
+
*
|
|
1792
|
+
* @param components - The file components to add
|
|
1793
|
+
*/
|
|
1794
|
+
addFileComponents(...components) {
|
|
1795
|
+
this.components.push(...normalizeArray(components).map((component) => resolveBuilder(component, FileBuilder)));
|
|
1796
|
+
return this;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Adds media gallery components to this container.
|
|
1800
|
+
*
|
|
1801
|
+
* @param components - The media gallery components to add
|
|
1802
|
+
*/
|
|
1803
|
+
addMediaGalleryComponents(...components) {
|
|
1804
|
+
this.components.push(
|
|
1805
|
+
...normalizeArray(components).map((component) => resolveBuilder(component, MediaGalleryBuilder))
|
|
1806
|
+
);
|
|
1807
|
+
return this;
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* Adds section components to this container.
|
|
1811
|
+
*
|
|
1812
|
+
* @param components - The section components to add
|
|
1813
|
+
*/
|
|
1814
|
+
addSectionComponents(...components) {
|
|
1815
|
+
this.components.push(...normalizeArray(components).map((component) => resolveBuilder(component, SectionBuilder)));
|
|
1816
|
+
return this;
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Adds separator components to this container.
|
|
1820
|
+
*
|
|
1821
|
+
* @param components - The separator components to add
|
|
1822
|
+
*/
|
|
1823
|
+
addSeparatorComponents(...components) {
|
|
1824
|
+
this.components.push(...normalizeArray(components).map((component) => resolveBuilder(component, SeparatorBuilder)));
|
|
1825
|
+
return this;
|
|
1826
|
+
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Adds text display components to this container.
|
|
1829
|
+
*
|
|
1830
|
+
* @param components - The text display components to add
|
|
1831
|
+
*/
|
|
1832
|
+
addTextDisplayComponents(...components) {
|
|
1833
|
+
this.components.push(
|
|
1834
|
+
...normalizeArray(components).map((component) => resolveBuilder(component, TextDisplayBuilder))
|
|
1835
|
+
);
|
|
1836
|
+
return this;
|
|
1837
|
+
}
|
|
1838
|
+
/**
|
|
1839
|
+
* Removes, replaces, or inserts components for this container.
|
|
1840
|
+
*
|
|
1841
|
+
* @param index - The index to start removing, replacing or inserting components
|
|
1842
|
+
* @param deleteCount - The amount of components to remove
|
|
1843
|
+
* @param components - The components to set
|
|
1844
|
+
*/
|
|
1845
|
+
spliceComponents(index, deleteCount, ...components) {
|
|
1846
|
+
this.components.splice(
|
|
1847
|
+
index,
|
|
1848
|
+
deleteCount,
|
|
1849
|
+
...normalizeArray(components).map(
|
|
1850
|
+
(component) => component instanceof ComponentBuilder ? component : createComponentBuilder(component)
|
|
1851
|
+
)
|
|
1852
|
+
);
|
|
1853
|
+
return this;
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Sets the spoiler status of this container.
|
|
1857
|
+
*
|
|
1858
|
+
* @param spoiler - The spoiler status to use
|
|
1859
|
+
*/
|
|
1860
|
+
setSpoiler(spoiler = true) {
|
|
1861
|
+
this.data.spoiler = spoilerPredicate.parse(spoiler);
|
|
1862
|
+
return this;
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1866
|
+
*/
|
|
1867
|
+
toJSON() {
|
|
1868
|
+
validateComponentArray(this.components, 1, 10);
|
|
1869
|
+
return {
|
|
1870
|
+
...this.data,
|
|
1871
|
+
components: this.components.map((component) => component.toJSON())
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
|
|
1876
|
+
// src/components/v2/MediaGallery.ts
|
|
1877
|
+
var import_v1016 = require("discord-api-types/v10");
|
|
1878
|
+
|
|
1879
|
+
// src/components/v2/MediaGalleryItem.ts
|
|
1880
|
+
var MediaGalleryItemBuilder = class {
|
|
1881
|
+
static {
|
|
1882
|
+
__name(this, "MediaGalleryItemBuilder");
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* The API data associated with this media gallery item.
|
|
1886
|
+
*/
|
|
1887
|
+
data;
|
|
1888
|
+
/**
|
|
1889
|
+
* Creates a new media gallery item from API data.
|
|
1890
|
+
*
|
|
1891
|
+
* @param data - The API data to create this media gallery item with
|
|
1892
|
+
* @example
|
|
1893
|
+
* Creating a media gallery item from an API data object:
|
|
1894
|
+
* ```ts
|
|
1895
|
+
* const item = new MediaGalleryItemBuilder({
|
|
1896
|
+
* description: "Some text here",
|
|
1897
|
+
* media: {
|
|
1898
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/2.png',
|
|
1899
|
+
* },
|
|
1900
|
+
* });
|
|
1901
|
+
* ```
|
|
1902
|
+
* @example
|
|
1903
|
+
* Creating a media gallery item using setters and API data:
|
|
1904
|
+
* ```ts
|
|
1905
|
+
* const item = new MediaGalleryItemBuilder({
|
|
1906
|
+
* media: {
|
|
1907
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/5.png',
|
|
1908
|
+
* },
|
|
1909
|
+
* })
|
|
1910
|
+
* .setDescription("alt text");
|
|
1911
|
+
* ```
|
|
1912
|
+
*/
|
|
1913
|
+
constructor(data = {}) {
|
|
1914
|
+
this.data = data;
|
|
1915
|
+
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Sets the description of this media gallery item.
|
|
1918
|
+
*
|
|
1919
|
+
* @param description - The description to use
|
|
1920
|
+
*/
|
|
1921
|
+
setDescription(description) {
|
|
1922
|
+
this.data.description = descriptionPredicate2.parse(description);
|
|
1923
|
+
return this;
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* Clears the description of this media gallery item.
|
|
1927
|
+
*/
|
|
1928
|
+
clearDescription() {
|
|
1929
|
+
this.data.description = void 0;
|
|
1930
|
+
return this;
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Sets the spoiler status of this media gallery item.
|
|
1934
|
+
*
|
|
1935
|
+
* @param spoiler - The spoiler status to use
|
|
1936
|
+
*/
|
|
1937
|
+
setSpoiler(spoiler = true) {
|
|
1938
|
+
this.data.spoiler = spoilerPredicate.parse(spoiler);
|
|
1939
|
+
return this;
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Sets the media URL of this media gallery item.
|
|
1943
|
+
*
|
|
1944
|
+
* @param url - The URL to use
|
|
1945
|
+
*/
|
|
1946
|
+
setURL(url) {
|
|
1947
|
+
this.data.media = unfurledMediaItemPredicate.parse({ url });
|
|
1948
|
+
return this;
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Serializes this builder to API-compatible JSON data.
|
|
1952
|
+
*
|
|
1953
|
+
* @remarks
|
|
1954
|
+
* This method runs validations on the data before serializing it.
|
|
1955
|
+
* As such, it may throw an error if the data is invalid.
|
|
1956
|
+
*/
|
|
1957
|
+
toJSON() {
|
|
1958
|
+
unfurledMediaItemPredicate.parse(this.data.media);
|
|
1959
|
+
return { ...this.data };
|
|
1960
|
+
}
|
|
1961
|
+
};
|
|
1962
|
+
|
|
1963
|
+
// src/components/v2/MediaGallery.ts
|
|
1964
|
+
var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
1965
|
+
static {
|
|
1966
|
+
__name(this, "MediaGalleryBuilder");
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* The components within this container.
|
|
1970
|
+
*/
|
|
1971
|
+
items;
|
|
1972
|
+
/**
|
|
1973
|
+
* Creates a new media gallery from API data.
|
|
1974
|
+
*
|
|
1975
|
+
* @param data - The API data to create this media gallery with
|
|
1976
|
+
* @example
|
|
1977
|
+
* Creating a media gallery from an API data object:
|
|
1978
|
+
* ```ts
|
|
1979
|
+
* const mediaGallery = new MediaGalleryBuilder({
|
|
1980
|
+
* items: [
|
|
1981
|
+
* {
|
|
1982
|
+
* description: "Some text here",
|
|
1983
|
+
* media: {
|
|
1984
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/2.png',
|
|
1985
|
+
* },
|
|
1986
|
+
* },
|
|
1987
|
+
* ],
|
|
1988
|
+
* });
|
|
1989
|
+
* ```
|
|
1990
|
+
* @example
|
|
1991
|
+
* Creating a media gallery using setters and API data:
|
|
1992
|
+
* ```ts
|
|
1993
|
+
* const mediaGallery = new MediaGalleryBuilder({
|
|
1994
|
+
* items: [
|
|
1995
|
+
* {
|
|
1996
|
+
* description: "alt text",
|
|
1997
|
+
* media: {
|
|
1998
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/5.png',
|
|
1999
|
+
* },
|
|
2000
|
+
* },
|
|
2001
|
+
* ],
|
|
2002
|
+
* })
|
|
2003
|
+
* .addItems(item2, item3);
|
|
2004
|
+
* ```
|
|
2005
|
+
*/
|
|
2006
|
+
constructor({ items, ...data } = {}) {
|
|
2007
|
+
super({ type: import_v1016.ComponentType.MediaGallery, ...data });
|
|
2008
|
+
this.items = items?.map((item) => new MediaGalleryItemBuilder(item)) ?? [];
|
|
2009
|
+
}
|
|
2010
|
+
/**
|
|
2011
|
+
* Adds items to this media gallery.
|
|
2012
|
+
*
|
|
2013
|
+
* @param items - The items to add
|
|
2014
|
+
*/
|
|
2015
|
+
addItems(...items) {
|
|
2016
|
+
this.items.push(
|
|
2017
|
+
...normalizeArray(items).map((input) => {
|
|
2018
|
+
const result = resolveBuilder(input, MediaGalleryItemBuilder);
|
|
2019
|
+
assertReturnOfBuilder(result, MediaGalleryItemBuilder);
|
|
2020
|
+
return result;
|
|
2021
|
+
})
|
|
2022
|
+
);
|
|
2023
|
+
return this;
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Removes, replaces, or inserts media gallery items for this media gallery.
|
|
2027
|
+
*
|
|
2028
|
+
* @param index - The index to start removing, replacing or inserting items
|
|
2029
|
+
* @param deleteCount - The amount of items to remove
|
|
2030
|
+
* @param items - The items to insert
|
|
2031
|
+
*/
|
|
2032
|
+
spliceItems(index, deleteCount, ...items) {
|
|
2033
|
+
this.items.splice(
|
|
2034
|
+
index,
|
|
2035
|
+
deleteCount,
|
|
2036
|
+
...normalizeArray(items).map((input) => {
|
|
2037
|
+
const result = resolveBuilder(input, MediaGalleryItemBuilder);
|
|
2038
|
+
assertReturnOfBuilder(result, MediaGalleryItemBuilder);
|
|
2039
|
+
return result;
|
|
2040
|
+
})
|
|
2041
|
+
);
|
|
2042
|
+
return this;
|
|
2043
|
+
}
|
|
2044
|
+
/**
|
|
2045
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
2046
|
+
*/
|
|
2047
|
+
toJSON() {
|
|
2048
|
+
validateComponentArray(this.items, 1, 10, MediaGalleryItemBuilder);
|
|
2049
|
+
return {
|
|
2050
|
+
...this.data,
|
|
2051
|
+
items: this.items.map((item) => item.toJSON())
|
|
2052
|
+
};
|
|
2053
|
+
}
|
|
2054
|
+
};
|
|
2055
|
+
|
|
2056
|
+
// src/components/v2/Section.ts
|
|
2057
|
+
var import_v1017 = require("discord-api-types/v10");
|
|
2058
|
+
var SectionBuilder = class extends ComponentBuilder {
|
|
2059
|
+
static {
|
|
2060
|
+
__name(this, "SectionBuilder");
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* The components within this section.
|
|
2064
|
+
*/
|
|
2065
|
+
components;
|
|
2066
|
+
/**
|
|
2067
|
+
* The accessory of this section.
|
|
2068
|
+
*/
|
|
2069
|
+
accessory;
|
|
2070
|
+
/**
|
|
2071
|
+
* Creates a new section from API data.
|
|
2072
|
+
*
|
|
2073
|
+
* @param data - The API data to create this section with
|
|
2074
|
+
* @example
|
|
2075
|
+
* Creating a section from an API data object:
|
|
2076
|
+
* ```ts
|
|
2077
|
+
* const section = new SectionBuilder({
|
|
2078
|
+
* components: [
|
|
2079
|
+
* {
|
|
2080
|
+
* content: "Some text here",
|
|
2081
|
+
* type: ComponentType.TextDisplay,
|
|
2082
|
+
* },
|
|
2083
|
+
* ],
|
|
2084
|
+
* accessory: {
|
|
2085
|
+
* media: {
|
|
2086
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/3.png',
|
|
2087
|
+
* },
|
|
2088
|
+
* }
|
|
2089
|
+
* });
|
|
2090
|
+
* ```
|
|
2091
|
+
* @example
|
|
2092
|
+
* Creating a section using setters and API data:
|
|
2093
|
+
* ```ts
|
|
2094
|
+
* const section = new SectionBuilder({
|
|
2095
|
+
* components: [
|
|
2096
|
+
* {
|
|
2097
|
+
* content: "# Heading",
|
|
2098
|
+
* type: ComponentType.TextDisplay,
|
|
2099
|
+
* },
|
|
2100
|
+
* ],
|
|
2101
|
+
* })
|
|
2102
|
+
* .setPrimaryButtonAccessory(button);
|
|
2103
|
+
* ```
|
|
2104
|
+
*/
|
|
2105
|
+
constructor({ components, accessory, ...data } = {}) {
|
|
2106
|
+
super({ type: import_v1017.ComponentType.Section, ...data });
|
|
2107
|
+
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
|
2108
|
+
this.accessory = accessory ? createComponentBuilder(accessory) : void 0;
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* Sets the accessory of this section to a button.
|
|
2112
|
+
*
|
|
2113
|
+
* @param accessory - The accessory to use
|
|
2114
|
+
*/
|
|
2115
|
+
setButtonAccessory(accessory) {
|
|
2116
|
+
Reflect.set(this, "accessory", accessoryPredicate.parse(resolveBuilder(accessory, ButtonBuilder)));
|
|
2117
|
+
return this;
|
|
2118
|
+
}
|
|
2119
|
+
/**
|
|
2120
|
+
* Sets the accessory of this section to a thumbnail.
|
|
2121
|
+
*
|
|
2122
|
+
* @param accessory - The accessory to use
|
|
2123
|
+
*/
|
|
2124
|
+
setThumbnailAccessory(accessory) {
|
|
2125
|
+
Reflect.set(this, "accessory", accessoryPredicate.parse(resolveBuilder(accessory, ThumbnailBuilder)));
|
|
2126
|
+
return this;
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Adds text display components to this section.
|
|
2130
|
+
*
|
|
2131
|
+
* @param components - The text display components to add
|
|
2132
|
+
*/
|
|
2133
|
+
addTextDisplayComponents(...components) {
|
|
2134
|
+
this.components.push(
|
|
2135
|
+
...normalizeArray(components).map((input) => {
|
|
2136
|
+
const result = resolveBuilder(input, TextDisplayBuilder);
|
|
2137
|
+
assertReturnOfBuilder(result, TextDisplayBuilder);
|
|
2138
|
+
return result;
|
|
2139
|
+
})
|
|
2140
|
+
);
|
|
2141
|
+
return this;
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Removes, replaces, or inserts text display components for this section.
|
|
2145
|
+
*
|
|
2146
|
+
* @param index - The index to start removing, replacing or inserting text display components
|
|
2147
|
+
* @param deleteCount - The amount of text display components to remove
|
|
2148
|
+
* @param components - The text display components to insert
|
|
2149
|
+
*/
|
|
2150
|
+
spliceTextDisplayComponents(index, deleteCount, ...components) {
|
|
2151
|
+
this.components.splice(
|
|
2152
|
+
index,
|
|
2153
|
+
deleteCount,
|
|
2154
|
+
...normalizeArray(components).map((input) => {
|
|
2155
|
+
const result = resolveBuilder(input, TextDisplayBuilder);
|
|
2156
|
+
assertReturnOfBuilder(result, TextDisplayBuilder);
|
|
2157
|
+
return result;
|
|
2158
|
+
})
|
|
2159
|
+
);
|
|
2160
|
+
return this;
|
|
2161
|
+
}
|
|
2162
|
+
/**
|
|
2163
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
2164
|
+
*/
|
|
2165
|
+
toJSON() {
|
|
2166
|
+
validateComponentArray(this.components, 1, 3, TextDisplayBuilder);
|
|
2167
|
+
return {
|
|
2168
|
+
...this.data,
|
|
2169
|
+
components: this.components.map((component) => component.toJSON()),
|
|
2170
|
+
accessory: accessoryPredicate.parse(this.accessory).toJSON()
|
|
2171
|
+
};
|
|
2172
|
+
}
|
|
2173
|
+
};
|
|
2174
|
+
|
|
1380
2175
|
// src/components/Components.ts
|
|
1381
2176
|
function createComponentBuilder(data) {
|
|
1382
2177
|
if (data instanceof ComponentBuilder) {
|
|
1383
2178
|
return data;
|
|
1384
2179
|
}
|
|
1385
2180
|
switch (data.type) {
|
|
1386
|
-
case
|
|
2181
|
+
case import_v1018.ComponentType.ActionRow:
|
|
1387
2182
|
return new ActionRowBuilder(data);
|
|
1388
|
-
case
|
|
2183
|
+
case import_v1018.ComponentType.Button:
|
|
1389
2184
|
return new ButtonBuilder(data);
|
|
1390
|
-
case
|
|
2185
|
+
case import_v1018.ComponentType.StringSelect:
|
|
1391
2186
|
return new StringSelectMenuBuilder(data);
|
|
1392
|
-
case
|
|
2187
|
+
case import_v1018.ComponentType.TextInput:
|
|
1393
2188
|
return new TextInputBuilder(data);
|
|
1394
|
-
case
|
|
2189
|
+
case import_v1018.ComponentType.UserSelect:
|
|
1395
2190
|
return new UserSelectMenuBuilder(data);
|
|
1396
|
-
case
|
|
2191
|
+
case import_v1018.ComponentType.RoleSelect:
|
|
1397
2192
|
return new RoleSelectMenuBuilder(data);
|
|
1398
|
-
case
|
|
2193
|
+
case import_v1018.ComponentType.MentionableSelect:
|
|
1399
2194
|
return new MentionableSelectMenuBuilder(data);
|
|
1400
|
-
case
|
|
2195
|
+
case import_v1018.ComponentType.ChannelSelect:
|
|
1401
2196
|
return new ChannelSelectMenuBuilder(data);
|
|
2197
|
+
case import_v1018.ComponentType.File:
|
|
2198
|
+
return new FileBuilder(data);
|
|
2199
|
+
case import_v1018.ComponentType.Container:
|
|
2200
|
+
return new ContainerBuilder(data);
|
|
2201
|
+
case import_v1018.ComponentType.Section:
|
|
2202
|
+
return new SectionBuilder(data);
|
|
2203
|
+
case import_v1018.ComponentType.Separator:
|
|
2204
|
+
return new SeparatorBuilder(data);
|
|
2205
|
+
case import_v1018.ComponentType.TextDisplay:
|
|
2206
|
+
return new TextDisplayBuilder(data);
|
|
2207
|
+
case import_v1018.ComponentType.Thumbnail:
|
|
2208
|
+
return new ThumbnailBuilder(data);
|
|
2209
|
+
case import_v1018.ComponentType.MediaGallery:
|
|
2210
|
+
return new MediaGalleryBuilder(data);
|
|
1402
2211
|
default:
|
|
1403
2212
|
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
|
1404
2213
|
}
|
|
1405
2214
|
}
|
|
1406
2215
|
__name(createComponentBuilder, "createComponentBuilder");
|
|
2216
|
+
function isBuilder(builder, Constructor) {
|
|
2217
|
+
return builder instanceof Constructor;
|
|
2218
|
+
}
|
|
2219
|
+
__name(isBuilder, "isBuilder");
|
|
2220
|
+
function resolveBuilder(builder, Constructor) {
|
|
2221
|
+
if (isBuilder(builder, Constructor)) {
|
|
2222
|
+
return builder;
|
|
2223
|
+
}
|
|
2224
|
+
if (typeof builder === "function") {
|
|
2225
|
+
return builder(new Constructor());
|
|
2226
|
+
}
|
|
2227
|
+
return new Constructor(builder);
|
|
2228
|
+
}
|
|
2229
|
+
__name(resolveBuilder, "resolveBuilder");
|
|
1407
2230
|
|
|
1408
2231
|
// src/components/ActionRow.ts
|
|
1409
2232
|
var ActionRowBuilder = class extends ComponentBuilder {
|
|
@@ -1449,7 +2272,7 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
1449
2272
|
* ```
|
|
1450
2273
|
*/
|
|
1451
2274
|
constructor({ components, ...data } = {}) {
|
|
1452
|
-
super({ type:
|
|
2275
|
+
super({ type: import_v1019.ComponentType.ActionRow, ...data });
|
|
1453
2276
|
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
|
1454
2277
|
}
|
|
1455
2278
|
/**
|
|
@@ -1482,15 +2305,15 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
1482
2305
|
};
|
|
1483
2306
|
|
|
1484
2307
|
// src/interactions/modals/Assertions.ts
|
|
1485
|
-
var
|
|
1486
|
-
__export(
|
|
2308
|
+
var Assertions_exports5 = {};
|
|
2309
|
+
__export(Assertions_exports5, {
|
|
1487
2310
|
componentsValidator: () => componentsValidator,
|
|
1488
2311
|
titleValidator: () => titleValidator,
|
|
1489
2312
|
validateRequiredParameters: () => validateRequiredParameters2
|
|
1490
2313
|
});
|
|
1491
|
-
var
|
|
1492
|
-
var titleValidator =
|
|
1493
|
-
var componentsValidator =
|
|
2314
|
+
var import_shapeshift5 = require("@sapphire/shapeshift");
|
|
2315
|
+
var titleValidator = import_shapeshift5.s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
|
2316
|
+
var componentsValidator = import_shapeshift5.s.instance(ActionRowBuilder).array().lengthGreaterThanOrEqual(1).setValidationEnabled(isValidationEnabled);
|
|
1494
2317
|
function validateRequiredParameters2(customId, title, components) {
|
|
1495
2318
|
customIdValidator.parse(customId);
|
|
1496
2319
|
titleValidator.parse(title);
|
|
@@ -1573,9 +2396,9 @@ var ModalBuilder = class {
|
|
|
1573
2396
|
};
|
|
1574
2397
|
|
|
1575
2398
|
// src/interactions/slashCommands/Assertions.ts
|
|
1576
|
-
var
|
|
1577
|
-
__export(
|
|
1578
|
-
assertReturnOfBuilder: () =>
|
|
2399
|
+
var Assertions_exports6 = {};
|
|
2400
|
+
__export(Assertions_exports6, {
|
|
2401
|
+
assertReturnOfBuilder: () => assertReturnOfBuilder2,
|
|
1579
2402
|
contextsPredicate: () => contextsPredicate,
|
|
1580
2403
|
integrationTypesPredicate: () => integrationTypesPredicate,
|
|
1581
2404
|
localizationMapPredicate: () => localizationMapPredicate,
|
|
@@ -1592,20 +2415,20 @@ __export(Assertions_exports5, {
|
|
|
1592
2415
|
validateRequired: () => validateRequired,
|
|
1593
2416
|
validateRequiredParameters: () => validateRequiredParameters3
|
|
1594
2417
|
});
|
|
1595
|
-
var
|
|
1596
|
-
var
|
|
1597
|
-
var namePredicate =
|
|
2418
|
+
var import_shapeshift6 = require("@sapphire/shapeshift");
|
|
2419
|
+
var import_v1020 = require("discord-api-types/v10");
|
|
2420
|
+
var namePredicate = import_shapeshift6.s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u).setValidationEnabled(isValidationEnabled);
|
|
1598
2421
|
function validateName(name) {
|
|
1599
2422
|
namePredicate.parse(name);
|
|
1600
2423
|
}
|
|
1601
2424
|
__name(validateName, "validateName");
|
|
1602
|
-
var
|
|
1603
|
-
var localePredicate =
|
|
2425
|
+
var descriptionPredicate3 = import_shapeshift6.s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
2426
|
+
var localePredicate = import_shapeshift6.s.nativeEnum(import_v1020.Locale);
|
|
1604
2427
|
function validateDescription(description) {
|
|
1605
|
-
|
|
2428
|
+
descriptionPredicate3.parse(description);
|
|
1606
2429
|
}
|
|
1607
2430
|
__name(validateDescription, "validateDescription");
|
|
1608
|
-
var maxArrayLengthPredicate =
|
|
2431
|
+
var maxArrayLengthPredicate = import_shapeshift6.s.unknown().array().lengthLessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
|
1609
2432
|
function validateLocale(locale) {
|
|
1610
2433
|
return localePredicate.parse(locale);
|
|
1611
2434
|
}
|
|
@@ -1620,7 +2443,7 @@ function validateRequiredParameters3(name, description, options) {
|
|
|
1620
2443
|
validateMaxOptionsLength(options);
|
|
1621
2444
|
}
|
|
1622
2445
|
__name(validateRequiredParameters3, "validateRequiredParameters");
|
|
1623
|
-
var booleanPredicate =
|
|
2446
|
+
var booleanPredicate = import_shapeshift6.s.boolean();
|
|
1624
2447
|
function validateDefaultPermission(value) {
|
|
1625
2448
|
booleanPredicate.parse(value);
|
|
1626
2449
|
}
|
|
@@ -1629,29 +2452,29 @@ function validateRequired(required) {
|
|
|
1629
2452
|
booleanPredicate.parse(required);
|
|
1630
2453
|
}
|
|
1631
2454
|
__name(validateRequired, "validateRequired");
|
|
1632
|
-
var choicesLengthPredicate =
|
|
2455
|
+
var choicesLengthPredicate = import_shapeshift6.s.number().lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
|
1633
2456
|
function validateChoicesLength(amountAdding, choices) {
|
|
1634
2457
|
choicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);
|
|
1635
2458
|
}
|
|
1636
2459
|
__name(validateChoicesLength, "validateChoicesLength");
|
|
1637
|
-
function
|
|
1638
|
-
|
|
2460
|
+
function assertReturnOfBuilder2(input, ExpectedInstanceOf) {
|
|
2461
|
+
import_shapeshift6.s.instance(ExpectedInstanceOf).parse(input);
|
|
1639
2462
|
}
|
|
1640
|
-
__name(
|
|
1641
|
-
var localizationMapPredicate =
|
|
2463
|
+
__name(assertReturnOfBuilder2, "assertReturnOfBuilder");
|
|
2464
|
+
var localizationMapPredicate = import_shapeshift6.s.object(Object.fromEntries(Object.values(import_v1020.Locale).map((locale) => [locale, import_shapeshift6.s.string().nullish()]))).strict().nullish().setValidationEnabled(isValidationEnabled);
|
|
1642
2465
|
function validateLocalizationMap(value) {
|
|
1643
2466
|
localizationMapPredicate.parse(value);
|
|
1644
2467
|
}
|
|
1645
2468
|
__name(validateLocalizationMap, "validateLocalizationMap");
|
|
1646
|
-
var dmPermissionPredicate =
|
|
2469
|
+
var dmPermissionPredicate = import_shapeshift6.s.boolean().nullish();
|
|
1647
2470
|
function validateDMPermission(value) {
|
|
1648
2471
|
dmPermissionPredicate.parse(value);
|
|
1649
2472
|
}
|
|
1650
2473
|
__name(validateDMPermission, "validateDMPermission");
|
|
1651
|
-
var memberPermissionPredicate =
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
2474
|
+
var memberPermissionPredicate = import_shapeshift6.s.union([
|
|
2475
|
+
import_shapeshift6.s.bigint().transform((value) => value.toString()),
|
|
2476
|
+
import_shapeshift6.s.number().safeInt().transform((value) => value.toString()),
|
|
2477
|
+
import_shapeshift6.s.string().regex(/^\d+$/)
|
|
1655
2478
|
]).nullish();
|
|
1656
2479
|
function validateDefaultMemberPermissions(permissions) {
|
|
1657
2480
|
return memberPermissionPredicate.parse(permissions);
|
|
@@ -1661,11 +2484,11 @@ function validateNSFW(value) {
|
|
|
1661
2484
|
booleanPredicate.parse(value);
|
|
1662
2485
|
}
|
|
1663
2486
|
__name(validateNSFW, "validateNSFW");
|
|
1664
|
-
var contextsPredicate =
|
|
1665
|
-
|
|
2487
|
+
var contextsPredicate = import_shapeshift6.s.array(
|
|
2488
|
+
import_shapeshift6.s.nativeEnum(import_v1020.InteractionContextType).setValidationEnabled(isValidationEnabled)
|
|
1666
2489
|
);
|
|
1667
|
-
var integrationTypesPredicate =
|
|
1668
|
-
|
|
2490
|
+
var integrationTypesPredicate = import_shapeshift6.s.array(
|
|
2491
|
+
import_shapeshift6.s.nativeEnum(import_v1020.ApplicationIntegrationType).setValidationEnabled(isValidationEnabled)
|
|
1669
2492
|
);
|
|
1670
2493
|
|
|
1671
2494
|
// src/interactions/slashCommands/SlashCommandBuilder.ts
|
|
@@ -1785,7 +2608,7 @@ var SharedNameAndDescription = class {
|
|
|
1785
2608
|
};
|
|
1786
2609
|
|
|
1787
2610
|
// src/interactions/slashCommands/mixins/SharedSlashCommand.ts
|
|
1788
|
-
var
|
|
2611
|
+
var import_v1021 = require("discord-api-types/v10");
|
|
1789
2612
|
var SharedSlashCommand = class {
|
|
1790
2613
|
static {
|
|
1791
2614
|
__name(this, "SharedSlashCommand");
|
|
@@ -1890,14 +2713,14 @@ var SharedSlashCommand = class {
|
|
|
1890
2713
|
validateLocalizationMap(this.description_localizations);
|
|
1891
2714
|
return {
|
|
1892
2715
|
...this,
|
|
1893
|
-
type:
|
|
2716
|
+
type: import_v1021.ApplicationCommandType.ChatInput,
|
|
1894
2717
|
options: this.options.map((option) => option.toJSON())
|
|
1895
2718
|
};
|
|
1896
2719
|
}
|
|
1897
2720
|
};
|
|
1898
2721
|
|
|
1899
2722
|
// src/interactions/slashCommands/options/attachment.ts
|
|
1900
|
-
var
|
|
2723
|
+
var import_v1022 = require("discord-api-types/v10");
|
|
1901
2724
|
|
|
1902
2725
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
|
|
1903
2726
|
var ApplicationCommandOptionBase = class extends SharedNameAndDescription {
|
|
@@ -1939,7 +2762,7 @@ var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase {
|
|
|
1939
2762
|
/**
|
|
1940
2763
|
* The type of this option.
|
|
1941
2764
|
*/
|
|
1942
|
-
type =
|
|
2765
|
+
type = import_v1022.ApplicationCommandOptionType.Attachment;
|
|
1943
2766
|
/**
|
|
1944
2767
|
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
|
1945
2768
|
*/
|
|
@@ -1950,7 +2773,7 @@ var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase {
|
|
|
1950
2773
|
};
|
|
1951
2774
|
|
|
1952
2775
|
// src/interactions/slashCommands/options/boolean.ts
|
|
1953
|
-
var
|
|
2776
|
+
var import_v1023 = require("discord-api-types/v10");
|
|
1954
2777
|
var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
|
|
1955
2778
|
static {
|
|
1956
2779
|
__name(this, "SlashCommandBooleanOption");
|
|
@@ -1958,7 +2781,7 @@ var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
|
|
|
1958
2781
|
/**
|
|
1959
2782
|
* The type of this option.
|
|
1960
2783
|
*/
|
|
1961
|
-
type =
|
|
2784
|
+
type = import_v1023.ApplicationCommandOptionType.Boolean;
|
|
1962
2785
|
/**
|
|
1963
2786
|
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
|
1964
2787
|
*/
|
|
@@ -1969,25 +2792,25 @@ var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
|
|
|
1969
2792
|
};
|
|
1970
2793
|
|
|
1971
2794
|
// src/interactions/slashCommands/options/channel.ts
|
|
1972
|
-
var
|
|
2795
|
+
var import_v1025 = require("discord-api-types/v10");
|
|
1973
2796
|
var import_ts_mixer = require("ts-mixer");
|
|
1974
2797
|
|
|
1975
2798
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
|
|
1976
|
-
var
|
|
1977
|
-
var
|
|
2799
|
+
var import_shapeshift7 = require("@sapphire/shapeshift");
|
|
2800
|
+
var import_v1024 = require("discord-api-types/v10");
|
|
1978
2801
|
var allowedChannelTypes = [
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
2802
|
+
import_v1024.ChannelType.GuildText,
|
|
2803
|
+
import_v1024.ChannelType.GuildVoice,
|
|
2804
|
+
import_v1024.ChannelType.GuildCategory,
|
|
2805
|
+
import_v1024.ChannelType.GuildAnnouncement,
|
|
2806
|
+
import_v1024.ChannelType.AnnouncementThread,
|
|
2807
|
+
import_v1024.ChannelType.PublicThread,
|
|
2808
|
+
import_v1024.ChannelType.PrivateThread,
|
|
2809
|
+
import_v1024.ChannelType.GuildStageVoice,
|
|
2810
|
+
import_v1024.ChannelType.GuildForum,
|
|
2811
|
+
import_v1024.ChannelType.GuildMedia
|
|
1989
2812
|
];
|
|
1990
|
-
var channelTypesPredicate =
|
|
2813
|
+
var channelTypesPredicate = import_shapeshift7.s.array(import_shapeshift7.s.union(allowedChannelTypes.map((type) => import_shapeshift7.s.literal(type))));
|
|
1991
2814
|
var ApplicationCommandOptionChannelTypesMixin = class {
|
|
1992
2815
|
static {
|
|
1993
2816
|
__name(this, "ApplicationCommandOptionChannelTypesMixin");
|
|
@@ -2015,7 +2838,7 @@ var SlashCommandChannelOption = class extends ApplicationCommandOptionBase {
|
|
|
2015
2838
|
/**
|
|
2016
2839
|
* The type of this option.
|
|
2017
2840
|
*/
|
|
2018
|
-
type =
|
|
2841
|
+
type = import_v1025.ApplicationCommandOptionType.Channel;
|
|
2019
2842
|
/**
|
|
2020
2843
|
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
|
2021
2844
|
*/
|
|
@@ -2030,8 +2853,8 @@ SlashCommandChannelOption = __decorateClass([
|
|
|
2030
2853
|
], SlashCommandChannelOption);
|
|
2031
2854
|
|
|
2032
2855
|
// src/interactions/slashCommands/options/integer.ts
|
|
2033
|
-
var
|
|
2034
|
-
var
|
|
2856
|
+
var import_shapeshift10 = require("@sapphire/shapeshift");
|
|
2857
|
+
var import_v1027 = require("discord-api-types/v10");
|
|
2035
2858
|
var import_ts_mixer2 = require("ts-mixer");
|
|
2036
2859
|
|
|
2037
2860
|
// src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
|
|
@@ -2050,8 +2873,8 @@ var ApplicationCommandNumericOptionMinMaxValueMixin = class {
|
|
|
2050
2873
|
};
|
|
2051
2874
|
|
|
2052
2875
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithAutocompleteMixin.ts
|
|
2053
|
-
var
|
|
2054
|
-
var booleanPredicate2 =
|
|
2876
|
+
var import_shapeshift8 = require("@sapphire/shapeshift");
|
|
2877
|
+
var booleanPredicate2 = import_shapeshift8.s.boolean();
|
|
2055
2878
|
var ApplicationCommandOptionWithAutocompleteMixin = class {
|
|
2056
2879
|
static {
|
|
2057
2880
|
__name(this, "ApplicationCommandOptionWithAutocompleteMixin");
|
|
@@ -2082,14 +2905,14 @@ var ApplicationCommandOptionWithAutocompleteMixin = class {
|
|
|
2082
2905
|
};
|
|
2083
2906
|
|
|
2084
2907
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesMixin.ts
|
|
2085
|
-
var
|
|
2086
|
-
var
|
|
2087
|
-
var stringPredicate =
|
|
2088
|
-
var numberPredicate =
|
|
2089
|
-
var choicesPredicate =
|
|
2908
|
+
var import_shapeshift9 = require("@sapphire/shapeshift");
|
|
2909
|
+
var import_v1026 = require("discord-api-types/v10");
|
|
2910
|
+
var stringPredicate = import_shapeshift9.s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100);
|
|
2911
|
+
var numberPredicate = import_shapeshift9.s.number().greaterThan(Number.NEGATIVE_INFINITY).lessThan(Number.POSITIVE_INFINITY);
|
|
2912
|
+
var choicesPredicate = import_shapeshift9.s.object({
|
|
2090
2913
|
name: stringPredicate,
|
|
2091
2914
|
name_localizations: localizationMapPredicate,
|
|
2092
|
-
value:
|
|
2915
|
+
value: import_shapeshift9.s.union([stringPredicate, numberPredicate])
|
|
2093
2916
|
}).array();
|
|
2094
2917
|
var ApplicationCommandOptionWithChoicesMixin = class {
|
|
2095
2918
|
static {
|
|
@@ -2121,7 +2944,7 @@ var ApplicationCommandOptionWithChoicesMixin = class {
|
|
|
2121
2944
|
}
|
|
2122
2945
|
validateChoicesLength(normalizedChoices.length, this.choices);
|
|
2123
2946
|
for (const { name, name_localizations, value } of normalizedChoices) {
|
|
2124
|
-
if (this.type ===
|
|
2947
|
+
if (this.type === import_v1026.ApplicationCommandOptionType.String) {
|
|
2125
2948
|
stringPredicate.parse(value);
|
|
2126
2949
|
} else {
|
|
2127
2950
|
numberPredicate.parse(value);
|
|
@@ -2148,12 +2971,12 @@ var ApplicationCommandOptionWithChoicesMixin = class {
|
|
|
2148
2971
|
};
|
|
2149
2972
|
|
|
2150
2973
|
// src/interactions/slashCommands/options/integer.ts
|
|
2151
|
-
var numberValidator =
|
|
2974
|
+
var numberValidator = import_shapeshift10.s.number().int();
|
|
2152
2975
|
var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase {
|
|
2153
2976
|
/**
|
|
2154
2977
|
* The type of this option.
|
|
2155
2978
|
*/
|
|
2156
|
-
type =
|
|
2979
|
+
type = import_v1027.ApplicationCommandOptionType.Integer;
|
|
2157
2980
|
/**
|
|
2158
2981
|
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
|
2159
2982
|
*/
|
|
@@ -2191,7 +3014,7 @@ SlashCommandIntegerOption = __decorateClass([
|
|
|
2191
3014
|
], SlashCommandIntegerOption);
|
|
2192
3015
|
|
|
2193
3016
|
// src/interactions/slashCommands/options/mentionable.ts
|
|
2194
|
-
var
|
|
3017
|
+
var import_v1028 = require("discord-api-types/v10");
|
|
2195
3018
|
var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
|
|
2196
3019
|
static {
|
|
2197
3020
|
__name(this, "SlashCommandMentionableOption");
|
|
@@ -2199,7 +3022,7 @@ var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
|
|
|
2199
3022
|
/**
|
|
2200
3023
|
* The type of this option.
|
|
2201
3024
|
*/
|
|
2202
|
-
type =
|
|
3025
|
+
type = import_v1028.ApplicationCommandOptionType.Mentionable;
|
|
2203
3026
|
/**
|
|
2204
3027
|
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
|
2205
3028
|
*/
|
|
@@ -2210,15 +3033,15 @@ var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
|
|
|
2210
3033
|
};
|
|
2211
3034
|
|
|
2212
3035
|
// src/interactions/slashCommands/options/number.ts
|
|
2213
|
-
var
|
|
2214
|
-
var
|
|
3036
|
+
var import_shapeshift11 = require("@sapphire/shapeshift");
|
|
3037
|
+
var import_v1029 = require("discord-api-types/v10");
|
|
2215
3038
|
var import_ts_mixer3 = require("ts-mixer");
|
|
2216
|
-
var numberValidator2 =
|
|
3039
|
+
var numberValidator2 = import_shapeshift11.s.number();
|
|
2217
3040
|
var SlashCommandNumberOption = class extends ApplicationCommandOptionBase {
|
|
2218
3041
|
/**
|
|
2219
3042
|
* The type of this option.
|
|
2220
3043
|
*/
|
|
2221
|
-
type =
|
|
3044
|
+
type = import_v1029.ApplicationCommandOptionType.Number;
|
|
2222
3045
|
/**
|
|
2223
3046
|
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
|
2224
3047
|
*/
|
|
@@ -2256,7 +3079,7 @@ SlashCommandNumberOption = __decorateClass([
|
|
|
2256
3079
|
], SlashCommandNumberOption);
|
|
2257
3080
|
|
|
2258
3081
|
// src/interactions/slashCommands/options/role.ts
|
|
2259
|
-
var
|
|
3082
|
+
var import_v1030 = require("discord-api-types/v10");
|
|
2260
3083
|
var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
|
|
2261
3084
|
static {
|
|
2262
3085
|
__name(this, "SlashCommandRoleOption");
|
|
@@ -2264,7 +3087,7 @@ var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
|
|
|
2264
3087
|
/**
|
|
2265
3088
|
* The type of this option.
|
|
2266
3089
|
*/
|
|
2267
|
-
type =
|
|
3090
|
+
type = import_v1030.ApplicationCommandOptionType.Role;
|
|
2268
3091
|
/**
|
|
2269
3092
|
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
|
2270
3093
|
*/
|
|
@@ -2275,16 +3098,16 @@ var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
|
|
|
2275
3098
|
};
|
|
2276
3099
|
|
|
2277
3100
|
// src/interactions/slashCommands/options/string.ts
|
|
2278
|
-
var
|
|
2279
|
-
var
|
|
3101
|
+
var import_shapeshift12 = require("@sapphire/shapeshift");
|
|
3102
|
+
var import_v1031 = require("discord-api-types/v10");
|
|
2280
3103
|
var import_ts_mixer4 = require("ts-mixer");
|
|
2281
|
-
var minLengthValidator2 =
|
|
2282
|
-
var maxLengthValidator2 =
|
|
3104
|
+
var minLengthValidator2 = import_shapeshift12.s.number().greaterThanOrEqual(0).lessThanOrEqual(6e3);
|
|
3105
|
+
var maxLengthValidator2 = import_shapeshift12.s.number().greaterThanOrEqual(1).lessThanOrEqual(6e3);
|
|
2283
3106
|
var SlashCommandStringOption = class extends ApplicationCommandOptionBase {
|
|
2284
3107
|
/**
|
|
2285
3108
|
* The type of this option.
|
|
2286
3109
|
*/
|
|
2287
|
-
type =
|
|
3110
|
+
type = import_v1031.ApplicationCommandOptionType.String;
|
|
2288
3111
|
/**
|
|
2289
3112
|
* The maximum length of this option.
|
|
2290
3113
|
*/
|
|
@@ -2330,7 +3153,7 @@ SlashCommandStringOption = __decorateClass([
|
|
|
2330
3153
|
], SlashCommandStringOption);
|
|
2331
3154
|
|
|
2332
3155
|
// src/interactions/slashCommands/options/user.ts
|
|
2333
|
-
var
|
|
3156
|
+
var import_v1032 = require("discord-api-types/v10");
|
|
2334
3157
|
var SlashCommandUserOption = class extends ApplicationCommandOptionBase {
|
|
2335
3158
|
static {
|
|
2336
3159
|
__name(this, "SlashCommandUserOption");
|
|
@@ -2338,7 +3161,7 @@ var SlashCommandUserOption = class extends ApplicationCommandOptionBase {
|
|
|
2338
3161
|
/**
|
|
2339
3162
|
* The type of this option.
|
|
2340
3163
|
*/
|
|
2341
|
-
type =
|
|
3164
|
+
type = import_v1032.ApplicationCommandOptionType.User;
|
|
2342
3165
|
/**
|
|
2343
3166
|
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
|
2344
3167
|
*/
|
|
@@ -2437,14 +3260,14 @@ var SharedSlashCommandOptions = class {
|
|
|
2437
3260
|
const { options } = this;
|
|
2438
3261
|
validateMaxOptionsLength(options);
|
|
2439
3262
|
const result = typeof input === "function" ? input(new Instance()) : input;
|
|
2440
|
-
|
|
3263
|
+
assertReturnOfBuilder2(result, Instance);
|
|
2441
3264
|
options.push(result);
|
|
2442
3265
|
return this;
|
|
2443
3266
|
}
|
|
2444
3267
|
};
|
|
2445
3268
|
|
|
2446
3269
|
// src/interactions/slashCommands/SlashCommandSubcommands.ts
|
|
2447
|
-
var
|
|
3270
|
+
var import_v1033 = require("discord-api-types/v10");
|
|
2448
3271
|
var import_ts_mixer5 = require("ts-mixer");
|
|
2449
3272
|
var SlashCommandSubcommandGroupBuilder = class {
|
|
2450
3273
|
/**
|
|
@@ -2468,7 +3291,7 @@ var SlashCommandSubcommandGroupBuilder = class {
|
|
|
2468
3291
|
const { options } = this;
|
|
2469
3292
|
validateMaxOptionsLength(options);
|
|
2470
3293
|
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input;
|
|
2471
|
-
|
|
3294
|
+
assertReturnOfBuilder2(result, SlashCommandSubcommandBuilder);
|
|
2472
3295
|
options.push(result);
|
|
2473
3296
|
return this;
|
|
2474
3297
|
}
|
|
@@ -2482,7 +3305,7 @@ var SlashCommandSubcommandGroupBuilder = class {
|
|
|
2482
3305
|
toJSON() {
|
|
2483
3306
|
validateRequiredParameters3(this.name, this.description, this.options);
|
|
2484
3307
|
return {
|
|
2485
|
-
type:
|
|
3308
|
+
type: import_v1033.ApplicationCommandOptionType.SubcommandGroup,
|
|
2486
3309
|
name: this.name,
|
|
2487
3310
|
name_localizations: this.name_localizations,
|
|
2488
3311
|
description: this.description,
|
|
@@ -2518,7 +3341,7 @@ var SlashCommandSubcommandBuilder = class {
|
|
|
2518
3341
|
toJSON() {
|
|
2519
3342
|
validateRequiredParameters3(this.name, this.description, this.options);
|
|
2520
3343
|
return {
|
|
2521
|
-
type:
|
|
3344
|
+
type: import_v1033.ApplicationCommandOptionType.Subcommand,
|
|
2522
3345
|
name: this.name,
|
|
2523
3346
|
name_localizations: this.name_localizations,
|
|
2524
3347
|
description: this.description,
|
|
@@ -2547,7 +3370,7 @@ var SharedSlashCommandSubcommands = class {
|
|
|
2547
3370
|
const { options } = this;
|
|
2548
3371
|
validateMaxOptionsLength(options);
|
|
2549
3372
|
const result = typeof input === "function" ? input(new SlashCommandSubcommandGroupBuilder()) : input;
|
|
2550
|
-
|
|
3373
|
+
assertReturnOfBuilder2(result, SlashCommandSubcommandGroupBuilder);
|
|
2551
3374
|
options.push(result);
|
|
2552
3375
|
return this;
|
|
2553
3376
|
}
|
|
@@ -2560,7 +3383,7 @@ var SharedSlashCommandSubcommands = class {
|
|
|
2560
3383
|
const { options } = this;
|
|
2561
3384
|
validateMaxOptionsLength(options);
|
|
2562
3385
|
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input;
|
|
2563
|
-
|
|
3386
|
+
assertReturnOfBuilder2(result, SlashCommandSubcommandBuilder);
|
|
2564
3387
|
options.push(result);
|
|
2565
3388
|
return this;
|
|
2566
3389
|
}
|
|
@@ -2626,8 +3449,8 @@ SlashCommandBuilder = __decorateClass([
|
|
|
2626
3449
|
], SlashCommandBuilder);
|
|
2627
3450
|
|
|
2628
3451
|
// src/interactions/contextMenuCommands/Assertions.ts
|
|
2629
|
-
var
|
|
2630
|
-
__export(
|
|
3452
|
+
var Assertions_exports7 = {};
|
|
3453
|
+
__export(Assertions_exports7, {
|
|
2631
3454
|
contextsPredicate: () => contextsPredicate2,
|
|
2632
3455
|
integrationTypesPredicate: () => integrationTypesPredicate2,
|
|
2633
3456
|
validateDMPermission: () => validateDMPermission2,
|
|
@@ -2637,11 +3460,11 @@ __export(Assertions_exports6, {
|
|
|
2637
3460
|
validateRequiredParameters: () => validateRequiredParameters4,
|
|
2638
3461
|
validateType: () => validateType
|
|
2639
3462
|
});
|
|
2640
|
-
var
|
|
2641
|
-
var
|
|
2642
|
-
var namePredicate2 =
|
|
2643
|
-
var typePredicate =
|
|
2644
|
-
var booleanPredicate3 =
|
|
3463
|
+
var import_shapeshift13 = require("@sapphire/shapeshift");
|
|
3464
|
+
var import_v1034 = require("discord-api-types/v10");
|
|
3465
|
+
var namePredicate2 = import_shapeshift13.s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^( *[\p{P}\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}]+ *)+$/u).setValidationEnabled(isValidationEnabled);
|
|
3466
|
+
var typePredicate = import_shapeshift13.s.union([import_shapeshift13.s.literal(import_v1034.ApplicationCommandType.User), import_shapeshift13.s.literal(import_v1034.ApplicationCommandType.Message)]).setValidationEnabled(isValidationEnabled);
|
|
3467
|
+
var booleanPredicate3 = import_shapeshift13.s.boolean();
|
|
2645
3468
|
function validateDefaultPermission2(value) {
|
|
2646
3469
|
booleanPredicate3.parse(value);
|
|
2647
3470
|
}
|
|
@@ -2659,25 +3482,25 @@ function validateRequiredParameters4(name, type) {
|
|
|
2659
3482
|
validateType(type);
|
|
2660
3483
|
}
|
|
2661
3484
|
__name(validateRequiredParameters4, "validateRequiredParameters");
|
|
2662
|
-
var dmPermissionPredicate2 =
|
|
3485
|
+
var dmPermissionPredicate2 = import_shapeshift13.s.boolean().nullish();
|
|
2663
3486
|
function validateDMPermission2(value) {
|
|
2664
3487
|
dmPermissionPredicate2.parse(value);
|
|
2665
3488
|
}
|
|
2666
3489
|
__name(validateDMPermission2, "validateDMPermission");
|
|
2667
|
-
var memberPermissionPredicate2 =
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
3490
|
+
var memberPermissionPredicate2 = import_shapeshift13.s.union([
|
|
3491
|
+
import_shapeshift13.s.bigint().transform((value) => value.toString()),
|
|
3492
|
+
import_shapeshift13.s.number().safeInt().transform((value) => value.toString()),
|
|
3493
|
+
import_shapeshift13.s.string().regex(/^\d+$/)
|
|
2671
3494
|
]).nullish();
|
|
2672
3495
|
function validateDefaultMemberPermissions2(permissions) {
|
|
2673
3496
|
return memberPermissionPredicate2.parse(permissions);
|
|
2674
3497
|
}
|
|
2675
3498
|
__name(validateDefaultMemberPermissions2, "validateDefaultMemberPermissions");
|
|
2676
|
-
var contextsPredicate2 =
|
|
2677
|
-
|
|
3499
|
+
var contextsPredicate2 = import_shapeshift13.s.array(
|
|
3500
|
+
import_shapeshift13.s.nativeEnum(import_v1034.InteractionContextType).setValidationEnabled(isValidationEnabled)
|
|
2678
3501
|
);
|
|
2679
|
-
var integrationTypesPredicate2 =
|
|
2680
|
-
|
|
3502
|
+
var integrationTypesPredicate2 = import_shapeshift13.s.array(
|
|
3503
|
+
import_shapeshift13.s.nativeEnum(import_v1034.ApplicationIntegrationType).setValidationEnabled(isValidationEnabled)
|
|
2681
3504
|
);
|
|
2682
3505
|
|
|
2683
3506
|
// src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
|
|
@@ -2858,7 +3681,7 @@ function embedLength(data) {
|
|
|
2858
3681
|
__name(embedLength, "embedLength");
|
|
2859
3682
|
|
|
2860
3683
|
// src/index.ts
|
|
2861
|
-
var version = "1.
|
|
3684
|
+
var version = "1.11.1";
|
|
2862
3685
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2863
3686
|
0 && (module.exports = {
|
|
2864
3687
|
ActionRowBuilder,
|
|
@@ -2872,16 +3695,23 @@ var version = "1.10.1";
|
|
|
2872
3695
|
ChannelSelectMenuBuilder,
|
|
2873
3696
|
ComponentAssertions,
|
|
2874
3697
|
ComponentBuilder,
|
|
3698
|
+
ComponentsV2Assertions,
|
|
3699
|
+
ContainerBuilder,
|
|
2875
3700
|
ContextMenuCommandAssertions,
|
|
2876
3701
|
ContextMenuCommandBuilder,
|
|
2877
3702
|
EmbedAssertions,
|
|
2878
3703
|
EmbedBuilder,
|
|
3704
|
+
FileBuilder,
|
|
3705
|
+
MediaGalleryBuilder,
|
|
3706
|
+
MediaGalleryItemBuilder,
|
|
2879
3707
|
MentionableSelectMenuBuilder,
|
|
2880
3708
|
ModalAssertions,
|
|
2881
3709
|
ModalBuilder,
|
|
2882
3710
|
RoleSelectMenuBuilder,
|
|
3711
|
+
SectionBuilder,
|
|
2883
3712
|
SelectMenuBuilder,
|
|
2884
3713
|
SelectMenuOptionBuilder,
|
|
3714
|
+
SeparatorBuilder,
|
|
2885
3715
|
SharedNameAndDescription,
|
|
2886
3716
|
SharedSlashCommand,
|
|
2887
3717
|
SharedSlashCommandOptions,
|
|
@@ -2901,8 +3731,10 @@ var version = "1.10.1";
|
|
|
2901
3731
|
SlashCommandUserOption,
|
|
2902
3732
|
StringSelectMenuBuilder,
|
|
2903
3733
|
StringSelectMenuOptionBuilder,
|
|
3734
|
+
TextDisplayBuilder,
|
|
2904
3735
|
TextInputAssertions,
|
|
2905
3736
|
TextInputBuilder,
|
|
3737
|
+
ThumbnailBuilder,
|
|
2906
3738
|
UserSelectMenuBuilder,
|
|
2907
3739
|
createComponentBuilder,
|
|
2908
3740
|
disableValidators,
|
|
@@ -2910,6 +3742,7 @@ var version = "1.10.1";
|
|
|
2910
3742
|
enableValidators,
|
|
2911
3743
|
isValidationEnabled,
|
|
2912
3744
|
normalizeArray,
|
|
3745
|
+
resolveBuilder,
|
|
2913
3746
|
version,
|
|
2914
3747
|
...require("@discordjs/formatters")
|
|
2915
3748
|
});
|