@discordjs/builders 1.11.3 → 1.12.0
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 +338 -63
- package/dist/index.d.ts +338 -63
- package/dist/index.js +530 -200
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +495 -167
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -498,7 +498,7 @@ __name(validateRequiredButtonParameters, "validateRequiredButtonParameters");
|
|
|
498
498
|
|
|
499
499
|
// src/components/ActionRow.ts
|
|
500
500
|
import {
|
|
501
|
-
ComponentType as
|
|
501
|
+
ComponentType as ComponentType20
|
|
502
502
|
} from "discord-api-types/v10";
|
|
503
503
|
|
|
504
504
|
// src/components/Component.ts
|
|
@@ -537,7 +537,7 @@ var ComponentBuilder = class {
|
|
|
537
537
|
};
|
|
538
538
|
|
|
539
539
|
// src/components/Components.ts
|
|
540
|
-
import { ComponentType as
|
|
540
|
+
import { ComponentType as ComponentType19 } from "discord-api-types/v10";
|
|
541
541
|
|
|
542
542
|
// src/components/button/Button.ts
|
|
543
543
|
import {
|
|
@@ -665,12 +665,54 @@ var ButtonBuilder = class extends ComponentBuilder {
|
|
|
665
665
|
}
|
|
666
666
|
};
|
|
667
667
|
|
|
668
|
+
// src/components/label/Label.ts
|
|
669
|
+
import { ComponentType as ComponentType11 } from "discord-api-types/v10";
|
|
670
|
+
|
|
668
671
|
// src/components/selectMenu/ChannelSelectMenu.ts
|
|
669
672
|
import {
|
|
670
|
-
ComponentType as
|
|
673
|
+
ComponentType as ComponentType3,
|
|
671
674
|
SelectMenuDefaultValueType
|
|
672
675
|
} from "discord-api-types/v10";
|
|
673
676
|
|
|
677
|
+
// src/components/textInput/Assertions.ts
|
|
678
|
+
var Assertions_exports3 = {};
|
|
679
|
+
__export(Assertions_exports3, {
|
|
680
|
+
labelValidator: () => labelValidator,
|
|
681
|
+
maxLengthValidator: () => maxLengthValidator,
|
|
682
|
+
minLengthValidator: () => minLengthValidator,
|
|
683
|
+
placeholderValidator: () => placeholderValidator2,
|
|
684
|
+
requiredValidator: () => requiredValidator,
|
|
685
|
+
textInputPredicate: () => textInputPredicate,
|
|
686
|
+
textInputStyleValidator: () => textInputStyleValidator,
|
|
687
|
+
validateRequiredParameters: () => validateRequiredParameters,
|
|
688
|
+
valueValidator: () => valueValidator
|
|
689
|
+
});
|
|
690
|
+
import { s as s3 } from "@sapphire/shapeshift";
|
|
691
|
+
import { ComponentType as ComponentType2, TextInputStyle } from "discord-api-types/v10";
|
|
692
|
+
var textInputStyleValidator = s3.nativeEnum(TextInputStyle).setValidationEnabled(isValidationEnabled);
|
|
693
|
+
var minLengthValidator = s3.number().int().greaterThanOrEqual(0).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
694
|
+
var maxLengthValidator = s3.number().int().greaterThanOrEqual(1).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
695
|
+
var requiredValidator = s3.boolean().setValidationEnabled(isValidationEnabled);
|
|
696
|
+
var valueValidator = s3.string().lengthLessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
697
|
+
var placeholderValidator2 = s3.string().lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
698
|
+
var labelValidator = s3.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
|
699
|
+
var textInputPredicate = s3.object({
|
|
700
|
+
type: s3.literal(ComponentType2.TextInput),
|
|
701
|
+
custom_id: customIdValidator,
|
|
702
|
+
style: textInputStyleValidator,
|
|
703
|
+
id: idValidator.optional(),
|
|
704
|
+
min_length: minLengthValidator.optional(),
|
|
705
|
+
max_length: maxLengthValidator.optional(),
|
|
706
|
+
placeholder: placeholderValidator2.optional(),
|
|
707
|
+
value: valueValidator.optional(),
|
|
708
|
+
required: requiredValidator.optional()
|
|
709
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
710
|
+
function validateRequiredParameters(customId, style) {
|
|
711
|
+
customIdValidator.parse(customId);
|
|
712
|
+
textInputStyleValidator.parse(style);
|
|
713
|
+
}
|
|
714
|
+
__name(validateRequiredParameters, "validateRequiredParameters");
|
|
715
|
+
|
|
674
716
|
// src/components/selectMenu/BaseSelectMenu.ts
|
|
675
717
|
var BaseSelectMenuBuilder = class extends ComponentBuilder {
|
|
676
718
|
static {
|
|
@@ -721,6 +763,16 @@ var BaseSelectMenuBuilder = class extends ComponentBuilder {
|
|
|
721
763
|
this.data.disabled = disabledValidator.parse(disabled);
|
|
722
764
|
return this;
|
|
723
765
|
}
|
|
766
|
+
/**
|
|
767
|
+
* Sets whether this select menu is required.
|
|
768
|
+
*
|
|
769
|
+
* @remarks Only for use in modals.
|
|
770
|
+
* @param required - Whether this select menu is required
|
|
771
|
+
*/
|
|
772
|
+
setRequired(required = true) {
|
|
773
|
+
this.data.required = requiredValidator.parse(required);
|
|
774
|
+
return this;
|
|
775
|
+
}
|
|
724
776
|
/**
|
|
725
777
|
* {@inheritDoc ComponentBuilder.toJSON}
|
|
726
778
|
*/
|
|
@@ -761,7 +813,7 @@ var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
761
813
|
* ```
|
|
762
814
|
*/
|
|
763
815
|
constructor(data) {
|
|
764
|
-
super({ ...data, type:
|
|
816
|
+
super({ ...data, type: ComponentType3.ChannelSelect });
|
|
765
817
|
}
|
|
766
818
|
/**
|
|
767
819
|
* Adds channel types to this select menu.
|
|
@@ -829,7 +881,7 @@ var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
829
881
|
|
|
830
882
|
// src/components/selectMenu/MentionableSelectMenu.ts
|
|
831
883
|
import {
|
|
832
|
-
ComponentType as
|
|
884
|
+
ComponentType as ComponentType4,
|
|
833
885
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType2
|
|
834
886
|
} from "discord-api-types/v10";
|
|
835
887
|
var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
@@ -859,7 +911,7 @@ var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
859
911
|
* ```
|
|
860
912
|
*/
|
|
861
913
|
constructor(data) {
|
|
862
|
-
super({ ...data, type:
|
|
914
|
+
super({ ...data, type: ComponentType4.MentionableSelect });
|
|
863
915
|
}
|
|
864
916
|
/**
|
|
865
917
|
* Adds default roles to this auto populated select menu.
|
|
@@ -922,7 +974,7 @@ var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
922
974
|
|
|
923
975
|
// src/components/selectMenu/RoleSelectMenu.ts
|
|
924
976
|
import {
|
|
925
|
-
ComponentType as
|
|
977
|
+
ComponentType as ComponentType5,
|
|
926
978
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType3
|
|
927
979
|
} from "discord-api-types/v10";
|
|
928
980
|
var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
@@ -952,7 +1004,7 @@ var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
952
1004
|
* ```
|
|
953
1005
|
*/
|
|
954
1006
|
constructor(data) {
|
|
955
|
-
super({ ...data, type:
|
|
1007
|
+
super({ ...data, type: ComponentType5.RoleSelect });
|
|
956
1008
|
}
|
|
957
1009
|
/**
|
|
958
1010
|
* Adds default roles to this auto populated select menu.
|
|
@@ -988,7 +1040,7 @@ var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
988
1040
|
};
|
|
989
1041
|
|
|
990
1042
|
// src/components/selectMenu/StringSelectMenu.ts
|
|
991
|
-
import { ComponentType as
|
|
1043
|
+
import { ComponentType as ComponentType6 } from "discord-api-types/v10";
|
|
992
1044
|
var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
993
1045
|
static {
|
|
994
1046
|
__name(this, "StringSelectMenuBuilder");
|
|
@@ -1030,7 +1082,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1030
1082
|
*/
|
|
1031
1083
|
constructor(data) {
|
|
1032
1084
|
const { options, ...initData } = data ?? {};
|
|
1033
|
-
super({ ...initData, type:
|
|
1085
|
+
super({ ...initData, type: ComponentType6.StringSelect });
|
|
1034
1086
|
this.options = options?.map((option) => new StringSelectMenuOptionBuilder(option)) ?? [];
|
|
1035
1087
|
}
|
|
1036
1088
|
/**
|
|
@@ -1111,7 +1163,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1111
1163
|
|
|
1112
1164
|
// src/components/selectMenu/UserSelectMenu.ts
|
|
1113
1165
|
import {
|
|
1114
|
-
ComponentType as
|
|
1166
|
+
ComponentType as ComponentType7,
|
|
1115
1167
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType4
|
|
1116
1168
|
} from "discord-api-types/v10";
|
|
1117
1169
|
var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
@@ -1141,7 +1193,7 @@ var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1141
1193
|
* ```
|
|
1142
1194
|
*/
|
|
1143
1195
|
constructor(data) {
|
|
1144
|
-
super({ ...data, type:
|
|
1196
|
+
super({ ...data, type: ComponentType7.UserSelect });
|
|
1145
1197
|
}
|
|
1146
1198
|
/**
|
|
1147
1199
|
* Adds default users to this auto populated select menu.
|
|
@@ -1178,38 +1230,8 @@ var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1178
1230
|
|
|
1179
1231
|
// src/components/textInput/TextInput.ts
|
|
1180
1232
|
import { isJSONEncodable } from "@discordjs/util";
|
|
1181
|
-
import { ComponentType as
|
|
1233
|
+
import { ComponentType as ComponentType8 } from "discord-api-types/v10";
|
|
1182
1234
|
import isEqual from "fast-deep-equal";
|
|
1183
|
-
|
|
1184
|
-
// src/components/textInput/Assertions.ts
|
|
1185
|
-
var Assertions_exports3 = {};
|
|
1186
|
-
__export(Assertions_exports3, {
|
|
1187
|
-
labelValidator: () => labelValidator,
|
|
1188
|
-
maxLengthValidator: () => maxLengthValidator,
|
|
1189
|
-
minLengthValidator: () => minLengthValidator,
|
|
1190
|
-
placeholderValidator: () => placeholderValidator2,
|
|
1191
|
-
requiredValidator: () => requiredValidator,
|
|
1192
|
-
textInputStyleValidator: () => textInputStyleValidator,
|
|
1193
|
-
validateRequiredParameters: () => validateRequiredParameters,
|
|
1194
|
-
valueValidator: () => valueValidator
|
|
1195
|
-
});
|
|
1196
|
-
import { s as s3 } from "@sapphire/shapeshift";
|
|
1197
|
-
import { TextInputStyle } from "discord-api-types/v10";
|
|
1198
|
-
var textInputStyleValidator = s3.nativeEnum(TextInputStyle);
|
|
1199
|
-
var minLengthValidator = s3.number().int().greaterThanOrEqual(0).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
1200
|
-
var maxLengthValidator = s3.number().int().greaterThanOrEqual(1).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
1201
|
-
var requiredValidator = s3.boolean();
|
|
1202
|
-
var valueValidator = s3.string().lengthLessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
1203
|
-
var placeholderValidator2 = s3.string().lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
1204
|
-
var labelValidator = s3.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
|
1205
|
-
function validateRequiredParameters(customId, style, label) {
|
|
1206
|
-
customIdValidator.parse(customId);
|
|
1207
|
-
textInputStyleValidator.parse(style);
|
|
1208
|
-
labelValidator.parse(label);
|
|
1209
|
-
}
|
|
1210
|
-
__name(validateRequiredParameters, "validateRequiredParameters");
|
|
1211
|
-
|
|
1212
|
-
// src/components/textInput/TextInput.ts
|
|
1213
1235
|
var TextInputBuilder = class extends ComponentBuilder {
|
|
1214
1236
|
static {
|
|
1215
1237
|
__name(this, "TextInputBuilder");
|
|
@@ -1223,7 +1245,7 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1223
1245
|
* ```ts
|
|
1224
1246
|
* const textInput = new TextInputBuilder({
|
|
1225
1247
|
* custom_id: 'a cool text input',
|
|
1226
|
-
*
|
|
1248
|
+
* placeholder: 'Type something',
|
|
1227
1249
|
* style: TextInputStyle.Short,
|
|
1228
1250
|
* });
|
|
1229
1251
|
* ```
|
|
@@ -1231,14 +1253,14 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1231
1253
|
* Creating a text input using setters and API data:
|
|
1232
1254
|
* ```ts
|
|
1233
1255
|
* const textInput = new TextInputBuilder({
|
|
1234
|
-
*
|
|
1256
|
+
* placeholder: 'Type something else',
|
|
1235
1257
|
* })
|
|
1236
1258
|
* .setCustomId('woah')
|
|
1237
1259
|
* .setStyle(TextInputStyle.Paragraph);
|
|
1238
1260
|
* ```
|
|
1239
1261
|
*/
|
|
1240
1262
|
constructor(data) {
|
|
1241
|
-
super({ type:
|
|
1263
|
+
super({ type: ComponentType8.TextInput, ...data });
|
|
1242
1264
|
}
|
|
1243
1265
|
/**
|
|
1244
1266
|
* Sets the custom id for this text input.
|
|
@@ -1253,6 +1275,7 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1253
1275
|
* Sets the label for this text input.
|
|
1254
1276
|
*
|
|
1255
1277
|
* @param label - The label to use
|
|
1278
|
+
* @deprecated Use a label builder to create a label (and optionally a description) instead.
|
|
1256
1279
|
*/
|
|
1257
1280
|
setLabel(label) {
|
|
1258
1281
|
this.data.label = labelValidator.parse(label);
|
|
@@ -1316,7 +1339,7 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1316
1339
|
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1317
1340
|
*/
|
|
1318
1341
|
toJSON() {
|
|
1319
|
-
validateRequiredParameters(this.data.custom_id, this.data.style
|
|
1342
|
+
validateRequiredParameters(this.data.custom_id, this.data.style);
|
|
1320
1343
|
return {
|
|
1321
1344
|
...this.data
|
|
1322
1345
|
};
|
|
@@ -1332,12 +1355,222 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1332
1355
|
}
|
|
1333
1356
|
};
|
|
1334
1357
|
|
|
1358
|
+
// src/components/label/Assertions.ts
|
|
1359
|
+
var Assertions_exports4 = {};
|
|
1360
|
+
__export(Assertions_exports4, {
|
|
1361
|
+
labelPredicate: () => labelPredicate
|
|
1362
|
+
});
|
|
1363
|
+
import { s as s5 } from "@sapphire/shapeshift";
|
|
1364
|
+
import { ComponentType as ComponentType10 } from "discord-api-types/v10";
|
|
1365
|
+
|
|
1366
|
+
// src/components/selectMenu/Assertions.ts
|
|
1367
|
+
import { Result, s as s4 } from "@sapphire/shapeshift";
|
|
1368
|
+
import { ChannelType as ChannelType2, ComponentType as ComponentType9, SelectMenuDefaultValueType as SelectMenuDefaultValueType5 } from "discord-api-types/v10";
|
|
1369
|
+
var selectMenuBasePredicate = s4.object({
|
|
1370
|
+
id: idValidator.optional(),
|
|
1371
|
+
placeholder: s4.string().lengthLessThanOrEqual(150).optional(),
|
|
1372
|
+
min_values: s4.number().greaterThanOrEqual(0).lessThanOrEqual(25).optional(),
|
|
1373
|
+
max_values: s4.number().greaterThanOrEqual(0).lessThanOrEqual(25).optional(),
|
|
1374
|
+
custom_id: customIdValidator,
|
|
1375
|
+
disabled: s4.boolean().optional()
|
|
1376
|
+
});
|
|
1377
|
+
var selectMenuChannelPredicate = selectMenuBasePredicate.extend({
|
|
1378
|
+
type: s4.literal(ComponentType9.ChannelSelect),
|
|
1379
|
+
channel_types: s4.nativeEnum(ChannelType2).array().optional(),
|
|
1380
|
+
default_values: s4.object({ id: s4.string(), type: s4.literal(SelectMenuDefaultValueType5.Channel) }).array().lengthLessThanOrEqual(25).optional()
|
|
1381
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
1382
|
+
var selectMenuMentionablePredicate = selectMenuBasePredicate.extend({
|
|
1383
|
+
type: s4.literal(ComponentType9.MentionableSelect),
|
|
1384
|
+
default_values: s4.object({
|
|
1385
|
+
id: s4.string(),
|
|
1386
|
+
type: s4.literal([SelectMenuDefaultValueType5.Role, SelectMenuDefaultValueType5.User])
|
|
1387
|
+
}).array().lengthLessThanOrEqual(25).optional()
|
|
1388
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
1389
|
+
var selectMenuRolePredicate = selectMenuBasePredicate.extend({
|
|
1390
|
+
type: s4.literal(ComponentType9.RoleSelect),
|
|
1391
|
+
default_values: s4.object({ id: s4.string(), type: s4.literal(SelectMenuDefaultValueType5.Role) }).array().lengthLessThanOrEqual(25).optional()
|
|
1392
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
1393
|
+
var selectMenuUserPredicate = selectMenuBasePredicate.extend({
|
|
1394
|
+
type: s4.literal(ComponentType9.UserSelect),
|
|
1395
|
+
default_values: s4.object({ id: s4.string(), type: s4.literal(SelectMenuDefaultValueType5.User) }).array().lengthLessThanOrEqual(25).optional()
|
|
1396
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
1397
|
+
var selectMenuStringOptionPredicate = s4.object({
|
|
1398
|
+
label: labelValidator,
|
|
1399
|
+
value: s4.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100),
|
|
1400
|
+
description: s4.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).optional(),
|
|
1401
|
+
emoji: emojiValidator.optional(),
|
|
1402
|
+
default: s4.boolean().optional()
|
|
1403
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
1404
|
+
var selectMenuStringPredicate = selectMenuBasePredicate.extend({
|
|
1405
|
+
type: s4.literal(ComponentType9.StringSelect),
|
|
1406
|
+
options: selectMenuStringOptionPredicate.array().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(25)
|
|
1407
|
+
}).reshape((value) => {
|
|
1408
|
+
if (value.min_values !== void 0 && value.options.length < value.min_values) {
|
|
1409
|
+
return Result.err(new RangeError(`The number of options must be greater than or equal to min_values`));
|
|
1410
|
+
}
|
|
1411
|
+
if (value.min_values !== void 0 && value.max_values !== void 0 && value.min_values > value.max_values) {
|
|
1412
|
+
return Result.err(
|
|
1413
|
+
new RangeError(`The maximum amount of options must be greater than or equal to the minimum amount of options`)
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
return Result.ok(value);
|
|
1417
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
1418
|
+
|
|
1419
|
+
// src/components/label/Assertions.ts
|
|
1420
|
+
var labelPredicate = s5.object({
|
|
1421
|
+
id: idValidator.optional(),
|
|
1422
|
+
type: s5.literal(ComponentType10.Label),
|
|
1423
|
+
label: s5.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45),
|
|
1424
|
+
description: s5.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).optional(),
|
|
1425
|
+
component: s5.union([
|
|
1426
|
+
textInputPredicate,
|
|
1427
|
+
selectMenuUserPredicate,
|
|
1428
|
+
selectMenuRolePredicate,
|
|
1429
|
+
selectMenuMentionablePredicate,
|
|
1430
|
+
selectMenuChannelPredicate,
|
|
1431
|
+
selectMenuStringPredicate
|
|
1432
|
+
])
|
|
1433
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
1434
|
+
|
|
1435
|
+
// src/components/label/Label.ts
|
|
1436
|
+
var LabelBuilder = class extends ComponentBuilder {
|
|
1437
|
+
static {
|
|
1438
|
+
__name(this, "LabelBuilder");
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* @internal
|
|
1442
|
+
*/
|
|
1443
|
+
data;
|
|
1444
|
+
/**
|
|
1445
|
+
* Creates a new label.
|
|
1446
|
+
*
|
|
1447
|
+
* @param data - The API data to create this label with
|
|
1448
|
+
* @example
|
|
1449
|
+
* Creating a label from an API data object:
|
|
1450
|
+
* ```ts
|
|
1451
|
+
* const label = new LabelBuilder({
|
|
1452
|
+
* label: "label",
|
|
1453
|
+
* component,
|
|
1454
|
+
* });
|
|
1455
|
+
* ```
|
|
1456
|
+
* @example
|
|
1457
|
+
* Creating a label using setters and API data:
|
|
1458
|
+
* ```ts
|
|
1459
|
+
* const label = new LabelBuilder({
|
|
1460
|
+
* label: 'label',
|
|
1461
|
+
* component,
|
|
1462
|
+
* }).setLabel('new text');
|
|
1463
|
+
* ```
|
|
1464
|
+
*/
|
|
1465
|
+
constructor(data = {}) {
|
|
1466
|
+
super({ type: ComponentType11.Label });
|
|
1467
|
+
const { component, ...rest } = data;
|
|
1468
|
+
this.data = {
|
|
1469
|
+
...rest,
|
|
1470
|
+
component: component ? createComponentBuilder(component) : void 0,
|
|
1471
|
+
type: ComponentType11.Label
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Sets the label for this label.
|
|
1476
|
+
*
|
|
1477
|
+
* @param label - The label to use
|
|
1478
|
+
*/
|
|
1479
|
+
setLabel(label) {
|
|
1480
|
+
this.data.label = label;
|
|
1481
|
+
return this;
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Sets the description for this label.
|
|
1485
|
+
*
|
|
1486
|
+
* @param description - The description to use
|
|
1487
|
+
*/
|
|
1488
|
+
setDescription(description) {
|
|
1489
|
+
this.data.description = description;
|
|
1490
|
+
return this;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Clears the description for this label.
|
|
1494
|
+
*/
|
|
1495
|
+
clearDescription() {
|
|
1496
|
+
this.data.description = void 0;
|
|
1497
|
+
return this;
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Sets a string select menu component to this label.
|
|
1501
|
+
*
|
|
1502
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1503
|
+
*/
|
|
1504
|
+
setStringSelectMenuComponent(input) {
|
|
1505
|
+
this.data.component = resolveBuilder(input, StringSelectMenuBuilder);
|
|
1506
|
+
return this;
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Sets a user select menu component to this label.
|
|
1510
|
+
*
|
|
1511
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1512
|
+
*/
|
|
1513
|
+
setUserSelectMenuComponent(input) {
|
|
1514
|
+
this.data.component = resolveBuilder(input, UserSelectMenuBuilder);
|
|
1515
|
+
return this;
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Sets a role select menu component to this label.
|
|
1519
|
+
*
|
|
1520
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1521
|
+
*/
|
|
1522
|
+
setRoleSelectMenuComponent(input) {
|
|
1523
|
+
this.data.component = resolveBuilder(input, RoleSelectMenuBuilder);
|
|
1524
|
+
return this;
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Sets a mentionable select menu component to this label.
|
|
1528
|
+
*
|
|
1529
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1530
|
+
*/
|
|
1531
|
+
setMentionableSelectMenuComponent(input) {
|
|
1532
|
+
this.data.component = resolveBuilder(input, MentionableSelectMenuBuilder);
|
|
1533
|
+
return this;
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Sets a channel select menu component to this label.
|
|
1537
|
+
*
|
|
1538
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1539
|
+
*/
|
|
1540
|
+
setChannelSelectMenuComponent(input) {
|
|
1541
|
+
this.data.component = resolveBuilder(input, ChannelSelectMenuBuilder);
|
|
1542
|
+
return this;
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Sets a text input component to this label.
|
|
1546
|
+
*
|
|
1547
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1548
|
+
*/
|
|
1549
|
+
setTextInputComponent(input) {
|
|
1550
|
+
this.data.component = resolveBuilder(input, TextInputBuilder);
|
|
1551
|
+
return this;
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1555
|
+
*/
|
|
1556
|
+
toJSON() {
|
|
1557
|
+
const { component, ...rest } = this.data;
|
|
1558
|
+
const data = {
|
|
1559
|
+
...rest,
|
|
1560
|
+
// The label predicate validates the component.
|
|
1561
|
+
component: component?.toJSON()
|
|
1562
|
+
};
|
|
1563
|
+
labelPredicate.parse(data);
|
|
1564
|
+
return data;
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
|
|
1335
1568
|
// src/components/v2/Container.ts
|
|
1336
|
-
import { ComponentType as
|
|
1569
|
+
import { ComponentType as ComponentType16 } from "discord-api-types/v10";
|
|
1337
1570
|
|
|
1338
1571
|
// src/components/v2/Assertions.ts
|
|
1339
|
-
var
|
|
1340
|
-
__export(
|
|
1572
|
+
var Assertions_exports5 = {};
|
|
1573
|
+
__export(Assertions_exports5, {
|
|
1341
1574
|
accessoryPredicate: () => accessoryPredicate,
|
|
1342
1575
|
assertReturnOfBuilder: () => assertReturnOfBuilder,
|
|
1343
1576
|
containerColorPredicate: () => containerColorPredicate,
|
|
@@ -1350,11 +1583,11 @@ __export(Assertions_exports4, {
|
|
|
1350
1583
|
unfurledMediaItemPredicate: () => unfurledMediaItemPredicate,
|
|
1351
1584
|
validateComponentArray: () => validateComponentArray
|
|
1352
1585
|
});
|
|
1353
|
-
import { s as
|
|
1586
|
+
import { s as s6 } from "@sapphire/shapeshift";
|
|
1354
1587
|
import { SeparatorSpacingSize } from "discord-api-types/v10";
|
|
1355
1588
|
|
|
1356
1589
|
// src/components/v2/Thumbnail.ts
|
|
1357
|
-
import { ComponentType as
|
|
1590
|
+
import { ComponentType as ComponentType12 } from "discord-api-types/v10";
|
|
1358
1591
|
var ThumbnailBuilder = class extends ComponentBuilder {
|
|
1359
1592
|
static {
|
|
1360
1593
|
__name(this, "ThumbnailBuilder");
|
|
@@ -1386,7 +1619,7 @@ var ThumbnailBuilder = class extends ComponentBuilder {
|
|
|
1386
1619
|
*/
|
|
1387
1620
|
constructor(data = {}) {
|
|
1388
1621
|
super({
|
|
1389
|
-
type:
|
|
1622
|
+
type: ComponentType12.Thumbnail,
|
|
1390
1623
|
...data,
|
|
1391
1624
|
media: data.media ? { url: data.media.url } : void 0
|
|
1392
1625
|
});
|
|
@@ -1435,33 +1668,33 @@ var ThumbnailBuilder = class extends ComponentBuilder {
|
|
|
1435
1668
|
};
|
|
1436
1669
|
|
|
1437
1670
|
// src/components/v2/Assertions.ts
|
|
1438
|
-
var unfurledMediaItemPredicate =
|
|
1439
|
-
url:
|
|
1671
|
+
var unfurledMediaItemPredicate = s6.object({
|
|
1672
|
+
url: s6.string().url(
|
|
1440
1673
|
{ allowedProtocols: ["http:", "https:", "attachment:"] },
|
|
1441
1674
|
{ message: "Invalid protocol for media URL. Must be http:, https:, or attachment:" }
|
|
1442
1675
|
)
|
|
1443
1676
|
}).setValidationEnabled(isValidationEnabled);
|
|
1444
|
-
var descriptionPredicate2 =
|
|
1445
|
-
var filePredicate =
|
|
1446
|
-
url:
|
|
1677
|
+
var descriptionPredicate2 = s6.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(1024).setValidationEnabled(isValidationEnabled);
|
|
1678
|
+
var filePredicate = s6.object({
|
|
1679
|
+
url: s6.string().url({ allowedProtocols: ["attachment:"] }, { message: "Invalid protocol for file URL. Must be attachment:" })
|
|
1447
1680
|
}).setValidationEnabled(isValidationEnabled);
|
|
1448
|
-
var spoilerPredicate =
|
|
1449
|
-
var dividerPredicate =
|
|
1450
|
-
var spacingPredicate =
|
|
1451
|
-
var textDisplayContentPredicate =
|
|
1452
|
-
var accessoryPredicate =
|
|
1681
|
+
var spoilerPredicate = s6.boolean();
|
|
1682
|
+
var dividerPredicate = s6.boolean();
|
|
1683
|
+
var spacingPredicate = s6.nativeEnum(SeparatorSpacingSize);
|
|
1684
|
+
var textDisplayContentPredicate = s6.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
1685
|
+
var accessoryPredicate = s6.instance(ButtonBuilder).or(s6.instance(ThumbnailBuilder)).setValidationEnabled(isValidationEnabled);
|
|
1453
1686
|
var containerColorPredicate = colorPredicate.nullish();
|
|
1454
1687
|
function assertReturnOfBuilder(input, ExpectedInstanceOf) {
|
|
1455
|
-
|
|
1688
|
+
s6.instance(ExpectedInstanceOf).setValidationEnabled(isValidationEnabled).parse(input);
|
|
1456
1689
|
}
|
|
1457
1690
|
__name(assertReturnOfBuilder, "assertReturnOfBuilder");
|
|
1458
1691
|
function validateComponentArray(input, min, max, ExpectedInstanceOf) {
|
|
1459
|
-
(ExpectedInstanceOf ?
|
|
1692
|
+
(ExpectedInstanceOf ? s6.instance(ExpectedInstanceOf) : s6.instance(ComponentBuilder)).array().lengthGreaterThanOrEqual(min).lengthLessThanOrEqual(max).setValidationEnabled(isValidationEnabled).parse(input);
|
|
1460
1693
|
}
|
|
1461
1694
|
__name(validateComponentArray, "validateComponentArray");
|
|
1462
1695
|
|
|
1463
1696
|
// src/components/v2/File.ts
|
|
1464
|
-
import { ComponentType as
|
|
1697
|
+
import { ComponentType as ComponentType13 } from "discord-api-types/v10";
|
|
1465
1698
|
var FileBuilder = class extends ComponentBuilder {
|
|
1466
1699
|
static {
|
|
1467
1700
|
__name(this, "FileBuilder");
|
|
@@ -1492,7 +1725,7 @@ var FileBuilder = class extends ComponentBuilder {
|
|
|
1492
1725
|
* ```
|
|
1493
1726
|
*/
|
|
1494
1727
|
constructor(data = {}) {
|
|
1495
|
-
super({ type:
|
|
1728
|
+
super({ type: ComponentType13.File, ...data, file: data.file ? { url: data.file.url } : void 0 });
|
|
1496
1729
|
}
|
|
1497
1730
|
/**
|
|
1498
1731
|
* Sets the spoiler status of this file.
|
|
@@ -1522,7 +1755,7 @@ var FileBuilder = class extends ComponentBuilder {
|
|
|
1522
1755
|
};
|
|
1523
1756
|
|
|
1524
1757
|
// src/components/v2/Separator.ts
|
|
1525
|
-
import { ComponentType as
|
|
1758
|
+
import { ComponentType as ComponentType14 } from "discord-api-types/v10";
|
|
1526
1759
|
var SeparatorBuilder = class extends ComponentBuilder {
|
|
1527
1760
|
static {
|
|
1528
1761
|
__name(this, "SeparatorBuilder");
|
|
@@ -1550,7 +1783,7 @@ var SeparatorBuilder = class extends ComponentBuilder {
|
|
|
1550
1783
|
*/
|
|
1551
1784
|
constructor(data = {}) {
|
|
1552
1785
|
super({
|
|
1553
|
-
type:
|
|
1786
|
+
type: ComponentType14.Separator,
|
|
1554
1787
|
...data
|
|
1555
1788
|
});
|
|
1556
1789
|
}
|
|
@@ -1588,7 +1821,7 @@ var SeparatorBuilder = class extends ComponentBuilder {
|
|
|
1588
1821
|
};
|
|
1589
1822
|
|
|
1590
1823
|
// src/components/v2/TextDisplay.ts
|
|
1591
|
-
import { ComponentType as
|
|
1824
|
+
import { ComponentType as ComponentType15 } from "discord-api-types/v10";
|
|
1592
1825
|
var TextDisplayBuilder = class extends ComponentBuilder {
|
|
1593
1826
|
static {
|
|
1594
1827
|
__name(this, "TextDisplayBuilder");
|
|
@@ -1615,7 +1848,7 @@ var TextDisplayBuilder = class extends ComponentBuilder {
|
|
|
1615
1848
|
*/
|
|
1616
1849
|
constructor(data = {}) {
|
|
1617
1850
|
super({
|
|
1618
|
-
type:
|
|
1851
|
+
type: ComponentType15.TextDisplay,
|
|
1619
1852
|
...data
|
|
1620
1853
|
});
|
|
1621
1854
|
}
|
|
@@ -1677,7 +1910,7 @@ var ContainerBuilder = class extends ComponentBuilder {
|
|
|
1677
1910
|
* ```
|
|
1678
1911
|
*/
|
|
1679
1912
|
constructor({ components, ...data } = {}) {
|
|
1680
|
-
super({ type:
|
|
1913
|
+
super({ type: ComponentType16.Container, ...data });
|
|
1681
1914
|
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
|
1682
1915
|
}
|
|
1683
1916
|
/**
|
|
@@ -1800,7 +2033,7 @@ var ContainerBuilder = class extends ComponentBuilder {
|
|
|
1800
2033
|
};
|
|
1801
2034
|
|
|
1802
2035
|
// src/components/v2/MediaGallery.ts
|
|
1803
|
-
import { ComponentType as
|
|
2036
|
+
import { ComponentType as ComponentType17 } from "discord-api-types/v10";
|
|
1804
2037
|
|
|
1805
2038
|
// src/components/v2/MediaGalleryItem.ts
|
|
1806
2039
|
var MediaGalleryItemBuilder = class {
|
|
@@ -1930,7 +2163,7 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
|
1930
2163
|
* ```
|
|
1931
2164
|
*/
|
|
1932
2165
|
constructor({ items, ...data } = {}) {
|
|
1933
|
-
super({ type:
|
|
2166
|
+
super({ type: ComponentType17.MediaGallery, ...data });
|
|
1934
2167
|
this.items = items?.map((item) => new MediaGalleryItemBuilder(item)) ?? [];
|
|
1935
2168
|
}
|
|
1936
2169
|
/**
|
|
@@ -1980,7 +2213,7 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
|
1980
2213
|
};
|
|
1981
2214
|
|
|
1982
2215
|
// src/components/v2/Section.ts
|
|
1983
|
-
import { ComponentType as
|
|
2216
|
+
import { ComponentType as ComponentType18 } from "discord-api-types/v10";
|
|
1984
2217
|
var SectionBuilder = class extends ComponentBuilder {
|
|
1985
2218
|
static {
|
|
1986
2219
|
__name(this, "SectionBuilder");
|
|
@@ -2029,7 +2262,7 @@ var SectionBuilder = class extends ComponentBuilder {
|
|
|
2029
2262
|
* ```
|
|
2030
2263
|
*/
|
|
2031
2264
|
constructor({ components, accessory, ...data } = {}) {
|
|
2032
|
-
super({ type:
|
|
2265
|
+
super({ type: ComponentType18.Section, ...data });
|
|
2033
2266
|
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
|
2034
2267
|
this.accessory = accessory ? createComponentBuilder(accessory) : void 0;
|
|
2035
2268
|
}
|
|
@@ -2104,36 +2337,38 @@ function createComponentBuilder(data) {
|
|
|
2104
2337
|
return data;
|
|
2105
2338
|
}
|
|
2106
2339
|
switch (data.type) {
|
|
2107
|
-
case
|
|
2340
|
+
case ComponentType19.ActionRow:
|
|
2108
2341
|
return new ActionRowBuilder(data);
|
|
2109
|
-
case
|
|
2342
|
+
case ComponentType19.Button:
|
|
2110
2343
|
return new ButtonBuilder(data);
|
|
2111
|
-
case
|
|
2344
|
+
case ComponentType19.StringSelect:
|
|
2112
2345
|
return new StringSelectMenuBuilder(data);
|
|
2113
|
-
case
|
|
2346
|
+
case ComponentType19.TextInput:
|
|
2114
2347
|
return new TextInputBuilder(data);
|
|
2115
|
-
case
|
|
2348
|
+
case ComponentType19.UserSelect:
|
|
2116
2349
|
return new UserSelectMenuBuilder(data);
|
|
2117
|
-
case
|
|
2350
|
+
case ComponentType19.RoleSelect:
|
|
2118
2351
|
return new RoleSelectMenuBuilder(data);
|
|
2119
|
-
case
|
|
2352
|
+
case ComponentType19.MentionableSelect:
|
|
2120
2353
|
return new MentionableSelectMenuBuilder(data);
|
|
2121
|
-
case
|
|
2354
|
+
case ComponentType19.ChannelSelect:
|
|
2122
2355
|
return new ChannelSelectMenuBuilder(data);
|
|
2123
|
-
case
|
|
2356
|
+
case ComponentType19.File:
|
|
2124
2357
|
return new FileBuilder(data);
|
|
2125
|
-
case
|
|
2358
|
+
case ComponentType19.Container:
|
|
2126
2359
|
return new ContainerBuilder(data);
|
|
2127
|
-
case
|
|
2360
|
+
case ComponentType19.Section:
|
|
2128
2361
|
return new SectionBuilder(data);
|
|
2129
|
-
case
|
|
2362
|
+
case ComponentType19.Separator:
|
|
2130
2363
|
return new SeparatorBuilder(data);
|
|
2131
|
-
case
|
|
2364
|
+
case ComponentType19.TextDisplay:
|
|
2132
2365
|
return new TextDisplayBuilder(data);
|
|
2133
|
-
case
|
|
2366
|
+
case ComponentType19.Thumbnail:
|
|
2134
2367
|
return new ThumbnailBuilder(data);
|
|
2135
|
-
case
|
|
2368
|
+
case ComponentType19.MediaGallery:
|
|
2136
2369
|
return new MediaGalleryBuilder(data);
|
|
2370
|
+
case ComponentType19.Label:
|
|
2371
|
+
return new LabelBuilder(data);
|
|
2137
2372
|
default:
|
|
2138
2373
|
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
|
2139
2374
|
}
|
|
@@ -2198,7 +2433,7 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
2198
2433
|
* ```
|
|
2199
2434
|
*/
|
|
2200
2435
|
constructor({ components, ...data } = {}) {
|
|
2201
|
-
super({ type:
|
|
2436
|
+
super({ type: ComponentType20.ActionRow, ...data });
|
|
2202
2437
|
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
|
2203
2438
|
}
|
|
2204
2439
|
/**
|
|
@@ -2230,16 +2465,19 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
2230
2465
|
}
|
|
2231
2466
|
};
|
|
2232
2467
|
|
|
2468
|
+
// src/interactions/modals/Modal.ts
|
|
2469
|
+
import { ComponentType as ComponentType21 } from "discord-api-types/v10";
|
|
2470
|
+
|
|
2233
2471
|
// src/interactions/modals/Assertions.ts
|
|
2234
|
-
var
|
|
2235
|
-
__export(
|
|
2472
|
+
var Assertions_exports6 = {};
|
|
2473
|
+
__export(Assertions_exports6, {
|
|
2236
2474
|
componentsValidator: () => componentsValidator,
|
|
2237
2475
|
titleValidator: () => titleValidator,
|
|
2238
2476
|
validateRequiredParameters: () => validateRequiredParameters2
|
|
2239
2477
|
});
|
|
2240
|
-
import { s as
|
|
2241
|
-
var titleValidator =
|
|
2242
|
-
var componentsValidator =
|
|
2478
|
+
import { s as s7 } from "@sapphire/shapeshift";
|
|
2479
|
+
var titleValidator = s7.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
|
2480
|
+
var componentsValidator = s7.union([s7.instance(ActionRowBuilder), s7.instance(LabelBuilder)]).array().lengthGreaterThanOrEqual(1).setValidationEnabled(isValidationEnabled);
|
|
2243
2481
|
function validateRequiredParameters2(customId, title, components) {
|
|
2244
2482
|
customIdValidator.parse(customId);
|
|
2245
2483
|
titleValidator.parse(title);
|
|
@@ -2291,19 +2529,107 @@ var ModalBuilder = class {
|
|
|
2291
2529
|
* Adds components to this modal.
|
|
2292
2530
|
*
|
|
2293
2531
|
* @param components - The components to add
|
|
2532
|
+
* @deprecated Use {@link ModalBuilder.addLabelComponents} or {@link ModalBuilder.addActionRowComponents} instead
|
|
2294
2533
|
*/
|
|
2295
2534
|
addComponents(...components) {
|
|
2296
2535
|
this.components.push(
|
|
2297
|
-
...normalizeArray(components).map(
|
|
2298
|
-
(component
|
|
2299
|
-
|
|
2536
|
+
...normalizeArray(components).map((component, idx) => {
|
|
2537
|
+
if (component instanceof ActionRowBuilder || component instanceof LabelBuilder) {
|
|
2538
|
+
return component;
|
|
2539
|
+
}
|
|
2540
|
+
if (component instanceof TextInputBuilder) {
|
|
2541
|
+
return new ActionRowBuilder().addComponents(component);
|
|
2542
|
+
}
|
|
2543
|
+
if ("type" in component) {
|
|
2544
|
+
if (component.type === ComponentType21.ActionRow) {
|
|
2545
|
+
return new ActionRowBuilder(component);
|
|
2546
|
+
}
|
|
2547
|
+
if (component.type === ComponentType21.Label) {
|
|
2548
|
+
return new LabelBuilder(component);
|
|
2549
|
+
}
|
|
2550
|
+
if (component.type === ComponentType21.TextInput) {
|
|
2551
|
+
return new ActionRowBuilder().addComponents(
|
|
2552
|
+
new TextInputBuilder(component)
|
|
2553
|
+
);
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
throw new TypeError(`Invalid component passed in ModalBuilder.addComponents at index ${idx}!`);
|
|
2557
|
+
})
|
|
2300
2558
|
);
|
|
2301
2559
|
return this;
|
|
2302
2560
|
}
|
|
2561
|
+
/**
|
|
2562
|
+
* Adds label components to this modal.
|
|
2563
|
+
*
|
|
2564
|
+
* @param components - The components to add
|
|
2565
|
+
*/
|
|
2566
|
+
addLabelComponents(...components) {
|
|
2567
|
+
const normalized = normalizeArray(components);
|
|
2568
|
+
const resolved = normalized.map((label) => resolveBuilder(label, LabelBuilder));
|
|
2569
|
+
this.components.push(...resolved);
|
|
2570
|
+
return this;
|
|
2571
|
+
}
|
|
2572
|
+
/**
|
|
2573
|
+
* Adds action rows to this modal.
|
|
2574
|
+
*
|
|
2575
|
+
* @param components - The components to add
|
|
2576
|
+
* @deprecated Use {@link ModalBuilder.addLabelComponents} instead
|
|
2577
|
+
*/
|
|
2578
|
+
addActionRowComponents(...components) {
|
|
2579
|
+
const normalized = normalizeArray(components);
|
|
2580
|
+
const resolved = normalized.map((row) => resolveBuilder(row, ActionRowBuilder));
|
|
2581
|
+
this.components.push(...resolved);
|
|
2582
|
+
return this;
|
|
2583
|
+
}
|
|
2584
|
+
/**
|
|
2585
|
+
* Sets the labels for this modal.
|
|
2586
|
+
*
|
|
2587
|
+
* @param components - The components to set
|
|
2588
|
+
*/
|
|
2589
|
+
setLabelComponents(...components) {
|
|
2590
|
+
const normalized = normalizeArray(components);
|
|
2591
|
+
this.spliceLabelComponents(0, this.components.length, ...normalized);
|
|
2592
|
+
return this;
|
|
2593
|
+
}
|
|
2594
|
+
/**
|
|
2595
|
+
* Removes, replaces, or inserts labels for this modal.
|
|
2596
|
+
*
|
|
2597
|
+
* @remarks
|
|
2598
|
+
* This method behaves similarly
|
|
2599
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
2600
|
+
* The maximum amount of labels that can be added is 5.
|
|
2601
|
+
*
|
|
2602
|
+
* It's useful for modifying and adjusting order of the already-existing labels of a modal.
|
|
2603
|
+
* @example
|
|
2604
|
+
* Remove the first label:
|
|
2605
|
+
* ```ts
|
|
2606
|
+
* modal.spliceLabelComponents(0, 1);
|
|
2607
|
+
* ```
|
|
2608
|
+
* @example
|
|
2609
|
+
* Remove the first n labels:
|
|
2610
|
+
* ```ts
|
|
2611
|
+
* const n = 4;
|
|
2612
|
+
* modal.spliceLabelComponents(0, n);
|
|
2613
|
+
* ```
|
|
2614
|
+
* @example
|
|
2615
|
+
* Remove the last label:
|
|
2616
|
+
* ```ts
|
|
2617
|
+
* modal.spliceLabelComponents(-1, 1);
|
|
2618
|
+
* ```
|
|
2619
|
+
* @param index - The index to start at
|
|
2620
|
+
* @param deleteCount - The number of labels to remove
|
|
2621
|
+
* @param labels - The replacing label objects
|
|
2622
|
+
*/
|
|
2623
|
+
spliceLabelComponents(index, deleteCount, ...labels) {
|
|
2624
|
+
const resolved = labels.map((label) => resolveBuilder(label, LabelBuilder));
|
|
2625
|
+
this.components.splice(index, deleteCount, ...resolved);
|
|
2626
|
+
return this;
|
|
2627
|
+
}
|
|
2303
2628
|
/**
|
|
2304
2629
|
* Sets components for this modal.
|
|
2305
2630
|
*
|
|
2306
2631
|
* @param components - The components to set
|
|
2632
|
+
* @deprecated Use {@link ModalBuilder.setLabelComponents} instead
|
|
2307
2633
|
*/
|
|
2308
2634
|
setComponents(...components) {
|
|
2309
2635
|
this.components.splice(0, this.components.length, ...normalizeArray(components));
|
|
@@ -2322,8 +2648,8 @@ var ModalBuilder = class {
|
|
|
2322
2648
|
};
|
|
2323
2649
|
|
|
2324
2650
|
// src/interactions/slashCommands/Assertions.ts
|
|
2325
|
-
var
|
|
2326
|
-
__export(
|
|
2651
|
+
var Assertions_exports7 = {};
|
|
2652
|
+
__export(Assertions_exports7, {
|
|
2327
2653
|
assertReturnOfBuilder: () => assertReturnOfBuilder2,
|
|
2328
2654
|
contextsPredicate: () => contextsPredicate,
|
|
2329
2655
|
integrationTypesPredicate: () => integrationTypesPredicate,
|
|
@@ -2341,24 +2667,24 @@ __export(Assertions_exports6, {
|
|
|
2341
2667
|
validateRequired: () => validateRequired,
|
|
2342
2668
|
validateRequiredParameters: () => validateRequiredParameters3
|
|
2343
2669
|
});
|
|
2344
|
-
import { s as
|
|
2670
|
+
import { s as s8 } from "@sapphire/shapeshift";
|
|
2345
2671
|
import {
|
|
2346
2672
|
ApplicationIntegrationType,
|
|
2347
2673
|
InteractionContextType,
|
|
2348
2674
|
Locale
|
|
2349
2675
|
} from "discord-api-types/v10";
|
|
2350
|
-
var namePredicate =
|
|
2676
|
+
var namePredicate = s8.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u).setValidationEnabled(isValidationEnabled);
|
|
2351
2677
|
function validateName(name) {
|
|
2352
2678
|
namePredicate.parse(name);
|
|
2353
2679
|
}
|
|
2354
2680
|
__name(validateName, "validateName");
|
|
2355
|
-
var descriptionPredicate3 =
|
|
2356
|
-
var localePredicate =
|
|
2681
|
+
var descriptionPredicate3 = s8.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
2682
|
+
var localePredicate = s8.nativeEnum(Locale);
|
|
2357
2683
|
function validateDescription(description) {
|
|
2358
2684
|
descriptionPredicate3.parse(description);
|
|
2359
2685
|
}
|
|
2360
2686
|
__name(validateDescription, "validateDescription");
|
|
2361
|
-
var maxArrayLengthPredicate =
|
|
2687
|
+
var maxArrayLengthPredicate = s8.unknown().array().lengthLessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
|
2362
2688
|
function validateLocale(locale) {
|
|
2363
2689
|
return localePredicate.parse(locale);
|
|
2364
2690
|
}
|
|
@@ -2373,7 +2699,7 @@ function validateRequiredParameters3(name, description, options) {
|
|
|
2373
2699
|
validateMaxOptionsLength(options);
|
|
2374
2700
|
}
|
|
2375
2701
|
__name(validateRequiredParameters3, "validateRequiredParameters");
|
|
2376
|
-
var booleanPredicate =
|
|
2702
|
+
var booleanPredicate = s8.boolean();
|
|
2377
2703
|
function validateDefaultPermission(value) {
|
|
2378
2704
|
booleanPredicate.parse(value);
|
|
2379
2705
|
}
|
|
@@ -2382,29 +2708,29 @@ function validateRequired(required) {
|
|
|
2382
2708
|
booleanPredicate.parse(required);
|
|
2383
2709
|
}
|
|
2384
2710
|
__name(validateRequired, "validateRequired");
|
|
2385
|
-
var choicesLengthPredicate =
|
|
2711
|
+
var choicesLengthPredicate = s8.number().lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
|
2386
2712
|
function validateChoicesLength(amountAdding, choices) {
|
|
2387
2713
|
choicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);
|
|
2388
2714
|
}
|
|
2389
2715
|
__name(validateChoicesLength, "validateChoicesLength");
|
|
2390
2716
|
function assertReturnOfBuilder2(input, ExpectedInstanceOf) {
|
|
2391
|
-
|
|
2717
|
+
s8.instance(ExpectedInstanceOf).parse(input);
|
|
2392
2718
|
}
|
|
2393
2719
|
__name(assertReturnOfBuilder2, "assertReturnOfBuilder");
|
|
2394
|
-
var localizationMapPredicate =
|
|
2720
|
+
var localizationMapPredicate = s8.object(Object.fromEntries(Object.values(Locale).map((locale) => [locale, s8.string().nullish()]))).strict().nullish().setValidationEnabled(isValidationEnabled);
|
|
2395
2721
|
function validateLocalizationMap(value) {
|
|
2396
2722
|
localizationMapPredicate.parse(value);
|
|
2397
2723
|
}
|
|
2398
2724
|
__name(validateLocalizationMap, "validateLocalizationMap");
|
|
2399
|
-
var dmPermissionPredicate =
|
|
2725
|
+
var dmPermissionPredicate = s8.boolean().nullish();
|
|
2400
2726
|
function validateDMPermission(value) {
|
|
2401
2727
|
dmPermissionPredicate.parse(value);
|
|
2402
2728
|
}
|
|
2403
2729
|
__name(validateDMPermission, "validateDMPermission");
|
|
2404
|
-
var memberPermissionPredicate =
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2730
|
+
var memberPermissionPredicate = s8.union([
|
|
2731
|
+
s8.bigint().transform((value) => value.toString()),
|
|
2732
|
+
s8.number().safeInt().transform((value) => value.toString()),
|
|
2733
|
+
s8.string().regex(/^\d+$/)
|
|
2408
2734
|
]).nullish();
|
|
2409
2735
|
function validateDefaultMemberPermissions(permissions) {
|
|
2410
2736
|
return memberPermissionPredicate.parse(permissions);
|
|
@@ -2414,11 +2740,11 @@ function validateNSFW(value) {
|
|
|
2414
2740
|
booleanPredicate.parse(value);
|
|
2415
2741
|
}
|
|
2416
2742
|
__name(validateNSFW, "validateNSFW");
|
|
2417
|
-
var contextsPredicate =
|
|
2418
|
-
|
|
2743
|
+
var contextsPredicate = s8.array(
|
|
2744
|
+
s8.nativeEnum(InteractionContextType).setValidationEnabled(isValidationEnabled)
|
|
2419
2745
|
);
|
|
2420
|
-
var integrationTypesPredicate =
|
|
2421
|
-
|
|
2746
|
+
var integrationTypesPredicate = s8.array(
|
|
2747
|
+
s8.nativeEnum(ApplicationIntegrationType).setValidationEnabled(isValidationEnabled)
|
|
2422
2748
|
);
|
|
2423
2749
|
|
|
2424
2750
|
// src/interactions/slashCommands/SlashCommandBuilder.ts
|
|
@@ -2728,21 +3054,21 @@ import { ApplicationCommandOptionType as ApplicationCommandOptionType3 } from "d
|
|
|
2728
3054
|
import { mix } from "ts-mixer";
|
|
2729
3055
|
|
|
2730
3056
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
|
|
2731
|
-
import { s as
|
|
2732
|
-
import { ChannelType as
|
|
3057
|
+
import { s as s9 } from "@sapphire/shapeshift";
|
|
3058
|
+
import { ChannelType as ChannelType3 } from "discord-api-types/v10";
|
|
2733
3059
|
var allowedChannelTypes = [
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
3060
|
+
ChannelType3.GuildText,
|
|
3061
|
+
ChannelType3.GuildVoice,
|
|
3062
|
+
ChannelType3.GuildCategory,
|
|
3063
|
+
ChannelType3.GuildAnnouncement,
|
|
3064
|
+
ChannelType3.AnnouncementThread,
|
|
3065
|
+
ChannelType3.PublicThread,
|
|
3066
|
+
ChannelType3.PrivateThread,
|
|
3067
|
+
ChannelType3.GuildStageVoice,
|
|
3068
|
+
ChannelType3.GuildForum,
|
|
3069
|
+
ChannelType3.GuildMedia
|
|
2744
3070
|
];
|
|
2745
|
-
var channelTypesPredicate =
|
|
3071
|
+
var channelTypesPredicate = s9.array(s9.union(allowedChannelTypes.map((type) => s9.literal(type))));
|
|
2746
3072
|
var ApplicationCommandOptionChannelTypesMixin = class {
|
|
2747
3073
|
static {
|
|
2748
3074
|
__name(this, "ApplicationCommandOptionChannelTypesMixin");
|
|
@@ -2785,7 +3111,7 @@ SlashCommandChannelOption = __decorateClass([
|
|
|
2785
3111
|
], SlashCommandChannelOption);
|
|
2786
3112
|
|
|
2787
3113
|
// src/interactions/slashCommands/options/integer.ts
|
|
2788
|
-
import { s as
|
|
3114
|
+
import { s as s12 } from "@sapphire/shapeshift";
|
|
2789
3115
|
import { ApplicationCommandOptionType as ApplicationCommandOptionType5 } from "discord-api-types/v10";
|
|
2790
3116
|
import { mix as mix2 } from "ts-mixer";
|
|
2791
3117
|
|
|
@@ -2805,8 +3131,8 @@ var ApplicationCommandNumericOptionMinMaxValueMixin = class {
|
|
|
2805
3131
|
};
|
|
2806
3132
|
|
|
2807
3133
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithAutocompleteMixin.ts
|
|
2808
|
-
import { s as
|
|
2809
|
-
var booleanPredicate2 =
|
|
3134
|
+
import { s as s10 } from "@sapphire/shapeshift";
|
|
3135
|
+
var booleanPredicate2 = s10.boolean();
|
|
2810
3136
|
var ApplicationCommandOptionWithAutocompleteMixin = class {
|
|
2811
3137
|
static {
|
|
2812
3138
|
__name(this, "ApplicationCommandOptionWithAutocompleteMixin");
|
|
@@ -2837,14 +3163,14 @@ var ApplicationCommandOptionWithAutocompleteMixin = class {
|
|
|
2837
3163
|
};
|
|
2838
3164
|
|
|
2839
3165
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesMixin.ts
|
|
2840
|
-
import { s as
|
|
3166
|
+
import { s as s11 } from "@sapphire/shapeshift";
|
|
2841
3167
|
import { ApplicationCommandOptionType as ApplicationCommandOptionType4 } from "discord-api-types/v10";
|
|
2842
|
-
var stringPredicate =
|
|
2843
|
-
var numberPredicate =
|
|
2844
|
-
var choicesPredicate =
|
|
3168
|
+
var stringPredicate = s11.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100);
|
|
3169
|
+
var numberPredicate = s11.number().greaterThan(Number.NEGATIVE_INFINITY).lessThan(Number.POSITIVE_INFINITY);
|
|
3170
|
+
var choicesPredicate = s11.object({
|
|
2845
3171
|
name: stringPredicate,
|
|
2846
3172
|
name_localizations: localizationMapPredicate,
|
|
2847
|
-
value:
|
|
3173
|
+
value: s11.union([stringPredicate, numberPredicate])
|
|
2848
3174
|
}).array();
|
|
2849
3175
|
var ApplicationCommandOptionWithChoicesMixin = class {
|
|
2850
3176
|
static {
|
|
@@ -2903,7 +3229,7 @@ var ApplicationCommandOptionWithChoicesMixin = class {
|
|
|
2903
3229
|
};
|
|
2904
3230
|
|
|
2905
3231
|
// src/interactions/slashCommands/options/integer.ts
|
|
2906
|
-
var numberValidator =
|
|
3232
|
+
var numberValidator = s12.number().int();
|
|
2907
3233
|
var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase {
|
|
2908
3234
|
/**
|
|
2909
3235
|
* The type of this option.
|
|
@@ -2965,10 +3291,10 @@ var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
|
|
|
2965
3291
|
};
|
|
2966
3292
|
|
|
2967
3293
|
// src/interactions/slashCommands/options/number.ts
|
|
2968
|
-
import { s as
|
|
3294
|
+
import { s as s13 } from "@sapphire/shapeshift";
|
|
2969
3295
|
import { ApplicationCommandOptionType as ApplicationCommandOptionType7 } from "discord-api-types/v10";
|
|
2970
3296
|
import { mix as mix3 } from "ts-mixer";
|
|
2971
|
-
var numberValidator2 =
|
|
3297
|
+
var numberValidator2 = s13.number();
|
|
2972
3298
|
var SlashCommandNumberOption = class extends ApplicationCommandOptionBase {
|
|
2973
3299
|
/**
|
|
2974
3300
|
* The type of this option.
|
|
@@ -3030,11 +3356,11 @@ var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
|
|
|
3030
3356
|
};
|
|
3031
3357
|
|
|
3032
3358
|
// src/interactions/slashCommands/options/string.ts
|
|
3033
|
-
import { s as
|
|
3359
|
+
import { s as s14 } from "@sapphire/shapeshift";
|
|
3034
3360
|
import { ApplicationCommandOptionType as ApplicationCommandOptionType9 } from "discord-api-types/v10";
|
|
3035
3361
|
import { mix as mix4 } from "ts-mixer";
|
|
3036
|
-
var minLengthValidator2 =
|
|
3037
|
-
var maxLengthValidator2 =
|
|
3362
|
+
var minLengthValidator2 = s14.number().greaterThanOrEqual(0).lessThanOrEqual(6e3);
|
|
3363
|
+
var maxLengthValidator2 = s14.number().greaterThanOrEqual(1).lessThanOrEqual(6e3);
|
|
3038
3364
|
var SlashCommandStringOption = class extends ApplicationCommandOptionBase {
|
|
3039
3365
|
/**
|
|
3040
3366
|
* The type of this option.
|
|
@@ -3383,8 +3709,8 @@ SlashCommandBuilder = __decorateClass([
|
|
|
3383
3709
|
], SlashCommandBuilder);
|
|
3384
3710
|
|
|
3385
3711
|
// src/interactions/contextMenuCommands/Assertions.ts
|
|
3386
|
-
var
|
|
3387
|
-
__export(
|
|
3712
|
+
var Assertions_exports8 = {};
|
|
3713
|
+
__export(Assertions_exports8, {
|
|
3388
3714
|
contextsPredicate: () => contextsPredicate2,
|
|
3389
3715
|
integrationTypesPredicate: () => integrationTypesPredicate2,
|
|
3390
3716
|
validateDMPermission: () => validateDMPermission2,
|
|
@@ -3394,11 +3720,11 @@ __export(Assertions_exports7, {
|
|
|
3394
3720
|
validateRequiredParameters: () => validateRequiredParameters4,
|
|
3395
3721
|
validateType: () => validateType
|
|
3396
3722
|
});
|
|
3397
|
-
import { s as
|
|
3723
|
+
import { s as s15 } from "@sapphire/shapeshift";
|
|
3398
3724
|
import { ApplicationCommandType as ApplicationCommandType2, ApplicationIntegrationType as ApplicationIntegrationType2, InteractionContextType as InteractionContextType2 } from "discord-api-types/v10";
|
|
3399
|
-
var namePredicate2 =
|
|
3400
|
-
var typePredicate =
|
|
3401
|
-
var booleanPredicate3 =
|
|
3725
|
+
var namePredicate2 = s15.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/\S/).setValidationEnabled(isValidationEnabled);
|
|
3726
|
+
var typePredicate = s15.union([s15.literal(ApplicationCommandType2.User), s15.literal(ApplicationCommandType2.Message)]).setValidationEnabled(isValidationEnabled);
|
|
3727
|
+
var booleanPredicate3 = s15.boolean();
|
|
3402
3728
|
function validateDefaultPermission2(value) {
|
|
3403
3729
|
booleanPredicate3.parse(value);
|
|
3404
3730
|
}
|
|
@@ -3416,25 +3742,25 @@ function validateRequiredParameters4(name, type) {
|
|
|
3416
3742
|
validateType(type);
|
|
3417
3743
|
}
|
|
3418
3744
|
__name(validateRequiredParameters4, "validateRequiredParameters");
|
|
3419
|
-
var dmPermissionPredicate2 =
|
|
3745
|
+
var dmPermissionPredicate2 = s15.boolean().nullish();
|
|
3420
3746
|
function validateDMPermission2(value) {
|
|
3421
3747
|
dmPermissionPredicate2.parse(value);
|
|
3422
3748
|
}
|
|
3423
3749
|
__name(validateDMPermission2, "validateDMPermission");
|
|
3424
|
-
var memberPermissionPredicate2 =
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3750
|
+
var memberPermissionPredicate2 = s15.union([
|
|
3751
|
+
s15.bigint().transform((value) => value.toString()),
|
|
3752
|
+
s15.number().safeInt().transform((value) => value.toString()),
|
|
3753
|
+
s15.string().regex(/^\d+$/)
|
|
3428
3754
|
]).nullish();
|
|
3429
3755
|
function validateDefaultMemberPermissions2(permissions) {
|
|
3430
3756
|
return memberPermissionPredicate2.parse(permissions);
|
|
3431
3757
|
}
|
|
3432
3758
|
__name(validateDefaultMemberPermissions2, "validateDefaultMemberPermissions");
|
|
3433
|
-
var contextsPredicate2 =
|
|
3434
|
-
|
|
3759
|
+
var contextsPredicate2 = s15.array(
|
|
3760
|
+
s15.nativeEnum(InteractionContextType2).setValidationEnabled(isValidationEnabled)
|
|
3435
3761
|
);
|
|
3436
|
-
var integrationTypesPredicate2 =
|
|
3437
|
-
|
|
3762
|
+
var integrationTypesPredicate2 = s15.array(
|
|
3763
|
+
s15.nativeEnum(ApplicationIntegrationType2).setValidationEnabled(isValidationEnabled)
|
|
3438
3764
|
);
|
|
3439
3765
|
|
|
3440
3766
|
// src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
|
|
@@ -3615,7 +3941,7 @@ function embedLength(data) {
|
|
|
3615
3941
|
__name(embedLength, "embedLength");
|
|
3616
3942
|
|
|
3617
3943
|
// src/index.ts
|
|
3618
|
-
var version = "1.
|
|
3944
|
+
var version = "1.12.0";
|
|
3619
3945
|
export {
|
|
3620
3946
|
ActionRowBuilder,
|
|
3621
3947
|
ApplicationCommandNumericOptionMinMaxValueMixin,
|
|
@@ -3628,17 +3954,19 @@ export {
|
|
|
3628
3954
|
ChannelSelectMenuBuilder,
|
|
3629
3955
|
Assertions_exports2 as ComponentAssertions,
|
|
3630
3956
|
ComponentBuilder,
|
|
3631
|
-
|
|
3957
|
+
Assertions_exports5 as ComponentsV2Assertions,
|
|
3632
3958
|
ContainerBuilder,
|
|
3633
|
-
|
|
3959
|
+
Assertions_exports8 as ContextMenuCommandAssertions,
|
|
3634
3960
|
ContextMenuCommandBuilder,
|
|
3635
3961
|
Assertions_exports as EmbedAssertions,
|
|
3636
3962
|
EmbedBuilder,
|
|
3637
3963
|
FileBuilder,
|
|
3964
|
+
Assertions_exports4 as LabelAssertions,
|
|
3965
|
+
LabelBuilder,
|
|
3638
3966
|
MediaGalleryBuilder,
|
|
3639
3967
|
MediaGalleryItemBuilder,
|
|
3640
3968
|
MentionableSelectMenuBuilder,
|
|
3641
|
-
|
|
3969
|
+
Assertions_exports6 as ModalAssertions,
|
|
3642
3970
|
ModalBuilder,
|
|
3643
3971
|
RoleSelectMenuBuilder,
|
|
3644
3972
|
SectionBuilder,
|
|
@@ -3649,7 +3977,7 @@ export {
|
|
|
3649
3977
|
SharedSlashCommand,
|
|
3650
3978
|
SharedSlashCommandOptions,
|
|
3651
3979
|
SharedSlashCommandSubcommands,
|
|
3652
|
-
|
|
3980
|
+
Assertions_exports7 as SlashCommandAssertions,
|
|
3653
3981
|
SlashCommandAttachmentOption,
|
|
3654
3982
|
SlashCommandBooleanOption,
|
|
3655
3983
|
SlashCommandBuilder,
|