@discordjs/builders 2.0.0-dev.1745540007-8e4e319c2 → 2.0.0-dev.1745755498-d32aacd14
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 +95 -33
- package/dist/index.d.ts +95 -33
- package/dist/index.js +103 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4316,18 +4316,23 @@ var import_v1041 = require("discord-api-types/v10");
|
|
|
4316
4316
|
var import_zod10 = require("zod");
|
|
4317
4317
|
var attachmentPredicate = import_zod10.z.object({
|
|
4318
4318
|
id: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.number()]),
|
|
4319
|
-
description: import_zod10.z.string().optional(),
|
|
4320
|
-
duration_secs: import_zod10.z.number().optional(),
|
|
4321
|
-
filename: import_zod10.z.string().optional(),
|
|
4322
|
-
title: import_zod10.z.string().optional(),
|
|
4323
|
-
waveform: import_zod10.z.string().optional()
|
|
4319
|
+
description: import_zod10.z.string().max(1024).optional(),
|
|
4320
|
+
duration_secs: import_zod10.z.number().max(2 ** 31 - 1).optional(),
|
|
4321
|
+
filename: import_zod10.z.string().max(1024).optional(),
|
|
4322
|
+
title: import_zod10.z.string().max(1024).optional(),
|
|
4323
|
+
waveform: import_zod10.z.string().max(400).optional()
|
|
4324
4324
|
});
|
|
4325
4325
|
var allowedMentionPredicate = import_zod10.z.object({
|
|
4326
4326
|
parse: import_zod10.z.nativeEnum(import_v1041.AllowedMentionsTypes).array().optional(),
|
|
4327
|
-
roles: import_zod10.z.string().array().optional(),
|
|
4328
|
-
users: import_zod10.z.string().array().optional(),
|
|
4327
|
+
roles: import_zod10.z.string().array().max(100).optional(),
|
|
4328
|
+
users: import_zod10.z.string().array().max(100).optional(),
|
|
4329
4329
|
replied_user: import_zod10.z.boolean().optional()
|
|
4330
|
-
})
|
|
4330
|
+
}).refine(
|
|
4331
|
+
(data) => !(data.parse?.includes(import_v1041.AllowedMentionsTypes.User) && data.users?.length || data.parse?.includes(import_v1041.AllowedMentionsTypes.Role) && data.roles?.length),
|
|
4332
|
+
{
|
|
4333
|
+
message: 'Cannot specify both parse: ["users"] and non-empty users array, or parse: ["roles"] and non-empty roles array. These are mutually exclusive'
|
|
4334
|
+
}
|
|
4335
|
+
);
|
|
4331
4336
|
var messageReferencePredicate = import_zod10.z.object({
|
|
4332
4337
|
channel_id: import_zod10.z.string().optional(),
|
|
4333
4338
|
fail_if_not_exists: import_zod10.z.boolean().optional(),
|
|
@@ -4357,9 +4362,9 @@ var basicActionRowPredicate = import_zod10.z.object({
|
|
|
4357
4362
|
}).array()
|
|
4358
4363
|
});
|
|
4359
4364
|
var messageNoComponentsV2Predicate = baseMessagePredicate.extend({
|
|
4360
|
-
content: import_zod10.z.string().optional(),
|
|
4365
|
+
content: import_zod10.z.string().max(2e3).optional(),
|
|
4361
4366
|
embeds: embedPredicate.array().max(10).optional(),
|
|
4362
|
-
sticker_ids: import_zod10.z.array(import_zod10.z.string()).
|
|
4367
|
+
sticker_ids: import_zod10.z.array(import_zod10.z.string()).max(3).optional(),
|
|
4363
4368
|
poll: pollPredicate.optional(),
|
|
4364
4369
|
components: basicActionRowPredicate.array().max(5).optional(),
|
|
4365
4370
|
flags: import_zod10.z.number().optional().refine((flags) => {
|
|
@@ -4405,9 +4410,9 @@ var AllowedMentionsBuilder = class {
|
|
|
4405
4410
|
}
|
|
4406
4411
|
data;
|
|
4407
4412
|
/**
|
|
4408
|
-
* Creates new allowed
|
|
4413
|
+
* Creates a new allowed mentions builder from API data.
|
|
4409
4414
|
*
|
|
4410
|
-
* @param data - The API data to create this
|
|
4415
|
+
* @param data - The API data to create this allowed mentions builder with
|
|
4411
4416
|
*/
|
|
4412
4417
|
constructor(data = {}) {
|
|
4413
4418
|
this.data = structuredClone(data);
|
|
@@ -4421,6 +4426,13 @@ var AllowedMentionsBuilder = class {
|
|
|
4421
4426
|
this.data.parse = normalizeArray(parse);
|
|
4422
4427
|
return this;
|
|
4423
4428
|
}
|
|
4429
|
+
/**
|
|
4430
|
+
* Clears the parse mention types.
|
|
4431
|
+
*/
|
|
4432
|
+
clearParse() {
|
|
4433
|
+
this.data.parse = void 0;
|
|
4434
|
+
return this;
|
|
4435
|
+
}
|
|
4424
4436
|
/**
|
|
4425
4437
|
* Sets the roles to mention.
|
|
4426
4438
|
*
|
|
@@ -4454,7 +4466,7 @@ var AllowedMentionsBuilder = class {
|
|
|
4454
4466
|
* allowedMentions.spliceRoles(0, 1);
|
|
4455
4467
|
* ```
|
|
4456
4468
|
* @example
|
|
4457
|
-
* Remove the first n
|
|
4469
|
+
* Remove the first n roles:
|
|
4458
4470
|
* ```ts
|
|
4459
4471
|
* const n = 4;
|
|
4460
4472
|
* allowedMentions.spliceRoles(0, n);
|
|
@@ -4473,6 +4485,13 @@ var AllowedMentionsBuilder = class {
|
|
|
4473
4485
|
this.data.roles.splice(index, deleteCount, ...normalizeArray(roles));
|
|
4474
4486
|
return this;
|
|
4475
4487
|
}
|
|
4488
|
+
/**
|
|
4489
|
+
* Clears the roles to mention.
|
|
4490
|
+
*/
|
|
4491
|
+
clearRoles() {
|
|
4492
|
+
this.data.roles = void 0;
|
|
4493
|
+
return this;
|
|
4494
|
+
}
|
|
4476
4495
|
/**
|
|
4477
4496
|
* Sets the users to mention.
|
|
4478
4497
|
*
|
|
@@ -4506,7 +4525,7 @@ var AllowedMentionsBuilder = class {
|
|
|
4506
4525
|
* allowedMentions.spliceUsers(0, 1);
|
|
4507
4526
|
* ```
|
|
4508
4527
|
* @example
|
|
4509
|
-
* Remove the first n
|
|
4528
|
+
* Remove the first n users:
|
|
4510
4529
|
* ```ts
|
|
4511
4530
|
* const n = 4;
|
|
4512
4531
|
* allowedMentions.spliceUsers(0, n);
|
|
@@ -4526,7 +4545,16 @@ var AllowedMentionsBuilder = class {
|
|
|
4526
4545
|
return this;
|
|
4527
4546
|
}
|
|
4528
4547
|
/**
|
|
4529
|
-
*
|
|
4548
|
+
* Clears the users to mention.
|
|
4549
|
+
*/
|
|
4550
|
+
clearUsers() {
|
|
4551
|
+
this.data.users = void 0;
|
|
4552
|
+
return this;
|
|
4553
|
+
}
|
|
4554
|
+
/**
|
|
4555
|
+
* For replies, sets whether to mention the author of the message being replied to.
|
|
4556
|
+
*
|
|
4557
|
+
* @param repliedUser - Whether to mention the author of the message being replied to
|
|
4530
4558
|
*/
|
|
4531
4559
|
setRepliedUser(repliedUser = true) {
|
|
4532
4560
|
this.data.replied_user = repliedUser;
|
|
@@ -4553,29 +4581,26 @@ var AttachmentBuilder = class {
|
|
|
4553
4581
|
}
|
|
4554
4582
|
data;
|
|
4555
4583
|
/**
|
|
4556
|
-
* Creates new attachment builder from API data.
|
|
4584
|
+
* Creates a new attachment builder from API data.
|
|
4557
4585
|
*
|
|
4558
|
-
* @param data - The API data to create this attachment with
|
|
4586
|
+
* @param data - The API data to create this attachment builder with
|
|
4559
4587
|
*/
|
|
4560
4588
|
constructor(data = {}) {
|
|
4561
4589
|
this.data = structuredClone(data);
|
|
4562
4590
|
}
|
|
4563
4591
|
/**
|
|
4592
|
+
* Sets the id of the attachment.
|
|
4593
|
+
*
|
|
4564
4594
|
* @param id - The id of the attachment
|
|
4565
4595
|
*/
|
|
4566
4596
|
setId(id) {
|
|
4567
4597
|
this.data.id = id;
|
|
4568
4598
|
return this;
|
|
4569
4599
|
}
|
|
4570
|
-
/**
|
|
4571
|
-
* Clears the id of this attachment.
|
|
4572
|
-
*/
|
|
4573
|
-
clearId() {
|
|
4574
|
-
this.data.id = void 0;
|
|
4575
|
-
return this;
|
|
4576
|
-
}
|
|
4577
4600
|
/**
|
|
4578
4601
|
* Sets the description of this attachment.
|
|
4602
|
+
*
|
|
4603
|
+
* @param description - The description of the attachment
|
|
4579
4604
|
*/
|
|
4580
4605
|
setDescription(description) {
|
|
4581
4606
|
this.data.description = description;
|
|
@@ -4637,7 +4662,7 @@ var AttachmentBuilder = class {
|
|
|
4637
4662
|
return this;
|
|
4638
4663
|
}
|
|
4639
4664
|
/**
|
|
4640
|
-
* Sets the waveform of this attachment.
|
|
4665
|
+
* Sets the waveform of this attachment (audio clips).
|
|
4641
4666
|
*
|
|
4642
4667
|
* @param waveform - The waveform of the attachment
|
|
4643
4668
|
*/
|
|
@@ -4673,15 +4698,15 @@ var MessageReferenceBuilder = class {
|
|
|
4673
4698
|
}
|
|
4674
4699
|
data;
|
|
4675
4700
|
/**
|
|
4676
|
-
* Creates new
|
|
4701
|
+
* Creates a new message reference builder from API data.
|
|
4677
4702
|
*
|
|
4678
|
-
* @param data - The API data to create this
|
|
4703
|
+
* @param data - The API data to create this message reference builder with
|
|
4679
4704
|
*/
|
|
4680
4705
|
constructor(data = {}) {
|
|
4681
4706
|
this.data = structuredClone(data);
|
|
4682
4707
|
}
|
|
4683
4708
|
/**
|
|
4684
|
-
* Sets the
|
|
4709
|
+
* Sets the type of message reference this represents
|
|
4685
4710
|
*
|
|
4686
4711
|
* @param type - The type of message reference
|
|
4687
4712
|
*/
|
|
@@ -4737,6 +4762,15 @@ var MessageReferenceBuilder = class {
|
|
|
4737
4762
|
this.data.guild_id = void 0;
|
|
4738
4763
|
return this;
|
|
4739
4764
|
}
|
|
4765
|
+
/**
|
|
4766
|
+
* Sets whether to fail the message creation if the referenced message does not exist
|
|
4767
|
+
*
|
|
4768
|
+
* @param failIfNotExists - Whether to fail the message creation if the referenced message does not exist
|
|
4769
|
+
*/
|
|
4770
|
+
setFailIfNotExists(failIfNotExists = true) {
|
|
4771
|
+
this.data.fail_if_not_exists = failIfNotExists;
|
|
4772
|
+
return this;
|
|
4773
|
+
}
|
|
4740
4774
|
/**
|
|
4741
4775
|
* Serializes this builder to API-compatible JSON data.
|
|
4742
4776
|
*
|
|
@@ -4779,19 +4813,27 @@ var MessageBuilder = class {
|
|
|
4779
4813
|
return this.data.embeds;
|
|
4780
4814
|
}
|
|
4781
4815
|
/**
|
|
4782
|
-
* Creates new
|
|
4816
|
+
* Creates a new message builder from API data.
|
|
4783
4817
|
*
|
|
4784
|
-
* @param data - The API data to create this
|
|
4818
|
+
* @param data - The API data to create this message builder with
|
|
4785
4819
|
*/
|
|
4786
|
-
constructor(
|
|
4820
|
+
constructor({
|
|
4821
|
+
attachments = [],
|
|
4822
|
+
embeds = [],
|
|
4823
|
+
components = [],
|
|
4824
|
+
message_reference,
|
|
4825
|
+
poll,
|
|
4826
|
+
allowed_mentions,
|
|
4827
|
+
...data
|
|
4828
|
+
} = {}) {
|
|
4787
4829
|
this.data = {
|
|
4788
4830
|
...structuredClone(data),
|
|
4789
|
-
allowed_mentions:
|
|
4790
|
-
attachments:
|
|
4791
|
-
embeds:
|
|
4792
|
-
poll:
|
|
4793
|
-
components:
|
|
4794
|
-
message_reference:
|
|
4831
|
+
allowed_mentions: allowed_mentions && new AllowedMentionsBuilder(allowed_mentions),
|
|
4832
|
+
attachments: attachments.map((attachment) => new AttachmentBuilder(attachment)),
|
|
4833
|
+
embeds: embeds.map((embed) => new EmbedBuilder(embed)),
|
|
4834
|
+
poll: poll && new PollBuilder(poll),
|
|
4835
|
+
components: components.map((component) => createComponentBuilder(component)),
|
|
4836
|
+
message_reference: message_reference && new MessageReferenceBuilder(message_reference)
|
|
4795
4837
|
};
|
|
4796
4838
|
}
|
|
4797
4839
|
/**
|
|
@@ -4828,6 +4870,8 @@ var MessageBuilder = class {
|
|
|
4828
4870
|
}
|
|
4829
4871
|
/**
|
|
4830
4872
|
* Sets whether the message is TTS.
|
|
4873
|
+
*
|
|
4874
|
+
* @param tts - Whether the message is TTS
|
|
4831
4875
|
*/
|
|
4832
4876
|
setTTS(tts = true) {
|
|
4833
4877
|
this.data.tts = tts;
|
|
@@ -4896,6 +4940,14 @@ var MessageBuilder = class {
|
|
|
4896
4940
|
this.data.embeds.splice(start, deleteCount, ...resolved);
|
|
4897
4941
|
return this;
|
|
4898
4942
|
}
|
|
4943
|
+
/**
|
|
4944
|
+
* Sets the embeds for this message.
|
|
4945
|
+
*
|
|
4946
|
+
* @param embeds - The embeds to set
|
|
4947
|
+
*/
|
|
4948
|
+
setEmbeds(...embeds) {
|
|
4949
|
+
return this.spliceEmbeds(0, this.embeds.length, ...normalizeArray(embeds));
|
|
4950
|
+
}
|
|
4899
4951
|
/**
|
|
4900
4952
|
* Sets the allowed mentions for this message.
|
|
4901
4953
|
*
|
|
@@ -4911,7 +4963,7 @@ var MessageBuilder = class {
|
|
|
4911
4963
|
* @param updater - The function to update the allowed mentions with
|
|
4912
4964
|
*/
|
|
4913
4965
|
updateAllowedMentions(updater) {
|
|
4914
|
-
|
|
4966
|
+
updater(this.data.allowed_mentions ??= new AllowedMentionsBuilder());
|
|
4915
4967
|
return this;
|
|
4916
4968
|
}
|
|
4917
4969
|
/**
|
|
@@ -4936,7 +4988,7 @@ var MessageBuilder = class {
|
|
|
4936
4988
|
* @param updater - The function to update the message reference with
|
|
4937
4989
|
*/
|
|
4938
4990
|
updateMessageReference(updater) {
|
|
4939
|
-
|
|
4991
|
+
updater(this.data.message_reference ??= new MessageReferenceBuilder());
|
|
4940
4992
|
return this;
|
|
4941
4993
|
}
|
|
4942
4994
|
/**
|
|
@@ -5065,8 +5117,7 @@ var MessageBuilder = class {
|
|
|
5065
5117
|
* @param stickerIds - The ids of the stickers to set
|
|
5066
5118
|
*/
|
|
5067
5119
|
setStickerIds(...stickerIds) {
|
|
5068
|
-
this.data.sticker_ids
|
|
5069
|
-
return this;
|
|
5120
|
+
return this.spliceStickerIds(0, this.data.sticker_ids?.length ?? 0, ...normalizeArray(stickerIds));
|
|
5070
5121
|
}
|
|
5071
5122
|
/**
|
|
5072
5123
|
* Adds sticker ids to this message.
|
|
@@ -5117,9 +5168,7 @@ var MessageBuilder = class {
|
|
|
5117
5168
|
* @param attachments - The attachments to set
|
|
5118
5169
|
*/
|
|
5119
5170
|
setAttachments(...attachments) {
|
|
5120
|
-
|
|
5121
|
-
this.data.attachments = resolved;
|
|
5122
|
-
return this;
|
|
5171
|
+
return this.spliceAttachments(0, this.data.attachments.length, ...normalizeArray(attachments));
|
|
5123
5172
|
}
|
|
5124
5173
|
/**
|
|
5125
5174
|
* Adds attachments to this message.
|
|
@@ -5166,6 +5215,8 @@ var MessageBuilder = class {
|
|
|
5166
5215
|
}
|
|
5167
5216
|
/**
|
|
5168
5217
|
* Sets the flags for this message.
|
|
5218
|
+
*
|
|
5219
|
+
* @param flags - The flags to set
|
|
5169
5220
|
*/
|
|
5170
5221
|
setFlags(flags) {
|
|
5171
5222
|
this.data.flags = flags;
|
|
@@ -5179,7 +5230,9 @@ var MessageBuilder = class {
|
|
|
5179
5230
|
return this;
|
|
5180
5231
|
}
|
|
5181
5232
|
/**
|
|
5182
|
-
* Sets
|
|
5233
|
+
* Sets whether to enforce recent uniqueness of the nonce of this message.
|
|
5234
|
+
*
|
|
5235
|
+
* @param enforceNonce - Whether to enforce recent uniqueness of the nonce of this message
|
|
5183
5236
|
*/
|
|
5184
5237
|
setEnforceNonce(enforceNonce = true) {
|
|
5185
5238
|
this.data.enforce_nonce = enforceNonce;
|
|
@@ -5200,7 +5253,7 @@ var MessageBuilder = class {
|
|
|
5200
5253
|
* @param updater - The function to update the poll with
|
|
5201
5254
|
*/
|
|
5202
5255
|
updatePoll(updater) {
|
|
5203
|
-
|
|
5256
|
+
updater(this.data.poll ??= new PollBuilder());
|
|
5204
5257
|
return this;
|
|
5205
5258
|
}
|
|
5206
5259
|
/**
|
|
@@ -5222,12 +5275,12 @@ var MessageBuilder = class {
|
|
|
5222
5275
|
const data = {
|
|
5223
5276
|
...structuredClone(rest),
|
|
5224
5277
|
// Wherever we pass false, it's covered by the messagePredicate already
|
|
5225
|
-
poll:
|
|
5278
|
+
poll: poll?.toJSON(false),
|
|
5226
5279
|
allowed_mentions: allowed_mentions?.toJSON(false),
|
|
5227
5280
|
attachments: attachments.map((attachment) => attachment.toJSON(false)),
|
|
5228
|
-
embeds:
|
|
5281
|
+
embeds: embeds.map((embed) => embed.toJSON(false)),
|
|
5229
5282
|
// Here, the messagePredicate does specific constraints rather than using the componentPredicate
|
|
5230
|
-
components:
|
|
5283
|
+
components: components.map((component) => component.toJSON(validationOverride)),
|
|
5231
5284
|
message_reference: message_reference?.toJSON(false)
|
|
5232
5285
|
};
|
|
5233
5286
|
validate(messagePredicate, data, validationOverride);
|
|
@@ -5236,7 +5289,7 @@ var MessageBuilder = class {
|
|
|
5236
5289
|
};
|
|
5237
5290
|
|
|
5238
5291
|
// src/index.ts
|
|
5239
|
-
var version = "2.0.0-dev.
|
|
5292
|
+
var version = "2.0.0-dev.1745755498-d32aacd14";
|
|
5240
5293
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5241
5294
|
0 && (module.exports = {
|
|
5242
5295
|
ActionRowBuilder,
|