@discordjs/builders 2.0.0-pr-11005.1765454364-f3f6d34e7 → 2.0.0-pr-11005.1765463668-087384722
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 +197 -20
- package/dist/index.d.ts +197 -20
- package/dist/index.js +141 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +137 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -107,16 +107,16 @@ __export(index_exports, {
|
|
|
107
107
|
embedAuthorPredicate: () => embedAuthorPredicate,
|
|
108
108
|
embedFieldPredicate: () => embedFieldPredicate,
|
|
109
109
|
embedFooterPredicate: () => embedFooterPredicate,
|
|
110
|
-
embedLength: () => embedLength,
|
|
111
110
|
embedPredicate: () => embedPredicate,
|
|
112
111
|
emojiPredicate: () => emojiPredicate,
|
|
113
112
|
enableValidators: () => enableValidators,
|
|
113
|
+
fileBodyMessagePredicate: () => fileBodyMessagePredicate,
|
|
114
114
|
filePredicate: () => filePredicate,
|
|
115
115
|
fileUploadPredicate: () => fileUploadPredicate,
|
|
116
116
|
idPredicate: () => idPredicate,
|
|
117
117
|
integerOptionPredicate: () => integerOptionPredicate,
|
|
118
118
|
isValidationEnabled: () => isValidationEnabled,
|
|
119
|
-
labelPredicate: () =>
|
|
119
|
+
labelPredicate: () => labelPredicate,
|
|
120
120
|
localeMapPredicate: () => localeMapPredicate,
|
|
121
121
|
mediaGalleryItemPredicate: () => mediaGalleryItemPredicate,
|
|
122
122
|
mediaGalleryPredicate: () => mediaGalleryPredicate,
|
|
@@ -131,6 +131,7 @@ __export(index_exports, {
|
|
|
131
131
|
pollAnswerPredicate: () => pollAnswerPredicate,
|
|
132
132
|
pollPredicate: () => pollPredicate,
|
|
133
133
|
pollQuestionPredicate: () => pollQuestionPredicate,
|
|
134
|
+
rawFilePredicate: () => rawFilePredicate,
|
|
134
135
|
resolveAccessoryComponent: () => resolveAccessoryComponent,
|
|
135
136
|
resolveBuilder: () => resolveBuilder,
|
|
136
137
|
sectionPredicate: () => sectionPredicate,
|
|
@@ -141,6 +142,7 @@ __export(index_exports, {
|
|
|
141
142
|
selectMenuStringPredicate: () => selectMenuStringPredicate,
|
|
142
143
|
selectMenuUserPredicate: () => selectMenuUserPredicate,
|
|
143
144
|
separatorPredicate: () => separatorPredicate,
|
|
145
|
+
snowflakePredicate: () => snowflakePredicate,
|
|
144
146
|
stringOptionPredicate: () => stringOptionPredicate,
|
|
145
147
|
textDisplayPredicate: () => textDisplayPredicate,
|
|
146
148
|
textInputPredicate: () => textInputPredicate,
|
|
@@ -244,15 +246,15 @@ var import_v10 = require("discord-api-types/v10");
|
|
|
244
246
|
var import_zod2 = require("zod");
|
|
245
247
|
var idPredicate = import_zod2.z.int().min(0).max(2147483647).optional();
|
|
246
248
|
var customIdPredicate = import_zod2.z.string().min(1).max(100);
|
|
249
|
+
var snowflakePredicate = import_zod2.z.string().regex(/^(?:0|[1-9]\d*)$/);
|
|
247
250
|
var memberPermissionsPredicate = import_zod2.z.coerce.bigint();
|
|
248
251
|
var localeMapPredicate = import_zod2.z.strictObject(
|
|
249
252
|
Object.fromEntries(Object.values(import_v10.Locale).map((loc) => [loc, import_zod2.z.string().optional()]))
|
|
250
253
|
);
|
|
251
254
|
|
|
252
255
|
// src/components/Assertions.ts
|
|
253
|
-
var labelPredicate = import_zod3.z.string().min(1).max(80);
|
|
254
256
|
var emojiPredicate = import_zod3.z.strictObject({
|
|
255
|
-
id:
|
|
257
|
+
id: snowflakePredicate.optional(),
|
|
256
258
|
name: import_zod3.z.string().min(2).max(32).optional(),
|
|
257
259
|
animated: import_zod3.z.boolean().optional()
|
|
258
260
|
}).refine((data) => data.id !== void 0 || data.name !== void 0, {
|
|
@@ -262,24 +264,29 @@ var buttonPredicateBase = import_zod3.z.strictObject({
|
|
|
262
264
|
type: import_zod3.z.literal(import_v102.ComponentType.Button),
|
|
263
265
|
disabled: import_zod3.z.boolean().optional()
|
|
264
266
|
});
|
|
267
|
+
var buttonLabelPredicate = import_zod3.z.string().min(1).max(80);
|
|
265
268
|
var buttonCustomIdPredicateBase = buttonPredicateBase.extend({
|
|
266
269
|
custom_id: customIdPredicate,
|
|
267
270
|
emoji: emojiPredicate.optional(),
|
|
268
|
-
label:
|
|
271
|
+
label: buttonLabelPredicate.optional()
|
|
272
|
+
}).refine((data) => data.emoji !== void 0 || data.label !== void 0, {
|
|
273
|
+
message: "Buttons with a custom id must have either an emoji or a label."
|
|
269
274
|
});
|
|
270
|
-
var buttonPrimaryPredicate = buttonCustomIdPredicateBase.
|
|
271
|
-
var buttonSecondaryPredicate = buttonCustomIdPredicateBase.
|
|
272
|
-
var buttonSuccessPredicate = buttonCustomIdPredicateBase.
|
|
273
|
-
var buttonDangerPredicate = buttonCustomIdPredicateBase.
|
|
275
|
+
var buttonPrimaryPredicate = buttonCustomIdPredicateBase.safeExtend({ style: import_zod3.z.literal(import_v102.ButtonStyle.Primary) });
|
|
276
|
+
var buttonSecondaryPredicate = buttonCustomIdPredicateBase.safeExtend({ style: import_zod3.z.literal(import_v102.ButtonStyle.Secondary) });
|
|
277
|
+
var buttonSuccessPredicate = buttonCustomIdPredicateBase.safeExtend({ style: import_zod3.z.literal(import_v102.ButtonStyle.Success) });
|
|
278
|
+
var buttonDangerPredicate = buttonCustomIdPredicateBase.safeExtend({ style: import_zod3.z.literal(import_v102.ButtonStyle.Danger) });
|
|
274
279
|
var buttonLinkPredicate = buttonPredicateBase.extend({
|
|
275
280
|
style: import_zod3.z.literal(import_v102.ButtonStyle.Link),
|
|
276
281
|
url: import_zod3.z.url({ protocol: /^(?:https?|discord)$/ }).max(512),
|
|
277
282
|
emoji: emojiPredicate.optional(),
|
|
278
|
-
label:
|
|
283
|
+
label: buttonLabelPredicate.optional()
|
|
284
|
+
}).refine((data) => data.emoji !== void 0 || data.label !== void 0, {
|
|
285
|
+
message: "Link buttons must have either an emoji or a label."
|
|
279
286
|
});
|
|
280
287
|
var buttonPremiumPredicate = buttonPredicateBase.extend({
|
|
281
288
|
style: import_zod3.z.literal(import_v102.ButtonStyle.Premium),
|
|
282
|
-
sku_id:
|
|
289
|
+
sku_id: snowflakePredicate
|
|
283
290
|
});
|
|
284
291
|
var buttonPredicate = import_zod3.z.discriminatedUnion("style", [
|
|
285
292
|
buttonLinkPredicate,
|
|
@@ -300,21 +307,21 @@ var selectMenuBasePredicate = import_zod3.z.object({
|
|
|
300
307
|
var selectMenuChannelPredicate = selectMenuBasePredicate.extend({
|
|
301
308
|
type: import_zod3.z.literal(import_v102.ComponentType.ChannelSelect),
|
|
302
309
|
channel_types: import_zod3.z.enum(import_v102.ChannelType).array().optional(),
|
|
303
|
-
default_values: import_zod3.z.object({ id:
|
|
310
|
+
default_values: import_zod3.z.object({ id: snowflakePredicate, type: import_zod3.z.literal(import_v102.SelectMenuDefaultValueType.Channel) }).array().max(25).optional()
|
|
304
311
|
});
|
|
305
312
|
var selectMenuMentionablePredicate = selectMenuBasePredicate.extend({
|
|
306
313
|
type: import_zod3.z.literal(import_v102.ComponentType.MentionableSelect),
|
|
307
314
|
default_values: import_zod3.z.object({
|
|
308
|
-
id:
|
|
315
|
+
id: snowflakePredicate,
|
|
309
316
|
type: import_zod3.z.literal([import_v102.SelectMenuDefaultValueType.Role, import_v102.SelectMenuDefaultValueType.User])
|
|
310
317
|
}).array().max(25).optional()
|
|
311
318
|
});
|
|
312
319
|
var selectMenuRolePredicate = selectMenuBasePredicate.extend({
|
|
313
320
|
type: import_zod3.z.literal(import_v102.ComponentType.RoleSelect),
|
|
314
|
-
default_values: import_zod3.z.object({ id:
|
|
321
|
+
default_values: import_zod3.z.object({ id: snowflakePredicate, type: import_zod3.z.literal(import_v102.SelectMenuDefaultValueType.Role) }).array().max(25).optional()
|
|
315
322
|
});
|
|
316
323
|
var selectMenuStringOptionPredicate = import_zod3.z.object({
|
|
317
|
-
label:
|
|
324
|
+
label: import_zod3.z.string().min(1).max(100),
|
|
318
325
|
value: import_zod3.z.string().min(1).max(100),
|
|
319
326
|
description: import_zod3.z.string().min(1).max(100).optional(),
|
|
320
327
|
emoji: emojiPredicate.optional(),
|
|
@@ -352,7 +359,7 @@ var selectMenuStringPredicate = selectMenuBasePredicate.extend({
|
|
|
352
359
|
});
|
|
353
360
|
var selectMenuUserPredicate = selectMenuBasePredicate.extend({
|
|
354
361
|
type: import_zod3.z.literal(import_v102.ComponentType.UserSelect),
|
|
355
|
-
default_values: import_zod3.z.object({ id:
|
|
362
|
+
default_values: import_zod3.z.object({ id: snowflakePredicate, type: import_zod3.z.literal(import_v102.SelectMenuDefaultValueType.User) }).array().max(25).optional()
|
|
356
363
|
});
|
|
357
364
|
var actionRowPredicate = import_zod3.z.object({
|
|
358
365
|
id: idPredicate,
|
|
@@ -2644,7 +2651,7 @@ __name(resolveAccessoryComponent, "resolveAccessoryComponent");
|
|
|
2644
2651
|
// src/components/label/Assertions.ts
|
|
2645
2652
|
var import_v1025 = require("discord-api-types/v10");
|
|
2646
2653
|
var import_zod7 = require("zod");
|
|
2647
|
-
var
|
|
2654
|
+
var labelPredicate = import_zod7.z.object({
|
|
2648
2655
|
id: idPredicate,
|
|
2649
2656
|
type: import_zod7.z.literal(import_v1025.ComponentType.Label),
|
|
2650
2657
|
label: import_zod7.z.string().min(1).max(45),
|
|
@@ -2797,7 +2804,7 @@ var LabelBuilder = class extends ComponentBuilder {
|
|
|
2797
2804
|
// The label predicate validates the component.
|
|
2798
2805
|
component: component?.toJSON(false)
|
|
2799
2806
|
};
|
|
2800
|
-
validate(
|
|
2807
|
+
validate(labelPredicate, data, validationOverride);
|
|
2801
2808
|
return data;
|
|
2802
2809
|
}
|
|
2803
2810
|
};
|
|
@@ -3123,8 +3130,8 @@ var numberOptionPredicate = import_zod8.z.object({
|
|
|
3123
3130
|
...numericMixinNumberOptionPredicate.shape
|
|
3124
3131
|
}).and(autocompleteOrNumberChoicesMixinOptionPredicate);
|
|
3125
3132
|
var stringOptionPredicate = basicOptionPredicate.extend({
|
|
3126
|
-
max_length: import_zod8.z.number().min(
|
|
3127
|
-
min_length: import_zod8.z.number().min(
|
|
3133
|
+
max_length: import_zod8.z.number().min(1).max(6e3).optional(),
|
|
3134
|
+
min_length: import_zod8.z.number().min(0).max(6e3).optional()
|
|
3128
3135
|
}).and(autocompleteOrStringChoicesMixinOptionPredicate);
|
|
3129
3136
|
var baseChatInputCommandPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
3130
3137
|
contexts: import_zod8.z.array(import_zod8.z.enum(import_v1028.InteractionContextType)).optional(),
|
|
@@ -3134,8 +3141,12 @@ var baseChatInputCommandPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
|
3134
3141
|
});
|
|
3135
3142
|
var chatInputCommandOptionsPredicate = import_zod8.z.union([
|
|
3136
3143
|
import_zod8.z.object({ type: basicOptionTypesPredicate }).array(),
|
|
3137
|
-
import_zod8.z.object({
|
|
3138
|
-
|
|
3144
|
+
import_zod8.z.object({
|
|
3145
|
+
type: import_zod8.z.union([
|
|
3146
|
+
import_zod8.z.literal(import_v1028.ApplicationCommandOptionType.Subcommand),
|
|
3147
|
+
import_zod8.z.literal(import_v1028.ApplicationCommandOptionType.SubcommandGroup)
|
|
3148
|
+
])
|
|
3149
|
+
}).array()
|
|
3139
3150
|
]);
|
|
3140
3151
|
var chatInputCommandPredicate = baseChatInputCommandPredicate.extend({
|
|
3141
3152
|
options: chatInputCommandOptionsPredicate.optional()
|
|
@@ -3786,7 +3797,7 @@ var modalPredicate = import_zod10.z.object({
|
|
|
3786
3797
|
type: import_zod10.z.literal(import_v1043.ComponentType.ActionRow),
|
|
3787
3798
|
components: import_zod10.z.object({ type: import_zod10.z.literal(import_v1043.ComponentType.TextInput) }).array().length(1)
|
|
3788
3799
|
}),
|
|
3789
|
-
|
|
3800
|
+
labelPredicate,
|
|
3790
3801
|
textDisplayPredicate
|
|
3791
3802
|
]).array().min(1).max(5)
|
|
3792
3803
|
});
|
|
@@ -3910,15 +3921,8 @@ var ModalBuilder = class {
|
|
|
3910
3921
|
};
|
|
3911
3922
|
|
|
3912
3923
|
// src/messages/embed/Assertions.ts
|
|
3924
|
+
var import_util = require("@discordjs/util");
|
|
3913
3925
|
var import_zod11 = require("zod");
|
|
3914
|
-
|
|
3915
|
-
// src/util/componentUtil.ts
|
|
3916
|
-
function embedLength(data) {
|
|
3917
|
-
return (data.title?.length ?? 0) + (data.description?.length ?? 0) + (data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) + (data.footer?.text.length ?? 0) + (data.author?.name.length ?? 0);
|
|
3918
|
-
}
|
|
3919
|
-
__name(embedLength, "embedLength");
|
|
3920
|
-
|
|
3921
|
-
// src/messages/embed/Assertions.ts
|
|
3922
3926
|
var namePredicate3 = import_zod11.z.string().max(256);
|
|
3923
3927
|
var URLPredicate = import_zod11.z.url({ protocol: /^https?$/ });
|
|
3924
3928
|
var URLWithAttachmentProtocolPredicate = import_zod11.z.url({ protocol: /^(?:https?|attachment)$/ });
|
|
@@ -3952,7 +3956,7 @@ var embedPredicate = import_zod11.z.object({
|
|
|
3952
3956
|
{
|
|
3953
3957
|
error: "Embed must have at least a title, description, a field, a footer, an author, an image, OR a thumbnail."
|
|
3954
3958
|
}
|
|
3955
|
-
).refine((embed) => embedLength(embed) <= 6e3, { error: "Embeds must not exceed 6000 characters in total." });
|
|
3959
|
+
).refine((embed) => (0, import_util.embedLength)(embed) <= 6e3, { error: "Embeds must not exceed 6000 characters in total." });
|
|
3956
3960
|
|
|
3957
3961
|
// src/messages/embed/EmbedAuthor.ts
|
|
3958
3962
|
var EmbedAuthorBuilder = class {
|
|
@@ -4773,10 +4777,19 @@ var PollBuilder = class {
|
|
|
4773
4777
|
};
|
|
4774
4778
|
|
|
4775
4779
|
// src/messages/Assertions.ts
|
|
4780
|
+
var import_node_buffer = require("buffer");
|
|
4776
4781
|
var import_v1045 = require("discord-api-types/v10");
|
|
4777
4782
|
var import_zod13 = require("zod");
|
|
4783
|
+
var fileKeyRegex = /^files\[(?<placeholder>\d+?)]$/;
|
|
4784
|
+
var rawFilePredicate = import_zod13.z.object({
|
|
4785
|
+
data: import_zod13.z.union([import_zod13.z.instanceof(import_node_buffer.Buffer), import_zod13.z.instanceof(Uint8Array), import_zod13.z.string()]),
|
|
4786
|
+
name: import_zod13.z.string().min(1),
|
|
4787
|
+
contentType: import_zod13.z.string().optional(),
|
|
4788
|
+
key: import_zod13.z.string().regex(fileKeyRegex).optional()
|
|
4789
|
+
});
|
|
4778
4790
|
var attachmentPredicate = import_zod13.z.object({
|
|
4779
|
-
|
|
4791
|
+
// As a string it only makes sense for edits when we do have an attachment snowflake
|
|
4792
|
+
id: import_zod13.z.union([snowflakePredicate, import_zod13.z.number()]),
|
|
4780
4793
|
description: import_zod13.z.string().max(1024).optional(),
|
|
4781
4794
|
duration_secs: import_zod13.z.number().max(2 ** 31 - 1).optional(),
|
|
4782
4795
|
filename: import_zod13.z.string().max(1024).optional(),
|
|
@@ -4862,6 +4875,11 @@ var messageComponentsV2Predicate = baseMessagePredicate.extend({
|
|
|
4862
4875
|
poll: import_zod13.z.null().optional()
|
|
4863
4876
|
});
|
|
4864
4877
|
var messagePredicate = import_zod13.z.union([messageNoComponentsV2Predicate, messageComponentsV2Predicate]);
|
|
4878
|
+
var fileBodyMessagePredicate = import_zod13.z.object({
|
|
4879
|
+
body: messagePredicate,
|
|
4880
|
+
// No min length to support message edits
|
|
4881
|
+
files: rawFilePredicate.array().max(10)
|
|
4882
|
+
});
|
|
4865
4883
|
|
|
4866
4884
|
// src/messages/AllowedMentions.ts
|
|
4867
4885
|
var AllowedMentionsBuilder = class {
|
|
@@ -5046,13 +5064,29 @@ var AttachmentBuilder = class {
|
|
|
5046
5064
|
* The API data associated with this attachment.
|
|
5047
5065
|
*/
|
|
5048
5066
|
data;
|
|
5067
|
+
/**
|
|
5068
|
+
* This data is not included in the output of `toJSON()`. For this class specifically, this refers to binary data
|
|
5069
|
+
* that will wind up being included in the multipart/form-data request, if used with the `MessageBuilder`.
|
|
5070
|
+
* To retrieve this data, use {@link getRawFile}.
|
|
5071
|
+
*
|
|
5072
|
+
* @remarks This cannot be set via the constructor, primarily because of the behavior described
|
|
5073
|
+
* {@link https://discord.com/developers/docs/reference#editing-message-attachments | here}.
|
|
5074
|
+
* That is, when editing a message's attachments, you should only be providing file data for new attachments.
|
|
5075
|
+
*/
|
|
5076
|
+
fileData;
|
|
5049
5077
|
/**
|
|
5050
5078
|
* Creates a new attachment builder.
|
|
5051
5079
|
*
|
|
5052
5080
|
* @param data - The API data to create this attachment with
|
|
5081
|
+
* @example
|
|
5082
|
+
* ```ts
|
|
5083
|
+
* const attachment = new AttachmentBuilder().setId(1).setFileData(':)').setFilename('smiley.txt')
|
|
5084
|
+
* ```
|
|
5085
|
+
* @remarks Please note that the `id` field is required, it's rather easy to miss!
|
|
5053
5086
|
*/
|
|
5054
5087
|
constructor(data = {}) {
|
|
5055
5088
|
this.data = structuredClone(data);
|
|
5089
|
+
this.fileData = {};
|
|
5056
5090
|
}
|
|
5057
5091
|
/**
|
|
5058
5092
|
* Sets the id of the attachment.
|
|
@@ -5111,6 +5145,54 @@ var AttachmentBuilder = class {
|
|
|
5111
5145
|
this.data.filename = void 0;
|
|
5112
5146
|
return this;
|
|
5113
5147
|
}
|
|
5148
|
+
/**
|
|
5149
|
+
* Sets the file data to upload with this attachment.
|
|
5150
|
+
*
|
|
5151
|
+
* @param data - The file data
|
|
5152
|
+
* @remarks Note that this data is NOT included in the {@link toJSON} output. To retrieve it, use {@link getRawFile}.
|
|
5153
|
+
*/
|
|
5154
|
+
setFileData(data) {
|
|
5155
|
+
this.fileData.data = data;
|
|
5156
|
+
return this;
|
|
5157
|
+
}
|
|
5158
|
+
/**
|
|
5159
|
+
* Clears the file data from this attachment.
|
|
5160
|
+
*/
|
|
5161
|
+
clearFileData() {
|
|
5162
|
+
this.fileData.data = void 0;
|
|
5163
|
+
return this;
|
|
5164
|
+
}
|
|
5165
|
+
/**
|
|
5166
|
+
* Sets the content type of the file data to upload with this attachment.
|
|
5167
|
+
*
|
|
5168
|
+
* @remarks Note that this data is NOT included in the {@link toJSON} output. To retrieve it, use {@link getRawFile}.
|
|
5169
|
+
*/
|
|
5170
|
+
setFileContentType(contentType) {
|
|
5171
|
+
this.fileData.contentType = contentType;
|
|
5172
|
+
return this;
|
|
5173
|
+
}
|
|
5174
|
+
/**
|
|
5175
|
+
* Clears the content type of the file data from this attachment.
|
|
5176
|
+
*/
|
|
5177
|
+
clearFileContentType() {
|
|
5178
|
+
this.fileData.contentType = void 0;
|
|
5179
|
+
return this;
|
|
5180
|
+
}
|
|
5181
|
+
/**
|
|
5182
|
+
* Converts this attachment to a {@link RawFile} for uploading.
|
|
5183
|
+
*
|
|
5184
|
+
* @returns A {@link RawFile} object, or `undefined` if no file data is set
|
|
5185
|
+
*/
|
|
5186
|
+
getRawFile() {
|
|
5187
|
+
if (!this.fileData?.data) {
|
|
5188
|
+
return;
|
|
5189
|
+
}
|
|
5190
|
+
return {
|
|
5191
|
+
...this.fileData,
|
|
5192
|
+
name: this.data.filename,
|
|
5193
|
+
key: this.data.id === void 0 ? void 0 : `files[${this.data.id}]`
|
|
5194
|
+
};
|
|
5195
|
+
}
|
|
5114
5196
|
/**
|
|
5115
5197
|
* Sets the title of this attachment.
|
|
5116
5198
|
*
|
|
@@ -5415,7 +5497,7 @@ var MessageBuilder = class {
|
|
|
5415
5497
|
*
|
|
5416
5498
|
* @param allowedMentions - The allowed mentions to set
|
|
5417
5499
|
*/
|
|
5418
|
-
setAllowedMentions(allowedMentions) {
|
|
5500
|
+
setAllowedMentions(allowedMentions = new AllowedMentionsBuilder()) {
|
|
5419
5501
|
this.data.allowed_mentions = resolveBuilder(allowedMentions, AllowedMentionsBuilder);
|
|
5420
5502
|
return this;
|
|
5421
5503
|
}
|
|
@@ -5748,10 +5830,31 @@ var MessageBuilder = class {
|
|
|
5748
5830
|
validate(messagePredicate, data, validationOverride);
|
|
5749
5831
|
return data;
|
|
5750
5832
|
}
|
|
5833
|
+
/**
|
|
5834
|
+
* Serializes this builder to both JSON body and file data for multipart/form-data requests.
|
|
5835
|
+
*
|
|
5836
|
+
* @param validationOverride - Force validation to run/not run regardless of your global preference
|
|
5837
|
+
* @remarks
|
|
5838
|
+
* This method extracts file data from attachments that have files set via {@link AttachmentBuilder.setFileData}.
|
|
5839
|
+
* The returned body includes attachment metadata, while files contains the binary data for upload.
|
|
5840
|
+
*/
|
|
5841
|
+
toFileBody(validationOverride) {
|
|
5842
|
+
const body = this.toJSON(false);
|
|
5843
|
+
const files = [];
|
|
5844
|
+
for (const attachment of this.data.attachments) {
|
|
5845
|
+
const rawFile = attachment.getRawFile();
|
|
5846
|
+
if (rawFile?.data || rawFile?.contentType) {
|
|
5847
|
+
files.push(rawFile);
|
|
5848
|
+
}
|
|
5849
|
+
}
|
|
5850
|
+
const combined = { body, files };
|
|
5851
|
+
validate(fileBodyMessagePredicate, combined, validationOverride);
|
|
5852
|
+
return combined;
|
|
5853
|
+
}
|
|
5751
5854
|
};
|
|
5752
5855
|
|
|
5753
5856
|
// src/index.ts
|
|
5754
|
-
var version = "2.0.0-pr-11005.
|
|
5857
|
+
var version = "2.0.0-pr-11005.1765463668-087384722";
|
|
5755
5858
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5756
5859
|
0 && (module.exports = {
|
|
5757
5860
|
ActionRowBuilder,
|
|
@@ -5840,10 +5943,10 @@ var version = "2.0.0-pr-11005.1765454364-f3f6d34e7";
|
|
|
5840
5943
|
embedAuthorPredicate,
|
|
5841
5944
|
embedFieldPredicate,
|
|
5842
5945
|
embedFooterPredicate,
|
|
5843
|
-
embedLength,
|
|
5844
5946
|
embedPredicate,
|
|
5845
5947
|
emojiPredicate,
|
|
5846
5948
|
enableValidators,
|
|
5949
|
+
fileBodyMessagePredicate,
|
|
5847
5950
|
filePredicate,
|
|
5848
5951
|
fileUploadPredicate,
|
|
5849
5952
|
idPredicate,
|
|
@@ -5864,6 +5967,7 @@ var version = "2.0.0-pr-11005.1765454364-f3f6d34e7";
|
|
|
5864
5967
|
pollAnswerPredicate,
|
|
5865
5968
|
pollPredicate,
|
|
5866
5969
|
pollQuestionPredicate,
|
|
5970
|
+
rawFilePredicate,
|
|
5867
5971
|
resolveAccessoryComponent,
|
|
5868
5972
|
resolveBuilder,
|
|
5869
5973
|
sectionPredicate,
|
|
@@ -5874,6 +5978,7 @@ var version = "2.0.0-pr-11005.1765454364-f3f6d34e7";
|
|
|
5874
5978
|
selectMenuStringPredicate,
|
|
5875
5979
|
selectMenuUserPredicate,
|
|
5876
5980
|
separatorPredicate,
|
|
5981
|
+
snowflakePredicate,
|
|
5877
5982
|
stringOptionPredicate,
|
|
5878
5983
|
textDisplayPredicate,
|
|
5879
5984
|
textInputPredicate,
|