@discordjs/builders 2.0.0-dev.1745453588-abc5d99ce → 2.0.0-dev.1745626390-8f375275c
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 +99 -37
- package/dist/index.d.ts +99 -37
- package/dist/index.js +105 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -4190,18 +4190,23 @@ import { AllowedMentionsTypes, ComponentType as ComponentType23, MessageFlags, M
|
|
|
4190
4190
|
import { z as z10 } from "zod";
|
|
4191
4191
|
var attachmentPredicate = z10.object({
|
|
4192
4192
|
id: z10.union([z10.string(), z10.number()]),
|
|
4193
|
-
description: z10.string().optional(),
|
|
4194
|
-
duration_secs: z10.number().optional(),
|
|
4195
|
-
filename: z10.string().optional(),
|
|
4196
|
-
title: z10.string().optional(),
|
|
4197
|
-
waveform: z10.string().optional()
|
|
4193
|
+
description: z10.string().max(1024).optional(),
|
|
4194
|
+
duration_secs: z10.number().max(2 ** 31 - 1).optional(),
|
|
4195
|
+
filename: z10.string().max(1024).optional(),
|
|
4196
|
+
title: z10.string().max(1024).optional(),
|
|
4197
|
+
waveform: z10.string().max(400).optional()
|
|
4198
4198
|
});
|
|
4199
4199
|
var allowedMentionPredicate = z10.object({
|
|
4200
4200
|
parse: z10.nativeEnum(AllowedMentionsTypes).array().optional(),
|
|
4201
|
-
roles: z10.string().array().optional(),
|
|
4202
|
-
users: z10.string().array().optional(),
|
|
4201
|
+
roles: z10.string().array().max(100).optional(),
|
|
4202
|
+
users: z10.string().array().max(100).optional(),
|
|
4203
4203
|
replied_user: z10.boolean().optional()
|
|
4204
|
-
})
|
|
4204
|
+
}).refine(
|
|
4205
|
+
(data) => !(data.parse?.includes(AllowedMentionsTypes.User) && data.users?.length || data.parse?.includes(AllowedMentionsTypes.Role) && data.roles?.length),
|
|
4206
|
+
{
|
|
4207
|
+
message: 'Cannot specify both parse: ["users"] and non-empty users array, or parse: ["roles"] and non-empty roles array. These are mutually exclusive'
|
|
4208
|
+
}
|
|
4209
|
+
);
|
|
4205
4210
|
var messageReferencePredicate = z10.object({
|
|
4206
4211
|
channel_id: z10.string().optional(),
|
|
4207
4212
|
fail_if_not_exists: z10.boolean().optional(),
|
|
@@ -4231,9 +4236,9 @@ var basicActionRowPredicate = z10.object({
|
|
|
4231
4236
|
}).array()
|
|
4232
4237
|
});
|
|
4233
4238
|
var messageNoComponentsV2Predicate = baseMessagePredicate.extend({
|
|
4234
|
-
content: z10.string().optional(),
|
|
4239
|
+
content: z10.string().max(2e3).optional(),
|
|
4235
4240
|
embeds: embedPredicate.array().max(10).optional(),
|
|
4236
|
-
sticker_ids: z10.array(z10.string()).
|
|
4241
|
+
sticker_ids: z10.array(z10.string()).max(3).optional(),
|
|
4237
4242
|
poll: pollPredicate.optional(),
|
|
4238
4243
|
components: basicActionRowPredicate.array().max(5).optional(),
|
|
4239
4244
|
flags: z10.number().optional().refine((flags) => {
|
|
@@ -4279,9 +4284,9 @@ var AllowedMentionsBuilder = class {
|
|
|
4279
4284
|
}
|
|
4280
4285
|
data;
|
|
4281
4286
|
/**
|
|
4282
|
-
* Creates new allowed
|
|
4287
|
+
* Creates a new allowed mentions builder from API data.
|
|
4283
4288
|
*
|
|
4284
|
-
* @param data - The API data to create this
|
|
4289
|
+
* @param data - The API data to create this allowed mentions builder with
|
|
4285
4290
|
*/
|
|
4286
4291
|
constructor(data = {}) {
|
|
4287
4292
|
this.data = structuredClone(data);
|
|
@@ -4295,6 +4300,13 @@ var AllowedMentionsBuilder = class {
|
|
|
4295
4300
|
this.data.parse = normalizeArray(parse);
|
|
4296
4301
|
return this;
|
|
4297
4302
|
}
|
|
4303
|
+
/**
|
|
4304
|
+
* Clears the parse mention types.
|
|
4305
|
+
*/
|
|
4306
|
+
clearParse() {
|
|
4307
|
+
this.data.parse = void 0;
|
|
4308
|
+
return this;
|
|
4309
|
+
}
|
|
4298
4310
|
/**
|
|
4299
4311
|
* Sets the roles to mention.
|
|
4300
4312
|
*
|
|
@@ -4328,7 +4340,7 @@ var AllowedMentionsBuilder = class {
|
|
|
4328
4340
|
* allowedMentions.spliceRoles(0, 1);
|
|
4329
4341
|
* ```
|
|
4330
4342
|
* @example
|
|
4331
|
-
* Remove the first n
|
|
4343
|
+
* Remove the first n roles:
|
|
4332
4344
|
* ```ts
|
|
4333
4345
|
* const n = 4;
|
|
4334
4346
|
* allowedMentions.spliceRoles(0, n);
|
|
@@ -4347,6 +4359,13 @@ var AllowedMentionsBuilder = class {
|
|
|
4347
4359
|
this.data.roles.splice(index, deleteCount, ...normalizeArray(roles));
|
|
4348
4360
|
return this;
|
|
4349
4361
|
}
|
|
4362
|
+
/**
|
|
4363
|
+
* Clears the roles to mention.
|
|
4364
|
+
*/
|
|
4365
|
+
clearRoles() {
|
|
4366
|
+
this.data.roles = void 0;
|
|
4367
|
+
return this;
|
|
4368
|
+
}
|
|
4350
4369
|
/**
|
|
4351
4370
|
* Sets the users to mention.
|
|
4352
4371
|
*
|
|
@@ -4380,7 +4399,7 @@ var AllowedMentionsBuilder = class {
|
|
|
4380
4399
|
* allowedMentions.spliceUsers(0, 1);
|
|
4381
4400
|
* ```
|
|
4382
4401
|
* @example
|
|
4383
|
-
* Remove the first n
|
|
4402
|
+
* Remove the first n users:
|
|
4384
4403
|
* ```ts
|
|
4385
4404
|
* const n = 4;
|
|
4386
4405
|
* allowedMentions.spliceUsers(0, n);
|
|
@@ -4400,7 +4419,16 @@ var AllowedMentionsBuilder = class {
|
|
|
4400
4419
|
return this;
|
|
4401
4420
|
}
|
|
4402
4421
|
/**
|
|
4403
|
-
*
|
|
4422
|
+
* Clears the users to mention.
|
|
4423
|
+
*/
|
|
4424
|
+
clearUsers() {
|
|
4425
|
+
this.data.users = void 0;
|
|
4426
|
+
return this;
|
|
4427
|
+
}
|
|
4428
|
+
/**
|
|
4429
|
+
* For replies, sets whether to mention the author of the message being replied to.
|
|
4430
|
+
*
|
|
4431
|
+
* @param repliedUser - Whether to mention the author of the message being replied to
|
|
4404
4432
|
*/
|
|
4405
4433
|
setRepliedUser(repliedUser = true) {
|
|
4406
4434
|
this.data.replied_user = repliedUser;
|
|
@@ -4427,29 +4455,26 @@ var AttachmentBuilder = class {
|
|
|
4427
4455
|
}
|
|
4428
4456
|
data;
|
|
4429
4457
|
/**
|
|
4430
|
-
* Creates new attachment builder from API data.
|
|
4458
|
+
* Creates a new attachment builder from API data.
|
|
4431
4459
|
*
|
|
4432
|
-
* @param data - The API data to create this attachment with
|
|
4460
|
+
* @param data - The API data to create this attachment builder with
|
|
4433
4461
|
*/
|
|
4434
4462
|
constructor(data = {}) {
|
|
4435
4463
|
this.data = structuredClone(data);
|
|
4436
4464
|
}
|
|
4437
4465
|
/**
|
|
4466
|
+
* Sets the id of the attachment.
|
|
4467
|
+
*
|
|
4438
4468
|
* @param id - The id of the attachment
|
|
4439
4469
|
*/
|
|
4440
4470
|
setId(id) {
|
|
4441
4471
|
this.data.id = id;
|
|
4442
4472
|
return this;
|
|
4443
4473
|
}
|
|
4444
|
-
/**
|
|
4445
|
-
* Clears the id of this attachment.
|
|
4446
|
-
*/
|
|
4447
|
-
clearId() {
|
|
4448
|
-
this.data.id = void 0;
|
|
4449
|
-
return this;
|
|
4450
|
-
}
|
|
4451
4474
|
/**
|
|
4452
4475
|
* Sets the description of this attachment.
|
|
4476
|
+
*
|
|
4477
|
+
* @param description - The description of the attachment
|
|
4453
4478
|
*/
|
|
4454
4479
|
setDescription(description) {
|
|
4455
4480
|
this.data.description = description;
|
|
@@ -4511,7 +4536,7 @@ var AttachmentBuilder = class {
|
|
|
4511
4536
|
return this;
|
|
4512
4537
|
}
|
|
4513
4538
|
/**
|
|
4514
|
-
* Sets the waveform of this attachment.
|
|
4539
|
+
* Sets the waveform of this attachment (audio clips).
|
|
4515
4540
|
*
|
|
4516
4541
|
* @param waveform - The waveform of the attachment
|
|
4517
4542
|
*/
|
|
@@ -4547,15 +4572,15 @@ var MessageReferenceBuilder = class {
|
|
|
4547
4572
|
}
|
|
4548
4573
|
data;
|
|
4549
4574
|
/**
|
|
4550
|
-
* Creates new
|
|
4575
|
+
* Creates a new message reference builder from API data.
|
|
4551
4576
|
*
|
|
4552
|
-
* @param data - The API data to create this
|
|
4577
|
+
* @param data - The API data to create this message reference builder with
|
|
4553
4578
|
*/
|
|
4554
4579
|
constructor(data = {}) {
|
|
4555
4580
|
this.data = structuredClone(data);
|
|
4556
4581
|
}
|
|
4557
4582
|
/**
|
|
4558
|
-
* Sets the
|
|
4583
|
+
* Sets the type of message reference this represents
|
|
4559
4584
|
*
|
|
4560
4585
|
* @param type - The type of message reference
|
|
4561
4586
|
*/
|
|
@@ -4611,6 +4636,15 @@ var MessageReferenceBuilder = class {
|
|
|
4611
4636
|
this.data.guild_id = void 0;
|
|
4612
4637
|
return this;
|
|
4613
4638
|
}
|
|
4639
|
+
/**
|
|
4640
|
+
* Sets whether to fail the message creation if the referenced message does not exist
|
|
4641
|
+
*
|
|
4642
|
+
* @param failIfNotExists - Whether to fail the message creation if the referenced message does not exist
|
|
4643
|
+
*/
|
|
4644
|
+
setFailIfNotExists(failIfNotExists = true) {
|
|
4645
|
+
this.data.fail_if_not_exists = failIfNotExists;
|
|
4646
|
+
return this;
|
|
4647
|
+
}
|
|
4614
4648
|
/**
|
|
4615
4649
|
* Serializes this builder to API-compatible JSON data.
|
|
4616
4650
|
*
|
|
@@ -4653,19 +4687,27 @@ var MessageBuilder = class {
|
|
|
4653
4687
|
return this.data.embeds;
|
|
4654
4688
|
}
|
|
4655
4689
|
/**
|
|
4656
|
-
* Creates new
|
|
4690
|
+
* Creates a new message builder from API data.
|
|
4657
4691
|
*
|
|
4658
|
-
* @param data - The API data to create this
|
|
4692
|
+
* @param data - The API data to create this message builder with
|
|
4659
4693
|
*/
|
|
4660
|
-
constructor(
|
|
4694
|
+
constructor({
|
|
4695
|
+
attachments = [],
|
|
4696
|
+
embeds = [],
|
|
4697
|
+
components = [],
|
|
4698
|
+
message_reference,
|
|
4699
|
+
poll,
|
|
4700
|
+
allowed_mentions,
|
|
4701
|
+
...data
|
|
4702
|
+
} = {}) {
|
|
4661
4703
|
this.data = {
|
|
4662
4704
|
...structuredClone(data),
|
|
4663
|
-
allowed_mentions:
|
|
4664
|
-
attachments:
|
|
4665
|
-
embeds:
|
|
4666
|
-
poll:
|
|
4667
|
-
components:
|
|
4668
|
-
message_reference:
|
|
4705
|
+
allowed_mentions: allowed_mentions && new AllowedMentionsBuilder(allowed_mentions),
|
|
4706
|
+
attachments: attachments.map((attachment) => new AttachmentBuilder(attachment)),
|
|
4707
|
+
embeds: embeds.map((embed) => new EmbedBuilder(embed)),
|
|
4708
|
+
poll: poll && new PollBuilder(poll),
|
|
4709
|
+
components: components.map((component) => createComponentBuilder(component)),
|
|
4710
|
+
message_reference: message_reference && new MessageReferenceBuilder(message_reference)
|
|
4669
4711
|
};
|
|
4670
4712
|
}
|
|
4671
4713
|
/**
|
|
@@ -4702,6 +4744,8 @@ var MessageBuilder = class {
|
|
|
4702
4744
|
}
|
|
4703
4745
|
/**
|
|
4704
4746
|
* Sets whether the message is TTS.
|
|
4747
|
+
*
|
|
4748
|
+
* @param tts - Whether the message is TTS
|
|
4705
4749
|
*/
|
|
4706
4750
|
setTTS(tts = true) {
|
|
4707
4751
|
this.data.tts = tts;
|
|
@@ -4770,6 +4814,14 @@ var MessageBuilder = class {
|
|
|
4770
4814
|
this.data.embeds.splice(start, deleteCount, ...resolved);
|
|
4771
4815
|
return this;
|
|
4772
4816
|
}
|
|
4817
|
+
/**
|
|
4818
|
+
* Sets the embeds for this message.
|
|
4819
|
+
*
|
|
4820
|
+
* @param embeds - The embeds to set
|
|
4821
|
+
*/
|
|
4822
|
+
setEmbeds(...embeds) {
|
|
4823
|
+
return this.spliceEmbeds(0, this.embeds.length, ...normalizeArray(embeds));
|
|
4824
|
+
}
|
|
4773
4825
|
/**
|
|
4774
4826
|
* Sets the allowed mentions for this message.
|
|
4775
4827
|
*
|
|
@@ -4785,7 +4837,7 @@ var MessageBuilder = class {
|
|
|
4785
4837
|
* @param updater - The function to update the allowed mentions with
|
|
4786
4838
|
*/
|
|
4787
4839
|
updateAllowedMentions(updater) {
|
|
4788
|
-
|
|
4840
|
+
updater(this.data.allowed_mentions ??= new AllowedMentionsBuilder());
|
|
4789
4841
|
return this;
|
|
4790
4842
|
}
|
|
4791
4843
|
/**
|
|
@@ -4810,7 +4862,7 @@ var MessageBuilder = class {
|
|
|
4810
4862
|
* @param updater - The function to update the message reference with
|
|
4811
4863
|
*/
|
|
4812
4864
|
updateMessageReference(updater) {
|
|
4813
|
-
|
|
4865
|
+
updater(this.data.message_reference ??= new MessageReferenceBuilder());
|
|
4814
4866
|
return this;
|
|
4815
4867
|
}
|
|
4816
4868
|
/**
|
|
@@ -4939,8 +4991,7 @@ var MessageBuilder = class {
|
|
|
4939
4991
|
* @param stickerIds - The ids of the stickers to set
|
|
4940
4992
|
*/
|
|
4941
4993
|
setStickerIds(...stickerIds) {
|
|
4942
|
-
this.data.sticker_ids
|
|
4943
|
-
return this;
|
|
4994
|
+
return this.spliceStickerIds(0, this.data.sticker_ids?.length ?? 0, ...normalizeArray(stickerIds));
|
|
4944
4995
|
}
|
|
4945
4996
|
/**
|
|
4946
4997
|
* Adds sticker ids to this message.
|
|
@@ -4991,9 +5042,7 @@ var MessageBuilder = class {
|
|
|
4991
5042
|
* @param attachments - The attachments to set
|
|
4992
5043
|
*/
|
|
4993
5044
|
setAttachments(...attachments) {
|
|
4994
|
-
|
|
4995
|
-
this.data.attachments = resolved;
|
|
4996
|
-
return this;
|
|
5045
|
+
return this.spliceAttachments(0, this.data.attachments.length, ...normalizeArray(attachments));
|
|
4997
5046
|
}
|
|
4998
5047
|
/**
|
|
4999
5048
|
* Adds attachments to this message.
|
|
@@ -5040,6 +5089,8 @@ var MessageBuilder = class {
|
|
|
5040
5089
|
}
|
|
5041
5090
|
/**
|
|
5042
5091
|
* Sets the flags for this message.
|
|
5092
|
+
*
|
|
5093
|
+
* @param flags - The flags to set
|
|
5043
5094
|
*/
|
|
5044
5095
|
setFlags(flags) {
|
|
5045
5096
|
this.data.flags = flags;
|
|
@@ -5053,7 +5104,9 @@ var MessageBuilder = class {
|
|
|
5053
5104
|
return this;
|
|
5054
5105
|
}
|
|
5055
5106
|
/**
|
|
5056
|
-
* Sets
|
|
5107
|
+
* Sets whether to enforce recent uniqueness of the nonce of this message.
|
|
5108
|
+
*
|
|
5109
|
+
* @param enforceNonce - Whether to enforce recent uniqueness of the nonce of this message
|
|
5057
5110
|
*/
|
|
5058
5111
|
setEnforceNonce(enforceNonce = true) {
|
|
5059
5112
|
this.data.enforce_nonce = enforceNonce;
|
|
@@ -5074,7 +5127,7 @@ var MessageBuilder = class {
|
|
|
5074
5127
|
* @param updater - The function to update the poll with
|
|
5075
5128
|
*/
|
|
5076
5129
|
updatePoll(updater) {
|
|
5077
|
-
|
|
5130
|
+
updater(this.data.poll ??= new PollBuilder());
|
|
5078
5131
|
return this;
|
|
5079
5132
|
}
|
|
5080
5133
|
/**
|
|
@@ -5096,12 +5149,12 @@ var MessageBuilder = class {
|
|
|
5096
5149
|
const data = {
|
|
5097
5150
|
...structuredClone(rest),
|
|
5098
5151
|
// Wherever we pass false, it's covered by the messagePredicate already
|
|
5099
|
-
poll:
|
|
5152
|
+
poll: poll?.toJSON(false),
|
|
5100
5153
|
allowed_mentions: allowed_mentions?.toJSON(false),
|
|
5101
5154
|
attachments: attachments.map((attachment) => attachment.toJSON(false)),
|
|
5102
|
-
embeds:
|
|
5155
|
+
embeds: embeds.map((embed) => embed.toJSON(false)),
|
|
5103
5156
|
// Here, the messagePredicate does specific constraints rather than using the componentPredicate
|
|
5104
|
-
components:
|
|
5157
|
+
components: components.map((component) => component.toJSON(validationOverride)),
|
|
5105
5158
|
message_reference: message_reference?.toJSON(false)
|
|
5106
5159
|
};
|
|
5107
5160
|
validate(messagePredicate, data, validationOverride);
|
|
@@ -5110,7 +5163,7 @@ var MessageBuilder = class {
|
|
|
5110
5163
|
};
|
|
5111
5164
|
|
|
5112
5165
|
// src/index.ts
|
|
5113
|
-
var version = "2.0.0-dev.
|
|
5166
|
+
var version = "2.0.0-dev.1745626390-8f375275c";
|
|
5114
5167
|
export {
|
|
5115
5168
|
ActionRowBuilder,
|
|
5116
5169
|
AllowedMentionsBuilder,
|
|
@@ -5138,6 +5191,7 @@ export {
|
|
|
5138
5191
|
ChatInputCommandUserOption,
|
|
5139
5192
|
CommandBuilder,
|
|
5140
5193
|
ComponentBuilder,
|
|
5194
|
+
ContainerBuilder,
|
|
5141
5195
|
ContextMenuCommandBuilder,
|
|
5142
5196
|
CustomIdButtonBuilder,
|
|
5143
5197
|
DangerButtonBuilder,
|