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