@discordjs/builders 2.0.0-dev.1757548920-90aac127f → 2.0.0-dev.1757851336-b66f52f9a
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 +355 -235
- package/dist/index.d.ts +355 -235
- package/dist/index.js +76 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -465,6 +465,16 @@ var BaseSelectMenuBuilder = class extends ComponentBuilder {
|
|
|
465
465
|
this.data.disabled = disabled;
|
|
466
466
|
return this;
|
|
467
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* Sets whether this select menu is required.
|
|
470
|
+
*
|
|
471
|
+
* @remarks Only for use in modals.
|
|
472
|
+
* @param required - Whether this string select menu is required
|
|
473
|
+
*/
|
|
474
|
+
setRequired(required = true) {
|
|
475
|
+
this.data.required = required;
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
468
478
|
};
|
|
469
479
|
|
|
470
480
|
// src/components/selectMenu/ChannelSelectMenu.ts
|
|
@@ -942,16 +952,6 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
942
952
|
this.data.options.splice(index, deleteCount, ...resolved);
|
|
943
953
|
return this;
|
|
944
954
|
}
|
|
945
|
-
/**
|
|
946
|
-
* Sets whether this string select menu is required.
|
|
947
|
-
*
|
|
948
|
-
* @remarks Only for use in modals.
|
|
949
|
-
* @param required - Whether this string select menu is required
|
|
950
|
-
*/
|
|
951
|
-
setRequired(required = true) {
|
|
952
|
-
this.data.required = required;
|
|
953
|
-
return this;
|
|
954
|
-
}
|
|
955
955
|
/**
|
|
956
956
|
* {@inheritDoc ComponentBuilder.toJSON}
|
|
957
957
|
*/
|
|
@@ -2375,7 +2375,14 @@ var labelPredicate2 = z6.object({
|
|
|
2375
2375
|
type: z6.literal(ComponentType22.Label),
|
|
2376
2376
|
label: z6.string().min(1).max(45),
|
|
2377
2377
|
description: z6.string().min(1).max(100).optional(),
|
|
2378
|
-
component: z6.union([
|
|
2378
|
+
component: z6.union([
|
|
2379
|
+
selectMenuStringPredicate,
|
|
2380
|
+
textInputPredicate,
|
|
2381
|
+
selectMenuUserPredicate,
|
|
2382
|
+
selectMenuRolePredicate,
|
|
2383
|
+
selectMenuMentionablePredicate,
|
|
2384
|
+
selectMenuChannelPredicate
|
|
2385
|
+
])
|
|
2379
2386
|
});
|
|
2380
2387
|
|
|
2381
2388
|
// src/components/label/Label.ts
|
|
@@ -2413,7 +2420,6 @@ var LabelBuilder = class extends ComponentBuilder {
|
|
|
2413
2420
|
const { component, ...rest } = data;
|
|
2414
2421
|
this.data = {
|
|
2415
2422
|
...structuredClone(rest),
|
|
2416
|
-
// @ts-expect-error https://github.com/discordjs/discord.js/pull/11078
|
|
2417
2423
|
component: component ? createComponentBuilder(component) : void 0,
|
|
2418
2424
|
type: ComponentType23.Label
|
|
2419
2425
|
};
|
|
@@ -2452,6 +2458,42 @@ var LabelBuilder = class extends ComponentBuilder {
|
|
|
2452
2458
|
this.data.component = resolveBuilder(input, StringSelectMenuBuilder);
|
|
2453
2459
|
return this;
|
|
2454
2460
|
}
|
|
2461
|
+
/**
|
|
2462
|
+
* Sets a user select menu component to this label.
|
|
2463
|
+
*
|
|
2464
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
2465
|
+
*/
|
|
2466
|
+
setUserSelectMenuComponent(input) {
|
|
2467
|
+
this.data.component = resolveBuilder(input, UserSelectMenuBuilder);
|
|
2468
|
+
return this;
|
|
2469
|
+
}
|
|
2470
|
+
/**
|
|
2471
|
+
* Sets a role select menu component to this label.
|
|
2472
|
+
*
|
|
2473
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
2474
|
+
*/
|
|
2475
|
+
setRoleSelectMenuComponent(input) {
|
|
2476
|
+
this.data.component = resolveBuilder(input, RoleSelectMenuBuilder);
|
|
2477
|
+
return this;
|
|
2478
|
+
}
|
|
2479
|
+
/**
|
|
2480
|
+
* Sets a mentionable select menu component to this label.
|
|
2481
|
+
*
|
|
2482
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
2483
|
+
*/
|
|
2484
|
+
setMentionableSelectMenuComponent(input) {
|
|
2485
|
+
this.data.component = resolveBuilder(input, MentionableSelectMenuBuilder);
|
|
2486
|
+
return this;
|
|
2487
|
+
}
|
|
2488
|
+
/**
|
|
2489
|
+
* Sets a channel select menu component to this label.
|
|
2490
|
+
*
|
|
2491
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
2492
|
+
*/
|
|
2493
|
+
setChannelSelectMenuComponent(input) {
|
|
2494
|
+
this.data.component = resolveBuilder(input, ChannelSelectMenuBuilder);
|
|
2495
|
+
return this;
|
|
2496
|
+
}
|
|
2455
2497
|
/**
|
|
2456
2498
|
* Sets a text input component to this label.
|
|
2457
2499
|
*
|
|
@@ -2468,6 +2510,7 @@ var LabelBuilder = class extends ComponentBuilder {
|
|
|
2468
2510
|
const { component, ...rest } = this.data;
|
|
2469
2511
|
const data = {
|
|
2470
2512
|
...structuredClone(rest),
|
|
2513
|
+
// The label predicate validates the component.
|
|
2471
2514
|
component: component?.toJSON(false)
|
|
2472
2515
|
};
|
|
2473
2516
|
validate(labelPredicate2, data, validationOverride);
|
|
@@ -3463,7 +3506,8 @@ var modalPredicate = z9.object({
|
|
|
3463
3506
|
type: z9.literal(ComponentType24.ActionRow),
|
|
3464
3507
|
components: z9.object({ type: z9.literal(ComponentType24.TextInput) }).array().length(1)
|
|
3465
3508
|
}),
|
|
3466
|
-
labelPredicate2
|
|
3509
|
+
labelPredicate2,
|
|
3510
|
+
textDisplayPredicate
|
|
3467
3511
|
]).array().min(1).max(5)
|
|
3468
3512
|
});
|
|
3469
3513
|
|
|
@@ -3491,7 +3535,6 @@ var ModalBuilder = class {
|
|
|
3491
3535
|
const { components = [], ...rest } = data;
|
|
3492
3536
|
this.data = {
|
|
3493
3537
|
...structuredClone(rest),
|
|
3494
|
-
// @ts-expect-error https://github.com/discordjs/discord.js/pull/11078
|
|
3495
3538
|
components: components.map((component) => createComponentBuilder(component))
|
|
3496
3539
|
};
|
|
3497
3540
|
}
|
|
@@ -3525,47 +3568,47 @@ var ModalBuilder = class {
|
|
|
3525
3568
|
return this;
|
|
3526
3569
|
}
|
|
3527
3570
|
/**
|
|
3528
|
-
*
|
|
3571
|
+
* Adds text display components to this modal.
|
|
3529
3572
|
*
|
|
3530
|
-
* @param components - The components to
|
|
3573
|
+
* @param components - The components to add
|
|
3531
3574
|
*/
|
|
3532
|
-
|
|
3575
|
+
addTextDisplayComponents(...components) {
|
|
3533
3576
|
const normalized = normalizeArray(components);
|
|
3534
|
-
|
|
3577
|
+
const resolved = normalized.map((row) => resolveBuilder(row, TextDisplayBuilder));
|
|
3578
|
+
this.data.components.push(...resolved);
|
|
3535
3579
|
return this;
|
|
3536
3580
|
}
|
|
3537
3581
|
/**
|
|
3538
|
-
* Removes, replaces, or inserts
|
|
3582
|
+
* Removes, replaces, or inserts components for this modal.
|
|
3539
3583
|
*
|
|
3540
3584
|
* @remarks
|
|
3541
3585
|
* This method behaves similarly
|
|
3542
3586
|
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
3543
|
-
* The maximum amount of
|
|
3587
|
+
* The maximum amount of components that can be added is 5.
|
|
3544
3588
|
*
|
|
3545
|
-
* It's useful for modifying and adjusting order of the already-existing
|
|
3589
|
+
* It's useful for modifying and adjusting order of the already-existing components of a modal.
|
|
3546
3590
|
* @example
|
|
3547
|
-
* Remove the first
|
|
3591
|
+
* Remove the first component:
|
|
3548
3592
|
* ```ts
|
|
3549
|
-
* modal.
|
|
3593
|
+
* modal.spliceComponents(0, 1);
|
|
3550
3594
|
* ```
|
|
3551
3595
|
* @example
|
|
3552
|
-
* Remove the first n
|
|
3596
|
+
* Remove the first n components:
|
|
3553
3597
|
* ```ts
|
|
3554
3598
|
* const n = 4;
|
|
3555
|
-
* modal.
|
|
3599
|
+
* modal.spliceComponents(0, n);
|
|
3556
3600
|
* ```
|
|
3557
3601
|
* @example
|
|
3558
|
-
* Remove the last
|
|
3602
|
+
* Remove the last component:
|
|
3559
3603
|
* ```ts
|
|
3560
|
-
* modal.
|
|
3604
|
+
* modal.spliceComponents(-1, 1);
|
|
3561
3605
|
* ```
|
|
3562
3606
|
* @param index - The index to start at
|
|
3563
|
-
* @param deleteCount - The number of
|
|
3564
|
-
* @param
|
|
3607
|
+
* @param deleteCount - The number of components to remove
|
|
3608
|
+
* @param components - The replacing components
|
|
3565
3609
|
*/
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
this.data.components.splice(index, deleteCount, ...resolved);
|
|
3610
|
+
spliceComponents(index, deleteCount, ...components) {
|
|
3611
|
+
this.data.components.splice(index, deleteCount, ...components);
|
|
3569
3612
|
return this;
|
|
3570
3613
|
}
|
|
3571
3614
|
/**
|
|
@@ -5428,7 +5471,7 @@ var MessageBuilder = class {
|
|
|
5428
5471
|
};
|
|
5429
5472
|
|
|
5430
5473
|
// src/index.ts
|
|
5431
|
-
var version = "2.0.0-dev.
|
|
5474
|
+
var version = "2.0.0-dev.1757851336-b66f52f9a";
|
|
5432
5475
|
export {
|
|
5433
5476
|
ActionRowBuilder,
|
|
5434
5477
|
AllowedMentionsBuilder,
|