@discordjs/builders 2.0.0-dev.1741219959-e273afbb9 → 2.0.0-dev.1741953893-09beb8a6a
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 +1335 -8
- package/dist/index.d.ts +1335 -8
- package/dist/index.js +866 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +858 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -872,7 +872,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
872
872
|
*
|
|
873
873
|
* @remarks
|
|
874
874
|
* This method behaves similarly
|
|
875
|
-
* to {@link https://developer.mozilla.org/
|
|
875
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice()}.
|
|
876
876
|
* It's useful for modifying and adjusting the order of existing options.
|
|
877
877
|
* @example
|
|
878
878
|
* Remove the first option:
|
|
@@ -1387,7 +1387,7 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
1387
1387
|
*
|
|
1388
1388
|
* @remarks
|
|
1389
1389
|
* This method behaves similarly
|
|
1390
|
-
* to {@link https://developer.mozilla.org/
|
|
1390
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
1391
1391
|
*
|
|
1392
1392
|
* It's useful for modifying and adjusting order of the already-existing components of an action row.
|
|
1393
1393
|
* @example
|
|
@@ -2042,7 +2042,7 @@ var SharedChatInputCommandOptions = class {
|
|
|
2042
2042
|
*
|
|
2043
2043
|
* @remarks
|
|
2044
2044
|
* This method behaves similarly
|
|
2045
|
-
* to {@link https://developer.mozilla.org/
|
|
2045
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
2046
2046
|
*
|
|
2047
2047
|
* It's useful for modifying and adjusting order of the already-existing options for this command.
|
|
2048
2048
|
* @example
|
|
@@ -2412,7 +2412,7 @@ var ModalBuilder = class {
|
|
|
2412
2412
|
*
|
|
2413
2413
|
* @remarks
|
|
2414
2414
|
* This method behaves similarly
|
|
2415
|
-
* to {@link https://developer.mozilla.org/
|
|
2415
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
2416
2416
|
* The maximum amount of action rows that can be added is 5.
|
|
2417
2417
|
*
|
|
2418
2418
|
* It's useful for modifying and adjusting order of the already-existing action rows of a modal.
|
|
@@ -2470,10 +2470,10 @@ __name(embedLength, "embedLength");
|
|
|
2470
2470
|
|
|
2471
2471
|
// src/messages/embed/Assertions.ts
|
|
2472
2472
|
var namePredicate3 = z7.string().max(256);
|
|
2473
|
-
var iconURLPredicate = z7.string().url().refine(refineURLPredicate(["http:", "https:", "attachment:"]), {
|
|
2474
|
-
message: "Invalid protocol for icon URL. Must be http:, https:, or attachment:"
|
|
2475
|
-
});
|
|
2476
2473
|
var URLPredicate = z7.string().url().refine(refineURLPredicate(["http:", "https:"]), { message: "Invalid protocol for URL. Must be http: or https:" });
|
|
2474
|
+
var URLWithAttachmentProtocolPredicate = z7.string().url().refine(refineURLPredicate(["http:", "https:", "attachment:"]), {
|
|
2475
|
+
message: "Invalid protocol for URL. Must be http:, https:, or attachment:"
|
|
2476
|
+
});
|
|
2477
2477
|
var embedFieldPredicate = z7.object({
|
|
2478
2478
|
name: namePredicate3,
|
|
2479
2479
|
value: z7.string().max(1024),
|
|
@@ -2481,12 +2481,12 @@ var embedFieldPredicate = z7.object({
|
|
|
2481
2481
|
});
|
|
2482
2482
|
var embedAuthorPredicate = z7.object({
|
|
2483
2483
|
name: namePredicate3.min(1),
|
|
2484
|
-
icon_url:
|
|
2484
|
+
icon_url: URLWithAttachmentProtocolPredicate.optional(),
|
|
2485
2485
|
url: URLPredicate.optional()
|
|
2486
2486
|
});
|
|
2487
2487
|
var embedFooterPredicate = z7.object({
|
|
2488
2488
|
text: z7.string().min(1).max(2048),
|
|
2489
|
-
icon_url:
|
|
2489
|
+
icon_url: URLWithAttachmentProtocolPredicate.optional()
|
|
2490
2490
|
});
|
|
2491
2491
|
var embedPredicate = z7.object({
|
|
2492
2492
|
title: namePredicate3.min(1).optional(),
|
|
@@ -2495,8 +2495,8 @@ var embedPredicate = z7.object({
|
|
|
2495
2495
|
timestamp: z7.string().optional(),
|
|
2496
2496
|
color: z7.number().int().min(0).max(16777215).optional(),
|
|
2497
2497
|
footer: embedFooterPredicate.optional(),
|
|
2498
|
-
image: z7.object({ url:
|
|
2499
|
-
thumbnail: z7.object({ url:
|
|
2498
|
+
image: z7.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
|
|
2499
|
+
thumbnail: z7.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
|
|
2500
2500
|
author: embedAuthorPredicate.optional(),
|
|
2501
2501
|
fields: z7.array(embedFieldPredicate).max(25).optional()
|
|
2502
2502
|
}).refine(
|
|
@@ -2753,7 +2753,7 @@ var EmbedBuilder = class {
|
|
|
2753
2753
|
*
|
|
2754
2754
|
* @remarks
|
|
2755
2755
|
* This method behaves similarly
|
|
2756
|
-
* to {@link https://developer.mozilla.org/
|
|
2756
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
2757
2757
|
* The maximum amount of fields that can be added is 25.
|
|
2758
2758
|
*
|
|
2759
2759
|
* It's useful for modifying and adjusting order of the already-existing fields of an embed.
|
|
@@ -3189,7 +3189,7 @@ var PollBuilder = class {
|
|
|
3189
3189
|
*
|
|
3190
3190
|
* @remarks
|
|
3191
3191
|
* This method behaves similarly
|
|
3192
|
-
* to {@link https://developer.mozilla.org/
|
|
3192
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
3193
3193
|
* The maximum amount of answers that can be added is 10.
|
|
3194
3194
|
*
|
|
3195
3195
|
* It's useful for modifying and adjusting order of the already-existing answers of a poll.
|
|
@@ -3317,16 +3317,854 @@ var PollBuilder = class {
|
|
|
3317
3317
|
}
|
|
3318
3318
|
};
|
|
3319
3319
|
|
|
3320
|
+
// src/messages/Assertions.ts
|
|
3321
|
+
import { AllowedMentionsTypes, ComponentType as ComponentType15, MessageReferenceType } from "discord-api-types/v10";
|
|
3322
|
+
import { z as z9 } from "zod";
|
|
3323
|
+
var attachmentPredicate = z9.object({
|
|
3324
|
+
id: z9.union([z9.string(), z9.number()]),
|
|
3325
|
+
description: z9.string().optional(),
|
|
3326
|
+
duration_secs: z9.number().optional(),
|
|
3327
|
+
filename: z9.string().optional(),
|
|
3328
|
+
title: z9.string().optional(),
|
|
3329
|
+
waveform: z9.string().optional()
|
|
3330
|
+
});
|
|
3331
|
+
var allowedMentionPredicate = z9.object({
|
|
3332
|
+
parse: z9.nativeEnum(AllowedMentionsTypes).array().optional(),
|
|
3333
|
+
roles: z9.string().array().optional(),
|
|
3334
|
+
users: z9.string().array().optional(),
|
|
3335
|
+
replied_user: z9.boolean().optional()
|
|
3336
|
+
});
|
|
3337
|
+
var messageReferencePredicate = z9.object({
|
|
3338
|
+
channel_id: z9.string().optional(),
|
|
3339
|
+
fail_if_not_exists: z9.boolean().optional(),
|
|
3340
|
+
guild_id: z9.string().optional(),
|
|
3341
|
+
message_id: z9.string(),
|
|
3342
|
+
type: z9.nativeEnum(MessageReferenceType).optional()
|
|
3343
|
+
});
|
|
3344
|
+
var messagePredicate = z9.object({
|
|
3345
|
+
content: z9.string().optional(),
|
|
3346
|
+
nonce: z9.union([z9.string().max(25), z9.number()]).optional(),
|
|
3347
|
+
tts: z9.boolean().optional(),
|
|
3348
|
+
embeds: embedPredicate.array().max(10).optional(),
|
|
3349
|
+
allowed_mentions: allowedMentionPredicate.optional(),
|
|
3350
|
+
message_reference: messageReferencePredicate.optional(),
|
|
3351
|
+
// Partial validation here to ensure the components are valid,
|
|
3352
|
+
// rest of the validation is done in the action row predicate
|
|
3353
|
+
components: z9.object({
|
|
3354
|
+
type: z9.literal(ComponentType15.ActionRow),
|
|
3355
|
+
components: z9.object({
|
|
3356
|
+
type: z9.union([
|
|
3357
|
+
z9.literal(ComponentType15.Button),
|
|
3358
|
+
z9.literal(ComponentType15.ChannelSelect),
|
|
3359
|
+
z9.literal(ComponentType15.MentionableSelect),
|
|
3360
|
+
z9.literal(ComponentType15.RoleSelect),
|
|
3361
|
+
z9.literal(ComponentType15.StringSelect),
|
|
3362
|
+
z9.literal(ComponentType15.UserSelect)
|
|
3363
|
+
])
|
|
3364
|
+
}).array()
|
|
3365
|
+
}).array().max(5).optional(),
|
|
3366
|
+
sticker_ids: z9.array(z9.string()).min(0).max(3).optional(),
|
|
3367
|
+
attachments: attachmentPredicate.array().max(10).optional(),
|
|
3368
|
+
flags: z9.number().optional(),
|
|
3369
|
+
enforce_nonce: z9.boolean().optional(),
|
|
3370
|
+
poll: pollPredicate.optional()
|
|
3371
|
+
}).refine(
|
|
3372
|
+
(data) => {
|
|
3373
|
+
return 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;
|
|
3374
|
+
},
|
|
3375
|
+
{ message: "Messages must have content, embeds, a poll, attachments, components, or stickers" }
|
|
3376
|
+
);
|
|
3377
|
+
|
|
3378
|
+
// src/messages/AllowedMentions.ts
|
|
3379
|
+
var AllowedMentionsBuilder = class {
|
|
3380
|
+
static {
|
|
3381
|
+
__name(this, "AllowedMentionsBuilder");
|
|
3382
|
+
}
|
|
3383
|
+
data;
|
|
3384
|
+
/**
|
|
3385
|
+
* Creates new allowed mention builder from API data.
|
|
3386
|
+
*
|
|
3387
|
+
* @param data - The API data to create this attachment with
|
|
3388
|
+
*/
|
|
3389
|
+
constructor(data = {}) {
|
|
3390
|
+
this.data = structuredClone(data);
|
|
3391
|
+
}
|
|
3392
|
+
/**
|
|
3393
|
+
* Sets the types of mentions to parse from the content.
|
|
3394
|
+
*
|
|
3395
|
+
* @param parse - The types of mentions to parse from the content
|
|
3396
|
+
*/
|
|
3397
|
+
setParse(...parse) {
|
|
3398
|
+
this.data.parse = normalizeArray(parse);
|
|
3399
|
+
return this;
|
|
3400
|
+
}
|
|
3401
|
+
/**
|
|
3402
|
+
* Sets the roles to mention.
|
|
3403
|
+
*
|
|
3404
|
+
* @param roles - The roles to mention
|
|
3405
|
+
*/
|
|
3406
|
+
setRoles(...roles) {
|
|
3407
|
+
this.data.roles = normalizeArray(roles);
|
|
3408
|
+
return this;
|
|
3409
|
+
}
|
|
3410
|
+
/**
|
|
3411
|
+
* Adds roles to mention.
|
|
3412
|
+
*
|
|
3413
|
+
* @param roles - The roles to mention
|
|
3414
|
+
*/
|
|
3415
|
+
addRoles(...roles) {
|
|
3416
|
+
this.data.roles ??= [];
|
|
3417
|
+
this.data.roles.push(...normalizeArray(roles));
|
|
3418
|
+
return this;
|
|
3419
|
+
}
|
|
3420
|
+
/**
|
|
3421
|
+
* Removes, replaces, or inserts roles.
|
|
3422
|
+
*
|
|
3423
|
+
* @remarks
|
|
3424
|
+
* This method behaves similarly
|
|
3425
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
3426
|
+
*
|
|
3427
|
+
* It's useful for modifying and adjusting order of the already-existing roles.
|
|
3428
|
+
* @example
|
|
3429
|
+
* Remove the first role:
|
|
3430
|
+
* ```ts
|
|
3431
|
+
* allowedMentions.spliceRoles(0, 1);
|
|
3432
|
+
* ```
|
|
3433
|
+
* @example
|
|
3434
|
+
* Remove the first n role:
|
|
3435
|
+
* ```ts
|
|
3436
|
+
* const n = 4;
|
|
3437
|
+
* allowedMentions.spliceRoles(0, n);
|
|
3438
|
+
* ```
|
|
3439
|
+
* @example
|
|
3440
|
+
* Remove the last role:
|
|
3441
|
+
* ```ts
|
|
3442
|
+
* allowedMentions.spliceRoles(-1, 1);
|
|
3443
|
+
* ```
|
|
3444
|
+
* @param index - The index to start at
|
|
3445
|
+
* @param deleteCount - The number of roles to remove
|
|
3446
|
+
* @param roles - The replacing role ids
|
|
3447
|
+
*/
|
|
3448
|
+
spliceRoles(index, deleteCount, ...roles) {
|
|
3449
|
+
this.data.roles ??= [];
|
|
3450
|
+
this.data.roles.splice(index, deleteCount, ...normalizeArray(roles));
|
|
3451
|
+
return this;
|
|
3452
|
+
}
|
|
3453
|
+
/**
|
|
3454
|
+
* Sets the users to mention.
|
|
3455
|
+
*
|
|
3456
|
+
* @param users - The users to mention
|
|
3457
|
+
*/
|
|
3458
|
+
setUsers(...users) {
|
|
3459
|
+
this.data.users = normalizeArray(users);
|
|
3460
|
+
return this;
|
|
3461
|
+
}
|
|
3462
|
+
/**
|
|
3463
|
+
* Adds users to mention.
|
|
3464
|
+
*
|
|
3465
|
+
* @param users - The users to mention
|
|
3466
|
+
*/
|
|
3467
|
+
addUsers(...users) {
|
|
3468
|
+
this.data.users ??= [];
|
|
3469
|
+
this.data.users.push(...normalizeArray(users));
|
|
3470
|
+
return this;
|
|
3471
|
+
}
|
|
3472
|
+
/**
|
|
3473
|
+
* Removes, replaces, or inserts users.
|
|
3474
|
+
*
|
|
3475
|
+
* @remarks
|
|
3476
|
+
* This method behaves similarly
|
|
3477
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
3478
|
+
*
|
|
3479
|
+
* It's useful for modifying and adjusting order of the already-existing users.
|
|
3480
|
+
* @example
|
|
3481
|
+
* Remove the first user:
|
|
3482
|
+
* ```ts
|
|
3483
|
+
* allowedMentions.spliceUsers(0, 1);
|
|
3484
|
+
* ```
|
|
3485
|
+
* @example
|
|
3486
|
+
* Remove the first n user:
|
|
3487
|
+
* ```ts
|
|
3488
|
+
* const n = 4;
|
|
3489
|
+
* allowedMentions.spliceUsers(0, n);
|
|
3490
|
+
* ```
|
|
3491
|
+
* @example
|
|
3492
|
+
* Remove the last user:
|
|
3493
|
+
* ```ts
|
|
3494
|
+
* allowedMentions.spliceUsers(-1, 1);
|
|
3495
|
+
* ```
|
|
3496
|
+
* @param index - The index to start at
|
|
3497
|
+
* @param deleteCount - The number of users to remove
|
|
3498
|
+
* @param users - The replacing user ids
|
|
3499
|
+
*/
|
|
3500
|
+
spliceUsers(index, deleteCount, ...users) {
|
|
3501
|
+
this.data.users ??= [];
|
|
3502
|
+
this.data.users.splice(index, deleteCount, ...normalizeArray(users));
|
|
3503
|
+
return this;
|
|
3504
|
+
}
|
|
3505
|
+
/**
|
|
3506
|
+
* For replies, sets whether to mention the author of the message being replied to
|
|
3507
|
+
*/
|
|
3508
|
+
setRepliedUser(repliedUser = true) {
|
|
3509
|
+
this.data.replied_user = repliedUser;
|
|
3510
|
+
return this;
|
|
3511
|
+
}
|
|
3512
|
+
/**
|
|
3513
|
+
* Serializes this builder to API-compatible JSON data.
|
|
3514
|
+
*
|
|
3515
|
+
* Note that by disabling validation, there is no guarantee that the resulting object will be valid.
|
|
3516
|
+
*
|
|
3517
|
+
* @param validationOverride - Force validation to run/not run regardless of your global preference
|
|
3518
|
+
*/
|
|
3519
|
+
toJSON(validationOverride) {
|
|
3520
|
+
const clone = structuredClone(this.data);
|
|
3521
|
+
validate(allowedMentionPredicate, clone, validationOverride);
|
|
3522
|
+
return clone;
|
|
3523
|
+
}
|
|
3524
|
+
};
|
|
3525
|
+
|
|
3526
|
+
// src/messages/Attachment.ts
|
|
3527
|
+
var AttachmentBuilder = class {
|
|
3528
|
+
static {
|
|
3529
|
+
__name(this, "AttachmentBuilder");
|
|
3530
|
+
}
|
|
3531
|
+
data;
|
|
3532
|
+
/**
|
|
3533
|
+
* Creates new attachment builder from API data.
|
|
3534
|
+
*
|
|
3535
|
+
* @param data - The API data to create this attachment with
|
|
3536
|
+
*/
|
|
3537
|
+
constructor(data = {}) {
|
|
3538
|
+
this.data = structuredClone(data);
|
|
3539
|
+
}
|
|
3540
|
+
/**
|
|
3541
|
+
* @param id - The id of the attachment
|
|
3542
|
+
*/
|
|
3543
|
+
setId(id) {
|
|
3544
|
+
this.data.id = id;
|
|
3545
|
+
return this;
|
|
3546
|
+
}
|
|
3547
|
+
/**
|
|
3548
|
+
* Clears the id of this attachment.
|
|
3549
|
+
*/
|
|
3550
|
+
clearId() {
|
|
3551
|
+
this.data.id = void 0;
|
|
3552
|
+
return this;
|
|
3553
|
+
}
|
|
3554
|
+
/**
|
|
3555
|
+
* Sets the description of this attachment.
|
|
3556
|
+
*/
|
|
3557
|
+
setDescription(description) {
|
|
3558
|
+
this.data.description = description;
|
|
3559
|
+
return this;
|
|
3560
|
+
}
|
|
3561
|
+
/**
|
|
3562
|
+
* Clears the description of this attachment.
|
|
3563
|
+
*/
|
|
3564
|
+
clearDescription() {
|
|
3565
|
+
this.data.description = void 0;
|
|
3566
|
+
return this;
|
|
3567
|
+
}
|
|
3568
|
+
/**
|
|
3569
|
+
* Sets the duration of this attachment (audio clips).
|
|
3570
|
+
*
|
|
3571
|
+
* @param duration - The duration of the attachment in seconds
|
|
3572
|
+
*/
|
|
3573
|
+
setDuration(duration) {
|
|
3574
|
+
this.data.duration_secs = duration;
|
|
3575
|
+
return this;
|
|
3576
|
+
}
|
|
3577
|
+
/**
|
|
3578
|
+
* Clears the duration of this attachment.
|
|
3579
|
+
*/
|
|
3580
|
+
clearDuration() {
|
|
3581
|
+
this.data.duration_secs = void 0;
|
|
3582
|
+
return this;
|
|
3583
|
+
}
|
|
3584
|
+
/**
|
|
3585
|
+
* Sets the filename of this attachment.
|
|
3586
|
+
*
|
|
3587
|
+
* @param filename - The filename of the attachment
|
|
3588
|
+
*/
|
|
3589
|
+
setFilename(filename) {
|
|
3590
|
+
this.data.filename = filename;
|
|
3591
|
+
return this;
|
|
3592
|
+
}
|
|
3593
|
+
/**
|
|
3594
|
+
* Clears the filename of this attachment.
|
|
3595
|
+
*/
|
|
3596
|
+
clearFilename() {
|
|
3597
|
+
this.data.filename = void 0;
|
|
3598
|
+
return this;
|
|
3599
|
+
}
|
|
3600
|
+
/**
|
|
3601
|
+
* Sets the title of this attachment.
|
|
3602
|
+
*
|
|
3603
|
+
* @param title - The title of the attachment
|
|
3604
|
+
*/
|
|
3605
|
+
setTitle(title) {
|
|
3606
|
+
this.data.title = title;
|
|
3607
|
+
return this;
|
|
3608
|
+
}
|
|
3609
|
+
/**
|
|
3610
|
+
* Clears the title of this attachment.
|
|
3611
|
+
*/
|
|
3612
|
+
clearTitle() {
|
|
3613
|
+
this.data.title = void 0;
|
|
3614
|
+
return this;
|
|
3615
|
+
}
|
|
3616
|
+
/**
|
|
3617
|
+
* Sets the waveform of this attachment.
|
|
3618
|
+
*
|
|
3619
|
+
* @param waveform - The waveform of the attachment
|
|
3620
|
+
*/
|
|
3621
|
+
setWaveform(waveform) {
|
|
3622
|
+
this.data.waveform = waveform;
|
|
3623
|
+
return this;
|
|
3624
|
+
}
|
|
3625
|
+
/**
|
|
3626
|
+
* Clears the waveform of this attachment.
|
|
3627
|
+
*/
|
|
3628
|
+
clearWaveform() {
|
|
3629
|
+
this.data.waveform = void 0;
|
|
3630
|
+
return this;
|
|
3631
|
+
}
|
|
3632
|
+
/**
|
|
3633
|
+
* Serializes this builder to API-compatible JSON data.
|
|
3634
|
+
*
|
|
3635
|
+
* Note that by disabling validation, there is no guarantee that the resulting object will be valid.
|
|
3636
|
+
*
|
|
3637
|
+
* @param validationOverride - Force validation to run/not run regardless of your global preference
|
|
3638
|
+
*/
|
|
3639
|
+
toJSON(validationOverride) {
|
|
3640
|
+
const clone = structuredClone(this.data);
|
|
3641
|
+
validate(attachmentPredicate, clone, validationOverride);
|
|
3642
|
+
return clone;
|
|
3643
|
+
}
|
|
3644
|
+
};
|
|
3645
|
+
|
|
3646
|
+
// src/messages/MessageReference.ts
|
|
3647
|
+
var MessageReferenceBuilder = class {
|
|
3648
|
+
static {
|
|
3649
|
+
__name(this, "MessageReferenceBuilder");
|
|
3650
|
+
}
|
|
3651
|
+
data;
|
|
3652
|
+
/**
|
|
3653
|
+
* Creates new allowed mention builder from API data.
|
|
3654
|
+
*
|
|
3655
|
+
* @param data - The API data to create this attachment with
|
|
3656
|
+
*/
|
|
3657
|
+
constructor(data = {}) {
|
|
3658
|
+
this.data = structuredClone(data);
|
|
3659
|
+
}
|
|
3660
|
+
/**
|
|
3661
|
+
* Sets the types of message reference this represents
|
|
3662
|
+
*
|
|
3663
|
+
* @param type - The type of message reference
|
|
3664
|
+
*/
|
|
3665
|
+
setType(type) {
|
|
3666
|
+
this.data.type = type;
|
|
3667
|
+
return this;
|
|
3668
|
+
}
|
|
3669
|
+
/**
|
|
3670
|
+
* Clear the type of message reference this represents
|
|
3671
|
+
*/
|
|
3672
|
+
clearType() {
|
|
3673
|
+
this.data.type = void 0;
|
|
3674
|
+
return this;
|
|
3675
|
+
}
|
|
3676
|
+
/**
|
|
3677
|
+
* Sets the id of the message being referenced
|
|
3678
|
+
*
|
|
3679
|
+
* @param messageId - The id of the message being referenced
|
|
3680
|
+
*/
|
|
3681
|
+
setMessageId(messageId) {
|
|
3682
|
+
this.data.message_id = messageId;
|
|
3683
|
+
return this;
|
|
3684
|
+
}
|
|
3685
|
+
/**
|
|
3686
|
+
* Sets the id of the channel being referenced
|
|
3687
|
+
*
|
|
3688
|
+
* @param channelId - The id of the channel being referenced
|
|
3689
|
+
*/
|
|
3690
|
+
setChannelId(channelId) {
|
|
3691
|
+
this.data.channel_id = channelId;
|
|
3692
|
+
return this;
|
|
3693
|
+
}
|
|
3694
|
+
/**
|
|
3695
|
+
* Clear the id of the channel being referenced
|
|
3696
|
+
*/
|
|
3697
|
+
clearChannelId() {
|
|
3698
|
+
this.data.channel_id = void 0;
|
|
3699
|
+
return this;
|
|
3700
|
+
}
|
|
3701
|
+
/**
|
|
3702
|
+
* Sets the id of the guild being referenced
|
|
3703
|
+
*
|
|
3704
|
+
* @param guildId - The id of the guild being referenced
|
|
3705
|
+
*/
|
|
3706
|
+
setGuildId(guildId) {
|
|
3707
|
+
this.data.guild_id = guildId;
|
|
3708
|
+
return this;
|
|
3709
|
+
}
|
|
3710
|
+
/**
|
|
3711
|
+
* Clear the id of the guild being referenced
|
|
3712
|
+
*/
|
|
3713
|
+
clearGuildId() {
|
|
3714
|
+
this.data.guild_id = void 0;
|
|
3715
|
+
return this;
|
|
3716
|
+
}
|
|
3717
|
+
/**
|
|
3718
|
+
* Serializes this builder to API-compatible JSON data.
|
|
3719
|
+
*
|
|
3720
|
+
* Note that by disabling validation, there is no guarantee that the resulting object will be valid.
|
|
3721
|
+
*
|
|
3722
|
+
* @param validationOverride - Force validation to run/not run regardless of your global preference
|
|
3723
|
+
*/
|
|
3724
|
+
toJSON(validationOverride) {
|
|
3725
|
+
const clone = structuredClone(this.data);
|
|
3726
|
+
validate(messageReferencePredicate, clone, validationOverride);
|
|
3727
|
+
return clone;
|
|
3728
|
+
}
|
|
3729
|
+
};
|
|
3730
|
+
|
|
3731
|
+
// src/messages/Message.ts
|
|
3732
|
+
var MessageBuilder = class {
|
|
3733
|
+
static {
|
|
3734
|
+
__name(this, "MessageBuilder");
|
|
3735
|
+
}
|
|
3736
|
+
/**
|
|
3737
|
+
* The API data associated with this message.
|
|
3738
|
+
*/
|
|
3739
|
+
data;
|
|
3740
|
+
/**
|
|
3741
|
+
* Gets the attachments of this message.
|
|
3742
|
+
*/
|
|
3743
|
+
get attachments() {
|
|
3744
|
+
return this.data.attachments;
|
|
3745
|
+
}
|
|
3746
|
+
/**
|
|
3747
|
+
* Gets the components of this message.
|
|
3748
|
+
*/
|
|
3749
|
+
get components() {
|
|
3750
|
+
return this.data.components;
|
|
3751
|
+
}
|
|
3752
|
+
/**
|
|
3753
|
+
* Gets the embeds of this message.
|
|
3754
|
+
*/
|
|
3755
|
+
get embeds() {
|
|
3756
|
+
return this.data.embeds;
|
|
3757
|
+
}
|
|
3758
|
+
/**
|
|
3759
|
+
* Creates new attachment builder from API data.
|
|
3760
|
+
*
|
|
3761
|
+
* @param data - The API data to create this attachment with
|
|
3762
|
+
*/
|
|
3763
|
+
constructor(data = {}) {
|
|
3764
|
+
this.data = {
|
|
3765
|
+
...structuredClone(data),
|
|
3766
|
+
allowed_mentions: data.allowed_mentions ? new AllowedMentionsBuilder(data.allowed_mentions) : void 0,
|
|
3767
|
+
attachments: data.attachments?.map((attachment) => new AttachmentBuilder(attachment)) ?? [],
|
|
3768
|
+
embeds: data.embeds?.map((embed) => new EmbedBuilder(embed)) ?? [],
|
|
3769
|
+
poll: data.poll ? new PollBuilder(data.poll) : void 0,
|
|
3770
|
+
components: data.components?.map((component) => new ActionRowBuilder(component)) ?? [],
|
|
3771
|
+
message_reference: data.message_reference ? new MessageReferenceBuilder(data.message_reference) : void 0
|
|
3772
|
+
};
|
|
3773
|
+
}
|
|
3774
|
+
/**
|
|
3775
|
+
* Sets the content of the message.
|
|
3776
|
+
*
|
|
3777
|
+
* @param content - The content to set
|
|
3778
|
+
*/
|
|
3779
|
+
setContent(content) {
|
|
3780
|
+
this.data.content = content;
|
|
3781
|
+
return this;
|
|
3782
|
+
}
|
|
3783
|
+
/**
|
|
3784
|
+
* Clears the content of the message.
|
|
3785
|
+
*/
|
|
3786
|
+
clearContent() {
|
|
3787
|
+
this.data.content = void 0;
|
|
3788
|
+
return this;
|
|
3789
|
+
}
|
|
3790
|
+
/**
|
|
3791
|
+
* Sets the nonce of the message.
|
|
3792
|
+
*
|
|
3793
|
+
* @param nonce - The nonce to set
|
|
3794
|
+
*/
|
|
3795
|
+
setNonce(nonce) {
|
|
3796
|
+
this.data.nonce = nonce;
|
|
3797
|
+
return this;
|
|
3798
|
+
}
|
|
3799
|
+
/**
|
|
3800
|
+
* Clears the nonce of the message.
|
|
3801
|
+
*/
|
|
3802
|
+
clearNonce() {
|
|
3803
|
+
this.data.nonce = void 0;
|
|
3804
|
+
return this;
|
|
3805
|
+
}
|
|
3806
|
+
/**
|
|
3807
|
+
* Sets whether the message is TTS.
|
|
3808
|
+
*/
|
|
3809
|
+
setTTS(tts = true) {
|
|
3810
|
+
this.data.tts = tts;
|
|
3811
|
+
return this;
|
|
3812
|
+
}
|
|
3813
|
+
/**
|
|
3814
|
+
* Appends embeds to this message.
|
|
3815
|
+
*
|
|
3816
|
+
* @remarks
|
|
3817
|
+
* The maximum amount of embeds that can be added is 10.
|
|
3818
|
+
* @example
|
|
3819
|
+
* Using an array:
|
|
3820
|
+
* ```ts
|
|
3821
|
+
* const embeds: APIEmbed[] = ...;
|
|
3822
|
+
* const message = new MessageBuilder()
|
|
3823
|
+
* .addEmbeds(embeds);
|
|
3824
|
+
* ```
|
|
3825
|
+
* @example
|
|
3826
|
+
* Using rest parameters (variadic):
|
|
3827
|
+
* ```ts
|
|
3828
|
+
* const message = new MessageBuilder()
|
|
3829
|
+
* .addEmbeds(
|
|
3830
|
+
* { title: 'Embed 1' },
|
|
3831
|
+
* { title: 'Embed 2' },
|
|
3832
|
+
* );
|
|
3833
|
+
* ```
|
|
3834
|
+
* @param embeds - The embeds to add
|
|
3835
|
+
*/
|
|
3836
|
+
addEmbeds(...embeds) {
|
|
3837
|
+
this.data.embeds ??= [];
|
|
3838
|
+
const resolved = normalizeArray(embeds).map((embed) => resolveBuilder(embed, EmbedBuilder));
|
|
3839
|
+
this.data.embeds.push(...resolved);
|
|
3840
|
+
return this;
|
|
3841
|
+
}
|
|
3842
|
+
/**
|
|
3843
|
+
* Removes, replaces, or inserts embeds for this message.
|
|
3844
|
+
*
|
|
3845
|
+
* @remarks
|
|
3846
|
+
* This method behaves similarly
|
|
3847
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
3848
|
+
*
|
|
3849
|
+
* It's useful for modifying and adjusting order of the already-existing embeds of a message.
|
|
3850
|
+
* @example
|
|
3851
|
+
* Remove the first embed:
|
|
3852
|
+
* ```ts
|
|
3853
|
+
* message.spliceEmbeds(0, 1);
|
|
3854
|
+
* ```
|
|
3855
|
+
* @example
|
|
3856
|
+
* Remove the first n embeds:
|
|
3857
|
+
* ```ts
|
|
3858
|
+
* const n = 4;
|
|
3859
|
+
* message.spliceEmbeds(0, n);
|
|
3860
|
+
* ```
|
|
3861
|
+
* @example
|
|
3862
|
+
* Remove the last embed:
|
|
3863
|
+
* ```ts
|
|
3864
|
+
* message.spliceEmbeds(-1, 1);
|
|
3865
|
+
* ```
|
|
3866
|
+
* @param start - The index to start at
|
|
3867
|
+
* @param deleteCount - The amount of embeds to remove
|
|
3868
|
+
* @param embeds - The embeds to insert
|
|
3869
|
+
*/
|
|
3870
|
+
spliceEmbeds(start, deleteCount, ...embeds) {
|
|
3871
|
+
this.data.embeds ??= [];
|
|
3872
|
+
const resolved = normalizeArray(embeds).map((embed) => resolveBuilder(embed, EmbedBuilder));
|
|
3873
|
+
this.data.embeds.splice(start, deleteCount, ...resolved);
|
|
3874
|
+
return this;
|
|
3875
|
+
}
|
|
3876
|
+
/**
|
|
3877
|
+
* Sets the allowed mentions for this message.
|
|
3878
|
+
*
|
|
3879
|
+
* @param allowedMentions - The allowed mentions to set
|
|
3880
|
+
*/
|
|
3881
|
+
setAllowedMentions(allowedMentions) {
|
|
3882
|
+
this.data.allowed_mentions = resolveBuilder(allowedMentions, AllowedMentionsBuilder);
|
|
3883
|
+
return this;
|
|
3884
|
+
}
|
|
3885
|
+
/**
|
|
3886
|
+
* Updates the allowed mentions for this message (and creates it if it doesn't exist)
|
|
3887
|
+
*
|
|
3888
|
+
* @param updater - The function to update the allowed mentions with
|
|
3889
|
+
*/
|
|
3890
|
+
updateAllowedMentions(updater) {
|
|
3891
|
+
this.data.allowed_mentions = updater(this.data.allowed_mentions ?? new AllowedMentionsBuilder());
|
|
3892
|
+
return this;
|
|
3893
|
+
}
|
|
3894
|
+
/**
|
|
3895
|
+
* Clears the allowed mentions for this message.
|
|
3896
|
+
*/
|
|
3897
|
+
clearAllowedMentions() {
|
|
3898
|
+
this.data.allowed_mentions = void 0;
|
|
3899
|
+
return this;
|
|
3900
|
+
}
|
|
3901
|
+
/**
|
|
3902
|
+
* Sets the message reference for this message.
|
|
3903
|
+
*
|
|
3904
|
+
* @param reference - The reference to set
|
|
3905
|
+
*/
|
|
3906
|
+
setMessageReference(reference) {
|
|
3907
|
+
this.data.message_reference = resolveBuilder(reference, MessageReferenceBuilder);
|
|
3908
|
+
return this;
|
|
3909
|
+
}
|
|
3910
|
+
/**
|
|
3911
|
+
* Updates the message reference for this message (and creates it if it doesn't exist)
|
|
3912
|
+
*
|
|
3913
|
+
* @param updater - The function to update the message reference with
|
|
3914
|
+
*/
|
|
3915
|
+
updateMessageReference(updater) {
|
|
3916
|
+
this.data.message_reference = updater(this.data.message_reference ?? new MessageReferenceBuilder());
|
|
3917
|
+
return this;
|
|
3918
|
+
}
|
|
3919
|
+
/**
|
|
3920
|
+
* Clears the message reference for this message.
|
|
3921
|
+
*/
|
|
3922
|
+
clearMessageReference() {
|
|
3923
|
+
this.data.message_reference = void 0;
|
|
3924
|
+
return this;
|
|
3925
|
+
}
|
|
3926
|
+
/**
|
|
3927
|
+
* Adds components to this message.
|
|
3928
|
+
*
|
|
3929
|
+
* @param components - The components to add
|
|
3930
|
+
*/
|
|
3931
|
+
addComponents(...components) {
|
|
3932
|
+
this.data.components ??= [];
|
|
3933
|
+
const resolved = normalizeArray(components).map((component) => resolveBuilder(component, ActionRowBuilder));
|
|
3934
|
+
this.data.components.push(...resolved);
|
|
3935
|
+
return this;
|
|
3936
|
+
}
|
|
3937
|
+
/**
|
|
3938
|
+
* Removes, replaces, or inserts components for this message.
|
|
3939
|
+
*
|
|
3940
|
+
* @remarks
|
|
3941
|
+
* This method behaves similarly
|
|
3942
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
3943
|
+
*
|
|
3944
|
+
* It's useful for modifying and adjusting order of the already-existing components of a message.
|
|
3945
|
+
* @example
|
|
3946
|
+
* Remove the first component:
|
|
3947
|
+
* ```ts
|
|
3948
|
+
* message.spliceComponents(0, 1);
|
|
3949
|
+
* ```
|
|
3950
|
+
* @example
|
|
3951
|
+
* Remove the first n components:
|
|
3952
|
+
* ```ts
|
|
3953
|
+
* const n = 4;
|
|
3954
|
+
* message.spliceComponents(0, n);
|
|
3955
|
+
* ```
|
|
3956
|
+
* @example
|
|
3957
|
+
* Remove the last component:
|
|
3958
|
+
* ```ts
|
|
3959
|
+
* message.spliceComponents(-1, 1);
|
|
3960
|
+
* ```
|
|
3961
|
+
* @param start - The index to start at
|
|
3962
|
+
* @param deleteCount - The amount of components to remove
|
|
3963
|
+
* @param components - The components to insert
|
|
3964
|
+
*/
|
|
3965
|
+
spliceComponents(start, deleteCount, ...components) {
|
|
3966
|
+
this.data.components ??= [];
|
|
3967
|
+
const resolved = normalizeArray(components).map((component) => resolveBuilder(component, ActionRowBuilder));
|
|
3968
|
+
this.data.components.splice(start, deleteCount, ...resolved);
|
|
3969
|
+
return this;
|
|
3970
|
+
}
|
|
3971
|
+
/**
|
|
3972
|
+
* Sets the components of this message.
|
|
3973
|
+
*
|
|
3974
|
+
* @param components - The components to set
|
|
3975
|
+
*/
|
|
3976
|
+
setComponents(...components) {
|
|
3977
|
+
this.data.components = normalizeArray(components).map((component) => resolveBuilder(component, ActionRowBuilder));
|
|
3978
|
+
return this;
|
|
3979
|
+
}
|
|
3980
|
+
/**
|
|
3981
|
+
* Sets the sticker ids of this message.
|
|
3982
|
+
*
|
|
3983
|
+
* @param stickerIds - The ids of the stickers to set
|
|
3984
|
+
*/
|
|
3985
|
+
setStickerIds(...stickerIds) {
|
|
3986
|
+
this.data.sticker_ids = normalizeArray(stickerIds);
|
|
3987
|
+
return this;
|
|
3988
|
+
}
|
|
3989
|
+
/**
|
|
3990
|
+
* Adds sticker ids to this message.
|
|
3991
|
+
*
|
|
3992
|
+
* @param stickerIds - The ids of the stickers to add
|
|
3993
|
+
*/
|
|
3994
|
+
addStickerIds(...stickerIds) {
|
|
3995
|
+
this.data.sticker_ids ??= [];
|
|
3996
|
+
this.data.sticker_ids.push(...normalizeArray(stickerIds));
|
|
3997
|
+
return this;
|
|
3998
|
+
}
|
|
3999
|
+
/**
|
|
4000
|
+
* Removes, replaces, or inserts sticker ids for this message.
|
|
4001
|
+
*
|
|
4002
|
+
* @remarks
|
|
4003
|
+
* This method behaves similarly
|
|
4004
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
4005
|
+
*
|
|
4006
|
+
* It's useful for modifying and adjusting order of the already-existing sticker ids of a message.
|
|
4007
|
+
* @example
|
|
4008
|
+
* Remove the first sticker id:
|
|
4009
|
+
* ```ts
|
|
4010
|
+
* message.spliceStickerIds(0, 1);
|
|
4011
|
+
* ```
|
|
4012
|
+
* @example
|
|
4013
|
+
* Remove the first n sticker ids:
|
|
4014
|
+
* ```ts
|
|
4015
|
+
* const n = 4;
|
|
4016
|
+
* message.spliceStickerIds(0, n);
|
|
4017
|
+
* ```
|
|
4018
|
+
* @example
|
|
4019
|
+
* Remove the last sticker id:
|
|
4020
|
+
* ```ts
|
|
4021
|
+
* message.spliceStickerIds(-1, 1);
|
|
4022
|
+
* ```
|
|
4023
|
+
* @param index - The index to start at
|
|
4024
|
+
* @param deleteCount - The amount of sticker ids to remove
|
|
4025
|
+
* @param stickerIds - The sticker ids to insert
|
|
4026
|
+
*/
|
|
4027
|
+
spliceStickerIds(index, deleteCount, ...stickerIds) {
|
|
4028
|
+
this.data.sticker_ids ??= [];
|
|
4029
|
+
this.data.sticker_ids.splice(index, deleteCount, ...normalizeArray(stickerIds));
|
|
4030
|
+
return this;
|
|
4031
|
+
}
|
|
4032
|
+
/**
|
|
4033
|
+
* Sets attachments for this message.
|
|
4034
|
+
*
|
|
4035
|
+
* @param attachments - The attachments to set
|
|
4036
|
+
*/
|
|
4037
|
+
setAttachments(...attachments) {
|
|
4038
|
+
const resolved = normalizeArray(attachments).map((attachment) => resolveBuilder(attachment, AttachmentBuilder));
|
|
4039
|
+
this.data.attachments = resolved;
|
|
4040
|
+
return this;
|
|
4041
|
+
}
|
|
4042
|
+
/**
|
|
4043
|
+
* Adds attachments to this message.
|
|
4044
|
+
*
|
|
4045
|
+
* @param attachments - The attachments to add
|
|
4046
|
+
*/
|
|
4047
|
+
addAttachments(...attachments) {
|
|
4048
|
+
const resolved = normalizeArray(attachments).map((attachment) => resolveBuilder(attachment, AttachmentBuilder));
|
|
4049
|
+
this.data.attachments.push(...resolved);
|
|
4050
|
+
return this;
|
|
4051
|
+
}
|
|
4052
|
+
/**
|
|
4053
|
+
* Removes, replaces, or inserts attachments for this message.
|
|
4054
|
+
*
|
|
4055
|
+
* @remarks
|
|
4056
|
+
* This method behaves similarly
|
|
4057
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
4058
|
+
*
|
|
4059
|
+
* It's useful for modifying and adjusting order of the already-existing attachments of a message.
|
|
4060
|
+
* @example
|
|
4061
|
+
* Remove the first attachment:
|
|
4062
|
+
* ```ts
|
|
4063
|
+
* message.spliceAttachments(0, 1);
|
|
4064
|
+
* ```
|
|
4065
|
+
* @example
|
|
4066
|
+
* Remove the first n attachments:
|
|
4067
|
+
* ```ts
|
|
4068
|
+
* const n = 4;
|
|
4069
|
+
* message.spliceAttachments(0, n);
|
|
4070
|
+
* ```
|
|
4071
|
+
* @example
|
|
4072
|
+
* Remove the last attachment:
|
|
4073
|
+
* ```ts
|
|
4074
|
+
* message.spliceAttachments(-1, 1);
|
|
4075
|
+
* ```
|
|
4076
|
+
* @param start - The index to start at
|
|
4077
|
+
* @param deleteCount - The amount of attachments to remove
|
|
4078
|
+
* @param attachments - The attachments to insert
|
|
4079
|
+
*/
|
|
4080
|
+
spliceAttachments(start, deleteCount, ...attachments) {
|
|
4081
|
+
const resolved = normalizeArray(attachments).map((attachment) => resolveBuilder(attachment, AttachmentBuilder));
|
|
4082
|
+
this.data.attachments.splice(start, deleteCount, ...resolved);
|
|
4083
|
+
return this;
|
|
4084
|
+
}
|
|
4085
|
+
/**
|
|
4086
|
+
* Sets the flags for this message.
|
|
4087
|
+
*/
|
|
4088
|
+
setFlags(flags) {
|
|
4089
|
+
this.data.flags = flags;
|
|
4090
|
+
return this;
|
|
4091
|
+
}
|
|
4092
|
+
/**
|
|
4093
|
+
* Clears the flags for this message.
|
|
4094
|
+
*/
|
|
4095
|
+
clearFlags() {
|
|
4096
|
+
this.data.flags = void 0;
|
|
4097
|
+
return this;
|
|
4098
|
+
}
|
|
4099
|
+
/**
|
|
4100
|
+
* Sets `enforce_nonce` for this message.
|
|
4101
|
+
*/
|
|
4102
|
+
setEnforceNonce(enforceNonce = true) {
|
|
4103
|
+
this.data.enforce_nonce = enforceNonce;
|
|
4104
|
+
return this;
|
|
4105
|
+
}
|
|
4106
|
+
/**
|
|
4107
|
+
* Sets the poll for this message.
|
|
4108
|
+
*
|
|
4109
|
+
* @param poll - The poll to set
|
|
4110
|
+
*/
|
|
4111
|
+
setPoll(poll) {
|
|
4112
|
+
this.data.poll = resolveBuilder(poll, PollBuilder);
|
|
4113
|
+
return this;
|
|
4114
|
+
}
|
|
4115
|
+
/**
|
|
4116
|
+
* Updates the poll for this message (and creates it if it doesn't exist)
|
|
4117
|
+
*
|
|
4118
|
+
* @param updater - The function to update the poll with
|
|
4119
|
+
*/
|
|
4120
|
+
updatePoll(updater) {
|
|
4121
|
+
this.data.poll = updater(this.data.poll ?? new PollBuilder());
|
|
4122
|
+
return this;
|
|
4123
|
+
}
|
|
4124
|
+
/**
|
|
4125
|
+
* Clears the poll for this message.
|
|
4126
|
+
*/
|
|
4127
|
+
clearPoll() {
|
|
4128
|
+
this.data.poll = void 0;
|
|
4129
|
+
return this;
|
|
4130
|
+
}
|
|
4131
|
+
/**
|
|
4132
|
+
* Serializes this builder to API-compatible JSON data.
|
|
4133
|
+
*
|
|
4134
|
+
* Note that by disabling validation, there is no guarantee that the resulting object will be valid.
|
|
4135
|
+
*
|
|
4136
|
+
* @param validationOverride - Force validation to run/not run regardless of your global preference
|
|
4137
|
+
*/
|
|
4138
|
+
toJSON(validationOverride) {
|
|
4139
|
+
const { poll, allowed_mentions, attachments, embeds, components, message_reference, ...rest } = this.data;
|
|
4140
|
+
const data = {
|
|
4141
|
+
...structuredClone(rest),
|
|
4142
|
+
// Wherever we pass false, it's covered by the messagePredicate already
|
|
4143
|
+
poll: this.data.poll?.toJSON(false),
|
|
4144
|
+
allowed_mentions: allowed_mentions?.toJSON(false),
|
|
4145
|
+
attachments: attachments.map((attachment) => attachment.toJSON(false)),
|
|
4146
|
+
embeds: this.data.embeds.map((embed) => embed.toJSON(false)),
|
|
4147
|
+
// Here, the messagePredicate does specific constraints rather than using the componentPredicate
|
|
4148
|
+
components: this.data.components?.map((component) => component.toJSON(validationOverride)),
|
|
4149
|
+
message_reference: message_reference?.toJSON(false)
|
|
4150
|
+
};
|
|
4151
|
+
validate(messagePredicate, data, validationOverride);
|
|
4152
|
+
return data;
|
|
4153
|
+
}
|
|
4154
|
+
};
|
|
4155
|
+
|
|
3320
4156
|
// src/index.ts
|
|
3321
|
-
var version = "2.0.0-dev.
|
|
4157
|
+
var version = "2.0.0-dev.1741953893-09beb8a6a";
|
|
3322
4158
|
export {
|
|
3323
4159
|
ActionRowBuilder,
|
|
4160
|
+
AllowedMentionsBuilder,
|
|
3324
4161
|
ApplicationCommandNumericOptionMinMaxValueMixin,
|
|
3325
4162
|
ApplicationCommandOptionAllowedChannelTypes,
|
|
3326
4163
|
ApplicationCommandOptionBase,
|
|
3327
4164
|
ApplicationCommandOptionChannelTypesMixin,
|
|
3328
4165
|
ApplicationCommandOptionWithAutocompleteMixin,
|
|
3329
4166
|
ApplicationCommandOptionWithChoicesMixin,
|
|
4167
|
+
AttachmentBuilder,
|
|
3330
4168
|
BaseButtonBuilder,
|
|
3331
4169
|
BaseSelectMenuBuilder,
|
|
3332
4170
|
ChannelSelectMenuBuilder,
|
|
@@ -3354,7 +4192,9 @@ export {
|
|
|
3354
4192
|
EmojiOrLabelButtonMixin,
|
|
3355
4193
|
LinkButtonBuilder,
|
|
3356
4194
|
MentionableSelectMenuBuilder,
|
|
4195
|
+
MessageBuilder,
|
|
3357
4196
|
MessageContextCommandBuilder,
|
|
4197
|
+
MessageReferenceBuilder,
|
|
3358
4198
|
ModalBuilder,
|
|
3359
4199
|
PollAnswerBuilder,
|
|
3360
4200
|
PollAnswerMediaBuilder,
|
|
@@ -3376,6 +4216,8 @@ export {
|
|
|
3376
4216
|
UserContextCommandBuilder,
|
|
3377
4217
|
UserSelectMenuBuilder,
|
|
3378
4218
|
actionRowPredicate,
|
|
4219
|
+
allowedMentionPredicate,
|
|
4220
|
+
attachmentPredicate,
|
|
3379
4221
|
basicOptionPredicate,
|
|
3380
4222
|
buttonPredicate,
|
|
3381
4223
|
channelOptionPredicate,
|
|
@@ -3397,6 +4239,8 @@ export {
|
|
|
3397
4239
|
localeMapPredicate,
|
|
3398
4240
|
memberPermissionsPredicate,
|
|
3399
4241
|
messageCommandPredicate,
|
|
4242
|
+
messagePredicate,
|
|
4243
|
+
messageReferencePredicate,
|
|
3400
4244
|
modalPredicate,
|
|
3401
4245
|
normalizeArray,
|
|
3402
4246
|
numberOptionPredicate,
|