lunibee 0.2.1 → 0.2.2
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/README.md +6 -6
- package/dist/builders/attachment.d.ts +5 -1
- package/dist/builders/commands.d.ts +131 -45
- package/dist/builders/components.d.ts +164 -45
- package/dist/builders/embed.d.ts +5 -1
- package/dist/builders/index.d.ts +9 -4
- package/dist/builders/index.js +197 -105
- package/dist/builders/index.js.map +8 -8
- package/dist/core/events.d.ts +28 -12
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +183 -56
- package/dist/core/index.js.map +13 -13
- package/dist/core/permissions.d.ts +6 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +413 -168
- package/dist/index.js.map +17 -17
- package/dist/managers/index.d.ts +5 -1
- package/dist/managers/index.js +30 -14
- package/dist/managers/index.js.map +9 -9
- package/dist/managers/message.d.ts +7 -3
- package/dist/rest/index.js +2 -2
- package/dist/rest/index.js.map +1 -1
- package/dist/sharding/index.js +3 -2
- package/dist/sharding/index.js.map +4 -4
- package/dist/structures/index.d.ts +9 -3
- package/dist/structures/index.js +126 -28
- package/dist/structures/index.js.map +9 -9
- package/dist/structures/interactions.d.ts +85 -11
- package/dist/structures/resources.d.ts +11 -1
- package/dist/types/gateway.d.ts +14 -0
- package/dist/types/index.d.ts +179 -16
- package/dist/types/index.js +37 -10
- package/dist/types/index.js.map +4 -4
- package/dist/ws/index.js +2 -1
- package/dist/ws/index.js.map +4 -4
- package/package.json +14 -14
package/dist/builders/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/builders/src/embed.ts
|
|
3
|
-
class
|
|
3
|
+
class CreateEmbed {
|
|
4
4
|
#data = {};
|
|
5
5
|
setTitle(value) {
|
|
6
6
|
if (value === null)
|
|
@@ -131,6 +131,7 @@ function url(value, field) {
|
|
|
131
131
|
throw new TypeError(`${field} must be a valid URL.`, { cause: error });
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
var EmbedBuilder = CreateEmbed;
|
|
134
135
|
// packages/types/src/gateway.ts
|
|
135
136
|
var GatewayIntentBits = {
|
|
136
137
|
Guilds: 1 << 0,
|
|
@@ -184,7 +185,7 @@ var IntentBits = {
|
|
|
184
185
|
directMessagePolls: 1 << 25
|
|
185
186
|
};
|
|
186
187
|
// packages/types/src/index.ts
|
|
187
|
-
var
|
|
188
|
+
var ButtonType = {
|
|
188
189
|
Primary: 1,
|
|
189
190
|
Secondary: 2,
|
|
190
191
|
Success: 3,
|
|
@@ -194,7 +195,7 @@ var ButtonStyle = {
|
|
|
194
195
|
};
|
|
195
196
|
|
|
196
197
|
// packages/builders/src/components.ts
|
|
197
|
-
var
|
|
198
|
+
var ComponentEnum = {
|
|
198
199
|
ActionRow: 1,
|
|
199
200
|
Button: 2,
|
|
200
201
|
StringSelect: 3,
|
|
@@ -212,9 +213,9 @@ var ComponentType = {
|
|
|
212
213
|
ContentInventoryEntry: 16,
|
|
213
214
|
Container: 17
|
|
214
215
|
};
|
|
215
|
-
var
|
|
216
|
+
var TextInputType = { Short: 1, Paragraph: 2 };
|
|
216
217
|
|
|
217
|
-
class
|
|
218
|
+
class CreateActionRow {
|
|
218
219
|
#components = [];
|
|
219
220
|
addComponents(...components) {
|
|
220
221
|
if (!components.length)
|
|
@@ -233,15 +234,15 @@ class ActionRowBuilder {
|
|
|
233
234
|
if (components.length === 0)
|
|
234
235
|
throw new RangeError("An action row needs at least one component.");
|
|
235
236
|
const types = components.map((component) => component.type);
|
|
236
|
-
if (types.some((type) => type !==
|
|
237
|
+
if (types.some((type) => type !== ComponentEnum.Button) && components.length > 1)
|
|
237
238
|
throw new RangeError("A select menu or text input must be alone in its action row.");
|
|
238
|
-
return { type:
|
|
239
|
+
return { type: ComponentEnum.ActionRow, components };
|
|
239
240
|
}
|
|
240
241
|
}
|
|
241
242
|
|
|
242
|
-
class
|
|
243
|
+
class CreateStringSelect {
|
|
243
244
|
#data = {
|
|
244
|
-
type:
|
|
245
|
+
type: ComponentEnum.StringSelect
|
|
245
246
|
};
|
|
246
247
|
setCustomId(value) {
|
|
247
248
|
validateText(value, 100, "Component custom ID");
|
|
@@ -300,18 +301,18 @@ class StringSelectBuilder {
|
|
|
300
301
|
}
|
|
301
302
|
}
|
|
302
303
|
|
|
303
|
-
class
|
|
304
|
+
class CreateButton {
|
|
304
305
|
#data = {
|
|
305
|
-
type:
|
|
306
|
-
style:
|
|
306
|
+
type: ComponentEnum.Button,
|
|
307
|
+
style: ButtonType.Secondary
|
|
307
308
|
};
|
|
308
309
|
setStyle(style) {
|
|
309
310
|
const data = this.#data;
|
|
310
311
|
data.style = style;
|
|
311
|
-
if (style ===
|
|
312
|
+
if (style === ButtonType.Link) {
|
|
312
313
|
delete data.custom_id;
|
|
313
314
|
delete data.sku_id;
|
|
314
|
-
} else if (style ===
|
|
315
|
+
} else if (style === ButtonType.Premium) {
|
|
315
316
|
delete data.custom_id;
|
|
316
317
|
delete data.url;
|
|
317
318
|
delete data.label;
|
|
@@ -324,7 +325,7 @@ class ButtonBuilder {
|
|
|
324
325
|
}
|
|
325
326
|
setCustomId(value) {
|
|
326
327
|
validateText(value, 100, "Button custom ID");
|
|
327
|
-
if (this.#data.style ===
|
|
328
|
+
if (this.#data.style === ButtonType.Link)
|
|
328
329
|
throw new TypeError("Link buttons cannot use custom IDs.");
|
|
329
330
|
this.#data.custom_id = value;
|
|
330
331
|
return this;
|
|
@@ -344,13 +345,13 @@ class ButtonBuilder {
|
|
|
344
345
|
cause: error
|
|
345
346
|
});
|
|
346
347
|
}
|
|
347
|
-
this.setStyle(
|
|
348
|
+
this.setStyle(ButtonType.Link);
|
|
348
349
|
this.#data.url = url.toString();
|
|
349
350
|
return this;
|
|
350
351
|
}
|
|
351
352
|
setSKUId(skuId) {
|
|
352
353
|
validateText(skuId, 20, "Button SKU ID");
|
|
353
|
-
this.setStyle(
|
|
354
|
+
this.setStyle(ButtonType.Premium);
|
|
354
355
|
this.#data.sku_id = skuId;
|
|
355
356
|
return this;
|
|
356
357
|
}
|
|
@@ -364,12 +365,12 @@ class ButtonBuilder {
|
|
|
364
365
|
}
|
|
365
366
|
toJSON() {
|
|
366
367
|
const data = this.#data;
|
|
367
|
-
if (data.style ===
|
|
368
|
+
if (data.style === ButtonType.Link) {
|
|
368
369
|
if (!data.url)
|
|
369
370
|
throw new TypeError("Link buttons require a URL.");
|
|
370
371
|
if (data.custom_id || data.sku_id)
|
|
371
372
|
throw new TypeError("Link buttons cannot have a custom ID or SKU ID.");
|
|
372
|
-
} else if (data.style ===
|
|
373
|
+
} else if (data.style === ButtonType.Premium) {
|
|
373
374
|
if (!data.sku_id)
|
|
374
375
|
throw new TypeError("Premium buttons require a SKU ID.");
|
|
375
376
|
if (data.custom_id || data.url || data.label || data.emoji)
|
|
@@ -380,16 +381,16 @@ class ButtonBuilder {
|
|
|
380
381
|
if (data.url || data.sku_id)
|
|
381
382
|
throw new TypeError("Only link buttons have a URL and only premium buttons have a SKU ID.");
|
|
382
383
|
}
|
|
383
|
-
if (data.style !==
|
|
384
|
+
if (data.style !== ButtonType.Premium && !data.label && !data.emoji)
|
|
384
385
|
throw new TypeError("Buttons require a label or an emoji.");
|
|
385
386
|
return structuredClone(data);
|
|
386
387
|
}
|
|
387
388
|
}
|
|
388
389
|
|
|
389
|
-
class
|
|
390
|
+
class CreateEntitySelect {
|
|
390
391
|
#data;
|
|
391
392
|
constructor(type) {
|
|
392
|
-
if (type !==
|
|
393
|
+
if (type !== ComponentEnum.UserSelect && type !== ComponentEnum.RoleSelect && type !== ComponentEnum.MentionableSelect && type !== ComponentEnum.ChannelSelect)
|
|
393
394
|
throw new TypeError("Invalid select component type.");
|
|
394
395
|
this.#data = { type };
|
|
395
396
|
}
|
|
@@ -431,7 +432,7 @@ class EntitySelectBuilder {
|
|
|
431
432
|
}
|
|
432
433
|
}
|
|
433
434
|
|
|
434
|
-
class
|
|
435
|
+
class CreateModal {
|
|
435
436
|
#components = [];
|
|
436
437
|
#custom_id;
|
|
437
438
|
#title;
|
|
@@ -454,7 +455,7 @@ class ModalBuilder {
|
|
|
454
455
|
return this;
|
|
455
456
|
}
|
|
456
457
|
addTextInputs(...inputs) {
|
|
457
|
-
return this.addComponents(...inputs.map((input) => new
|
|
458
|
+
return this.addComponents(...inputs.map((input) => new CreateActionRow().addComponents(input)));
|
|
458
459
|
}
|
|
459
460
|
toJSON() {
|
|
460
461
|
if (!this.#custom_id || !this.#title)
|
|
@@ -470,10 +471,10 @@ class ModalBuilder {
|
|
|
470
471
|
}
|
|
471
472
|
}
|
|
472
473
|
|
|
473
|
-
class
|
|
474
|
+
class CreateTextInput {
|
|
474
475
|
#data = {
|
|
475
|
-
type:
|
|
476
|
-
style:
|
|
476
|
+
type: ComponentEnum.TextInput,
|
|
477
|
+
style: TextInputType.Short
|
|
477
478
|
};
|
|
478
479
|
setStyle(style) {
|
|
479
480
|
this.#data.style = style;
|
|
@@ -523,7 +524,7 @@ class TextInputBuilder {
|
|
|
523
524
|
}
|
|
524
525
|
}
|
|
525
526
|
|
|
526
|
-
class
|
|
527
|
+
class CreateContainer {
|
|
527
528
|
#components = [];
|
|
528
529
|
#accentColor;
|
|
529
530
|
#spoiler;
|
|
@@ -546,7 +547,7 @@ class ContainerBuilder {
|
|
|
546
547
|
}
|
|
547
548
|
toJSON() {
|
|
548
549
|
const data = {
|
|
549
|
-
type:
|
|
550
|
+
type: ComponentEnum.Container,
|
|
550
551
|
components: this.#components.map((c) => c.toJSON())
|
|
551
552
|
};
|
|
552
553
|
if (this.#accentColor !== undefined)
|
|
@@ -557,7 +558,7 @@ class ContainerBuilder {
|
|
|
557
558
|
}
|
|
558
559
|
}
|
|
559
560
|
|
|
560
|
-
class
|
|
561
|
+
class CreateSection {
|
|
561
562
|
#components = [];
|
|
562
563
|
#accessory;
|
|
563
564
|
addComponents(...components) {
|
|
@@ -572,14 +573,14 @@ class SectionBuilder {
|
|
|
572
573
|
}
|
|
573
574
|
toJSON() {
|
|
574
575
|
return {
|
|
575
|
-
type:
|
|
576
|
+
type: ComponentEnum.Section,
|
|
576
577
|
components: this.#components.length ? this.#components.map((c) => c.toJSON()) : undefined,
|
|
577
578
|
accessory: this.#accessory?.toJSON()
|
|
578
579
|
};
|
|
579
580
|
}
|
|
580
581
|
}
|
|
581
582
|
|
|
582
|
-
class
|
|
583
|
+
class CreateTextDisplay {
|
|
583
584
|
#content = "";
|
|
584
585
|
setContent(content) {
|
|
585
586
|
validateText(content, 4000, "Text display content");
|
|
@@ -588,13 +589,13 @@ class TextDisplayBuilder {
|
|
|
588
589
|
}
|
|
589
590
|
toJSON() {
|
|
590
591
|
return {
|
|
591
|
-
type:
|
|
592
|
+
type: ComponentEnum.TextDisplay,
|
|
592
593
|
content: this.#content
|
|
593
594
|
};
|
|
594
595
|
}
|
|
595
596
|
}
|
|
596
597
|
|
|
597
|
-
class
|
|
598
|
+
class CreateMediaGallery {
|
|
598
599
|
#items = [];
|
|
599
600
|
addItems(...items) {
|
|
600
601
|
if (!items.length) {
|
|
@@ -608,13 +609,13 @@ class MediaGalleryBuilder {
|
|
|
608
609
|
}
|
|
609
610
|
toJSON() {
|
|
610
611
|
return {
|
|
611
|
-
type:
|
|
612
|
+
type: ComponentEnum.MediaGallery,
|
|
612
613
|
items: structuredClone(this.#items)
|
|
613
614
|
};
|
|
614
615
|
}
|
|
615
616
|
}
|
|
616
617
|
|
|
617
|
-
class
|
|
618
|
+
class CreateFileComponent {
|
|
618
619
|
#url = "";
|
|
619
620
|
#spoiler;
|
|
620
621
|
setUrl(url) {
|
|
@@ -630,7 +631,7 @@ class FileComponentBuilder {
|
|
|
630
631
|
if (!this.#url)
|
|
631
632
|
throw new Error("File component must have a URL.");
|
|
632
633
|
const data = {
|
|
633
|
-
type:
|
|
634
|
+
type: ComponentEnum.File,
|
|
634
635
|
file: { url: this.#url }
|
|
635
636
|
};
|
|
636
637
|
if (this.#spoiler !== undefined)
|
|
@@ -639,7 +640,7 @@ class FileComponentBuilder {
|
|
|
639
640
|
}
|
|
640
641
|
}
|
|
641
642
|
|
|
642
|
-
class
|
|
643
|
+
class CreateSeparator {
|
|
643
644
|
#spacing;
|
|
644
645
|
#divider;
|
|
645
646
|
setSpacing(spacing) {
|
|
@@ -652,7 +653,7 @@ class SeparatorBuilder {
|
|
|
652
653
|
}
|
|
653
654
|
toJSON() {
|
|
654
655
|
const data = {
|
|
655
|
-
type:
|
|
656
|
+
type: ComponentEnum.Separator
|
|
656
657
|
};
|
|
657
658
|
if (this.#spacing !== undefined)
|
|
658
659
|
data.spacing = this.#spacing;
|
|
@@ -662,7 +663,7 @@ class SeparatorBuilder {
|
|
|
662
663
|
}
|
|
663
664
|
}
|
|
664
665
|
|
|
665
|
-
class
|
|
666
|
+
class CreateThumbnail {
|
|
666
667
|
#url = "";
|
|
667
668
|
#description;
|
|
668
669
|
#spoiler;
|
|
@@ -682,7 +683,7 @@ class ThumbnailBuilder {
|
|
|
682
683
|
}
|
|
683
684
|
toJSON() {
|
|
684
685
|
const data = {
|
|
685
|
-
type:
|
|
686
|
+
type: ComponentEnum.Thumbnail,
|
|
686
687
|
url: this.#url
|
|
687
688
|
};
|
|
688
689
|
if (this.#description !== undefined)
|
|
@@ -693,7 +694,7 @@ class ThumbnailBuilder {
|
|
|
693
694
|
}
|
|
694
695
|
}
|
|
695
696
|
|
|
696
|
-
class
|
|
697
|
+
class CreateContentInventoryEntry {
|
|
697
698
|
#id = "";
|
|
698
699
|
setId(id) {
|
|
699
700
|
validateText(id, 100, "Content inventory entry ID");
|
|
@@ -702,7 +703,7 @@ class ContentInventoryEntryBuilder {
|
|
|
702
703
|
}
|
|
703
704
|
toJSON() {
|
|
704
705
|
return {
|
|
705
|
-
type:
|
|
706
|
+
type: ComponentEnum.ContentInventoryEntry,
|
|
706
707
|
id: this.#id
|
|
707
708
|
};
|
|
708
709
|
}
|
|
@@ -723,27 +724,27 @@ function validateLength(value, field, max = 4000) {
|
|
|
723
724
|
if (!Number.isInteger(value) || value < 0 || value > max)
|
|
724
725
|
throw new RangeError(`${field} must be an integer between 0 and ${max}.`);
|
|
725
726
|
}
|
|
726
|
-
class
|
|
727
|
+
class CreateUserSelectMenu extends CreateEntitySelect {
|
|
727
728
|
constructor() {
|
|
728
|
-
super(
|
|
729
|
+
super(ComponentEnum.UserSelect);
|
|
729
730
|
}
|
|
730
731
|
}
|
|
731
732
|
|
|
732
|
-
class
|
|
733
|
+
class CreateRoleSelectMenu extends CreateEntitySelect {
|
|
733
734
|
constructor() {
|
|
734
|
-
super(
|
|
735
|
+
super(ComponentEnum.RoleSelect);
|
|
735
736
|
}
|
|
736
737
|
}
|
|
737
738
|
|
|
738
|
-
class
|
|
739
|
+
class CreateMentionableSelectMenu extends CreateEntitySelect {
|
|
739
740
|
constructor() {
|
|
740
|
-
super(
|
|
741
|
+
super(ComponentEnum.MentionableSelect);
|
|
741
742
|
}
|
|
742
743
|
}
|
|
743
744
|
|
|
744
|
-
class
|
|
745
|
+
class CreateChannelSelectMenu extends CreateEntitySelect {
|
|
745
746
|
constructor() {
|
|
746
|
-
super(
|
|
747
|
+
super(ComponentEnum.ChannelSelect);
|
|
747
748
|
}
|
|
748
749
|
}
|
|
749
750
|
function assertSelect(data) {
|
|
@@ -763,8 +764,30 @@ function componentsV2Message(components, options) {
|
|
|
763
764
|
flags: (options?.flags ?? 0) | IS_COMPONENTS_V2
|
|
764
765
|
};
|
|
765
766
|
}
|
|
767
|
+
var ButtonBuilder = CreateButton;
|
|
768
|
+
var ChannelSelectMenuBuilder = CreateChannelSelectMenu;
|
|
769
|
+
var ContainerBuilder = CreateContainer;
|
|
770
|
+
var ContentInventoryEntryBuilder = CreateContentInventoryEntry;
|
|
771
|
+
var EntitySelectBuilder = CreateEntitySelect;
|
|
772
|
+
var FileComponentBuilder = CreateFileComponent;
|
|
773
|
+
var MediaGalleryBuilder = CreateMediaGallery;
|
|
774
|
+
var MentionableSelectMenuBuilder = CreateMentionableSelectMenu;
|
|
775
|
+
var ModalBuilder = CreateModal;
|
|
776
|
+
var RoleSelectMenuBuilder = CreateRoleSelectMenu;
|
|
777
|
+
var SectionBuilder = CreateSection;
|
|
778
|
+
var SeparatorBuilder = CreateSeparator;
|
|
779
|
+
var StringSelectBuilder = CreateStringSelect;
|
|
780
|
+
var StringSelectMenuBuilder = CreateStringSelect;
|
|
781
|
+
var TextDisplayBuilder = CreateTextDisplay;
|
|
782
|
+
var TextInputBuilder = CreateTextInput;
|
|
783
|
+
var ThumbnailBuilder = CreateThumbnail;
|
|
784
|
+
var UserSelectMenuBuilder = CreateUserSelectMenu;
|
|
785
|
+
var ActionRowBuilder = CreateActionRow;
|
|
786
|
+
var ButtonStyle = ButtonType;
|
|
787
|
+
var TextInputStyle = TextInputType;
|
|
788
|
+
var ComponentType = ComponentEnum;
|
|
766
789
|
// packages/builders/src/commands.ts
|
|
767
|
-
var
|
|
790
|
+
var ApplicationCommandOptionEnum = {
|
|
768
791
|
Subcommand: 1,
|
|
769
792
|
SubcommandGroup: 2,
|
|
770
793
|
String: 3,
|
|
@@ -778,7 +801,7 @@ var ApplicationCommandOptionType = {
|
|
|
778
801
|
Attachment: 11
|
|
779
802
|
};
|
|
780
803
|
|
|
781
|
-
class
|
|
804
|
+
class CreateSlashCommand {
|
|
782
805
|
#data = { type: 1 };
|
|
783
806
|
setName(name) {
|
|
784
807
|
validateName(name, "Command name");
|
|
@@ -810,37 +833,37 @@ class SlashCommandBuilder {
|
|
|
810
833
|
return this;
|
|
811
834
|
}
|
|
812
835
|
addStringOption(configure) {
|
|
813
|
-
return this.addOption(configure(new
|
|
836
|
+
return this.addOption(configure(new CreateStringOption));
|
|
814
837
|
}
|
|
815
838
|
addIntegerOption(configure) {
|
|
816
|
-
return this.addOption(configure(new
|
|
839
|
+
return this.addOption(configure(new CreateIntegerOption));
|
|
817
840
|
}
|
|
818
841
|
addNumberOption(configure) {
|
|
819
|
-
return this.addOption(configure(new
|
|
842
|
+
return this.addOption(configure(new CreateNumberOption));
|
|
820
843
|
}
|
|
821
844
|
addBooleanOption(configure) {
|
|
822
|
-
return this.addOption(configure(new
|
|
845
|
+
return this.addOption(configure(new CreateBooleanOption));
|
|
823
846
|
}
|
|
824
847
|
addUserOption(configure) {
|
|
825
|
-
return this.addOption(configure(new
|
|
848
|
+
return this.addOption(configure(new CreateUserOption));
|
|
826
849
|
}
|
|
827
850
|
addChannelOption(configure) {
|
|
828
|
-
return this.addOption(configure(new
|
|
851
|
+
return this.addOption(configure(new CreateChannelOption));
|
|
829
852
|
}
|
|
830
853
|
addRoleOption(configure) {
|
|
831
|
-
return this.addOption(configure(new
|
|
854
|
+
return this.addOption(configure(new CreateRoleOption));
|
|
832
855
|
}
|
|
833
856
|
addMentionableOption(configure) {
|
|
834
|
-
return this.addOption(configure(new
|
|
857
|
+
return this.addOption(configure(new CreateMentionableOption));
|
|
835
858
|
}
|
|
836
859
|
addAttachmentOption(configure) {
|
|
837
|
-
return this.addOption(configure(new
|
|
860
|
+
return this.addOption(configure(new CreateAttachmentOption));
|
|
838
861
|
}
|
|
839
862
|
addSubcommand(configure) {
|
|
840
|
-
return this.addOption(configure(new
|
|
863
|
+
return this.addOption(configure(new CreateSubcommand));
|
|
841
864
|
}
|
|
842
865
|
addSubcommandGroup(configure) {
|
|
843
|
-
return this.addOption(configure(new
|
|
866
|
+
return this.addOption(configure(new CreateSubcommandGroup));
|
|
844
867
|
}
|
|
845
868
|
toJSON() {
|
|
846
869
|
return structuredClone(this.#data);
|
|
@@ -860,7 +883,7 @@ class SlashCommandBuilder {
|
|
|
860
883
|
}
|
|
861
884
|
}
|
|
862
885
|
|
|
863
|
-
class
|
|
886
|
+
class CreateCommandOption {
|
|
864
887
|
data;
|
|
865
888
|
constructor(type) {
|
|
866
889
|
this.data = { type };
|
|
@@ -888,9 +911,9 @@ class CommandOptionBuilder {
|
|
|
888
911
|
}
|
|
889
912
|
}
|
|
890
913
|
|
|
891
|
-
class
|
|
914
|
+
class CreateStringOption extends CreateCommandOption {
|
|
892
915
|
constructor() {
|
|
893
|
-
super(
|
|
916
|
+
super(ApplicationCommandOptionEnum.String);
|
|
894
917
|
}
|
|
895
918
|
addChoices(...choices) {
|
|
896
919
|
const current = this.data.choices ?? [];
|
|
@@ -924,9 +947,9 @@ class StringOptionBuilder extends CommandOptionBuilder {
|
|
|
924
947
|
}
|
|
925
948
|
}
|
|
926
949
|
|
|
927
|
-
class
|
|
950
|
+
class CreateIntegerOption extends CreateCommandOption {
|
|
928
951
|
constructor() {
|
|
929
|
-
super(
|
|
952
|
+
super(ApplicationCommandOptionEnum.Integer);
|
|
930
953
|
}
|
|
931
954
|
setMinValue(value) {
|
|
932
955
|
validateNumberRange(value, -9007199254740991, 9007199254740991, "min_value", true);
|
|
@@ -959,9 +982,9 @@ class IntegerOptionBuilder extends CommandOptionBuilder {
|
|
|
959
982
|
}
|
|
960
983
|
}
|
|
961
984
|
|
|
962
|
-
class
|
|
985
|
+
class CreateNumberOption extends CreateCommandOption {
|
|
963
986
|
constructor() {
|
|
964
|
-
super(
|
|
987
|
+
super(ApplicationCommandOptionEnum.Number);
|
|
965
988
|
}
|
|
966
989
|
setMinValue(value) {
|
|
967
990
|
validateNumberRange(value, -9007199254740991, 9007199254740991, "min_value", false);
|
|
@@ -994,39 +1017,39 @@ class NumberOptionBuilder extends CommandOptionBuilder {
|
|
|
994
1017
|
}
|
|
995
1018
|
}
|
|
996
1019
|
|
|
997
|
-
class
|
|
1020
|
+
class CreateBooleanOption extends CreateCommandOption {
|
|
998
1021
|
constructor() {
|
|
999
|
-
super(
|
|
1022
|
+
super(ApplicationCommandOptionEnum.Boolean);
|
|
1000
1023
|
}
|
|
1001
1024
|
}
|
|
1002
1025
|
|
|
1003
|
-
class
|
|
1026
|
+
class CreateUserOption extends CreateCommandOption {
|
|
1004
1027
|
constructor() {
|
|
1005
|
-
super(
|
|
1028
|
+
super(ApplicationCommandOptionEnum.User);
|
|
1006
1029
|
}
|
|
1007
1030
|
}
|
|
1008
1031
|
|
|
1009
|
-
class
|
|
1032
|
+
class CreateRoleOption extends CreateCommandOption {
|
|
1010
1033
|
constructor() {
|
|
1011
|
-
super(
|
|
1034
|
+
super(ApplicationCommandOptionEnum.Role);
|
|
1012
1035
|
}
|
|
1013
1036
|
}
|
|
1014
1037
|
|
|
1015
|
-
class
|
|
1038
|
+
class CreateMentionableOption extends CreateCommandOption {
|
|
1016
1039
|
constructor() {
|
|
1017
|
-
super(
|
|
1040
|
+
super(ApplicationCommandOptionEnum.Mentionable);
|
|
1018
1041
|
}
|
|
1019
1042
|
}
|
|
1020
1043
|
|
|
1021
|
-
class
|
|
1044
|
+
class CreateAttachmentOption extends CreateCommandOption {
|
|
1022
1045
|
constructor() {
|
|
1023
|
-
super(
|
|
1046
|
+
super(ApplicationCommandOptionEnum.Attachment);
|
|
1024
1047
|
}
|
|
1025
1048
|
}
|
|
1026
1049
|
|
|
1027
|
-
class
|
|
1050
|
+
class CreateChannelOption extends CreateCommandOption {
|
|
1028
1051
|
constructor() {
|
|
1029
|
-
super(
|
|
1052
|
+
super(ApplicationCommandOptionEnum.Channel);
|
|
1030
1053
|
}
|
|
1031
1054
|
addChannelTypes(...types) {
|
|
1032
1055
|
if (types.some((type) => !Number.isInteger(type) || type < 0))
|
|
@@ -1036,36 +1059,36 @@ class ChannelOptionBuilder extends CommandOptionBuilder {
|
|
|
1036
1059
|
}
|
|
1037
1060
|
}
|
|
1038
1061
|
|
|
1039
|
-
class
|
|
1062
|
+
class CreateSubcommand extends CreateCommandOption {
|
|
1040
1063
|
constructor() {
|
|
1041
|
-
super(
|
|
1064
|
+
super(ApplicationCommandOptionEnum.Subcommand);
|
|
1042
1065
|
}
|
|
1043
1066
|
addStringOption(configure) {
|
|
1044
|
-
return this.addChildOption(configure(new
|
|
1067
|
+
return this.addChildOption(configure(new CreateStringOption));
|
|
1045
1068
|
}
|
|
1046
1069
|
addIntegerOption(configure) {
|
|
1047
|
-
return this.addChildOption(configure(new
|
|
1070
|
+
return this.addChildOption(configure(new CreateIntegerOption));
|
|
1048
1071
|
}
|
|
1049
1072
|
addNumberOption(configure) {
|
|
1050
|
-
return this.addChildOption(configure(new
|
|
1073
|
+
return this.addChildOption(configure(new CreateNumberOption));
|
|
1051
1074
|
}
|
|
1052
1075
|
addBooleanOption(configure) {
|
|
1053
|
-
return this.addChildOption(configure(new
|
|
1076
|
+
return this.addChildOption(configure(new CreateBooleanOption));
|
|
1054
1077
|
}
|
|
1055
1078
|
addUserOption(configure) {
|
|
1056
|
-
return this.addChildOption(configure(new
|
|
1079
|
+
return this.addChildOption(configure(new CreateUserOption));
|
|
1057
1080
|
}
|
|
1058
1081
|
addChannelOption(configure) {
|
|
1059
|
-
return this.addChildOption(configure(new
|
|
1082
|
+
return this.addChildOption(configure(new CreateChannelOption));
|
|
1060
1083
|
}
|
|
1061
1084
|
addRoleOption(configure) {
|
|
1062
|
-
return this.addChildOption(configure(new
|
|
1085
|
+
return this.addChildOption(configure(new CreateRoleOption));
|
|
1063
1086
|
}
|
|
1064
1087
|
addMentionableOption(configure) {
|
|
1065
|
-
return this.addChildOption(configure(new
|
|
1088
|
+
return this.addChildOption(configure(new CreateMentionableOption));
|
|
1066
1089
|
}
|
|
1067
1090
|
addAttachmentOption(configure) {
|
|
1068
|
-
return this.addChildOption(configure(new
|
|
1091
|
+
return this.addChildOption(configure(new CreateAttachmentOption));
|
|
1069
1092
|
}
|
|
1070
1093
|
addChildOption(option) {
|
|
1071
1094
|
const options = this.data.options ?? [];
|
|
@@ -1076,7 +1099,7 @@ class SubcommandBuilder extends CommandOptionBuilder {
|
|
|
1076
1099
|
throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
|
|
1077
1100
|
if (payload.required === true && options.some((existing) => existing.required !== true))
|
|
1078
1101
|
throw new RangeError("Required subcommand options must be placed before optional options.");
|
|
1079
|
-
if (options.some((existing) => existing.type ===
|
|
1102
|
+
if (options.some((existing) => existing.type === ApplicationCommandOptionEnum.Subcommand))
|
|
1080
1103
|
throw new RangeError("Subcommands cannot contain nested subcommands.");
|
|
1081
1104
|
options.push(payload);
|
|
1082
1105
|
this.data.options = options;
|
|
@@ -1084,18 +1107,18 @@ class SubcommandBuilder extends CommandOptionBuilder {
|
|
|
1084
1107
|
}
|
|
1085
1108
|
}
|
|
1086
1109
|
|
|
1087
|
-
class
|
|
1110
|
+
class CreateSubcommandGroup extends CreateCommandOption {
|
|
1088
1111
|
constructor() {
|
|
1089
|
-
super(
|
|
1112
|
+
super(ApplicationCommandOptionEnum.SubcommandGroup);
|
|
1090
1113
|
}
|
|
1091
1114
|
addSubcommand(configure) {
|
|
1092
1115
|
const options = this.data.options ?? [];
|
|
1093
1116
|
if (options.length >= 25)
|
|
1094
1117
|
throw new RangeError("A subcommand group cannot contain more than 25 subcommands.");
|
|
1095
|
-
const payload = configure(new
|
|
1118
|
+
const payload = configure(new CreateSubcommand).toJSON();
|
|
1096
1119
|
if (options.some((existing) => existing.name === payload.name))
|
|
1097
1120
|
throw new RangeError(`Duplicate subcommand name: ${String(payload.name)}.`);
|
|
1098
|
-
if (payload.type !==
|
|
1121
|
+
if (payload.type !== ApplicationCommandOptionEnum.Subcommand)
|
|
1099
1122
|
throw new TypeError("Subcommand group children must be subcommands.");
|
|
1100
1123
|
options.push(payload);
|
|
1101
1124
|
this.data.options = options;
|
|
@@ -1119,7 +1142,7 @@ function validateNumberRange(value, minimum, maximum, field, integerOnly = true)
|
|
|
1119
1142
|
throw new RangeError(`${field} must be ${integerOnly ? "an integer" : "a number"} between ${minimum} and ${maximum}.`);
|
|
1120
1143
|
}
|
|
1121
1144
|
|
|
1122
|
-
class
|
|
1145
|
+
class CreateContextMenuCommand {
|
|
1123
1146
|
data;
|
|
1124
1147
|
constructor(type = 2) {
|
|
1125
1148
|
this.data = { type };
|
|
@@ -1148,27 +1171,54 @@ class ContextMenuCommandBuilder {
|
|
|
1148
1171
|
this.data.integration_types = [...types];
|
|
1149
1172
|
return this;
|
|
1150
1173
|
}
|
|
1174
|
+
setContexts(...contexts) {
|
|
1175
|
+
if (contexts.some((context) => context !== 0 && context !== 1 && context !== 2))
|
|
1176
|
+
throw new RangeError("Command contexts must be 0, 1 or 2.");
|
|
1177
|
+
this.data.contexts = [...contexts];
|
|
1178
|
+
return this;
|
|
1179
|
+
}
|
|
1180
|
+
setNameLocalizations(localizations) {
|
|
1181
|
+
this.data.name_localizations = localizations === null ? null : { ...localizations };
|
|
1182
|
+
return this;
|
|
1183
|
+
}
|
|
1151
1184
|
toJSON() {
|
|
1152
1185
|
return structuredClone(this.data);
|
|
1153
1186
|
}
|
|
1154
1187
|
}
|
|
1155
1188
|
|
|
1156
|
-
class
|
|
1189
|
+
class CreateUserCommand extends CreateContextMenuCommand {
|
|
1157
1190
|
constructor() {
|
|
1158
1191
|
super(2);
|
|
1159
1192
|
}
|
|
1160
1193
|
}
|
|
1161
1194
|
|
|
1162
|
-
class
|
|
1195
|
+
class CreateMessageCommand extends CreateContextMenuCommand {
|
|
1163
1196
|
constructor() {
|
|
1164
1197
|
super(3);
|
|
1165
1198
|
}
|
|
1166
1199
|
}
|
|
1200
|
+
var AttachmentOptionBuilder = CreateAttachmentOption;
|
|
1201
|
+
var BooleanOptionBuilder = CreateBooleanOption;
|
|
1202
|
+
var ChannelOptionBuilder = CreateChannelOption;
|
|
1203
|
+
var CommandOptionBuilder = CreateCommandOption;
|
|
1204
|
+
var ContextMenuCommandBuilder = CreateContextMenuCommand;
|
|
1205
|
+
var IntegerOptionBuilder = CreateIntegerOption;
|
|
1206
|
+
var MentionableOptionBuilder = CreateMentionableOption;
|
|
1207
|
+
var MessageCommandBuilder = CreateMessageCommand;
|
|
1208
|
+
var NumberOptionBuilder = CreateNumberOption;
|
|
1209
|
+
var RoleOptionBuilder = CreateRoleOption;
|
|
1210
|
+
var SlashCommandBuilder = CreateSlashCommand;
|
|
1211
|
+
var StringOptionBuilder = CreateStringOption;
|
|
1212
|
+
var SubcommandBuilder = CreateSubcommand;
|
|
1213
|
+
var SubcommandGroupBuilder = CreateSubcommandGroup;
|
|
1214
|
+
var UserCommandBuilder = CreateUserCommand;
|
|
1215
|
+
var UserOptionBuilder = CreateUserOption;
|
|
1216
|
+
var ApplicationCommandOptionType = ApplicationCommandOptionEnum;
|
|
1167
1217
|
// packages/builders/src/attachment.ts
|
|
1168
1218
|
import { readFile } from "fs/promises";
|
|
1169
1219
|
import { basename } from "path";
|
|
1170
1220
|
|
|
1171
|
-
class
|
|
1221
|
+
class CreateAttachment {
|
|
1172
1222
|
name;
|
|
1173
1223
|
description;
|
|
1174
1224
|
file;
|
|
@@ -1212,20 +1262,61 @@ class AttachmentBuilder {
|
|
|
1212
1262
|
throw new TypeError("Attachment file must be a supported binary value or file path.");
|
|
1213
1263
|
}
|
|
1214
1264
|
}
|
|
1265
|
+
var AttachmentBuilder = CreateAttachment;
|
|
1215
1266
|
export {
|
|
1216
1267
|
ActionRowBuilder,
|
|
1268
|
+
ApplicationCommandOptionEnum,
|
|
1217
1269
|
ApplicationCommandOptionType,
|
|
1218
1270
|
AttachmentBuilder,
|
|
1219
1271
|
AttachmentOptionBuilder,
|
|
1220
1272
|
BooleanOptionBuilder,
|
|
1221
1273
|
ButtonBuilder,
|
|
1222
1274
|
ButtonStyle,
|
|
1275
|
+
ButtonType,
|
|
1223
1276
|
ChannelOptionBuilder,
|
|
1224
1277
|
ChannelSelectMenuBuilder,
|
|
1278
|
+
CommandOptionBuilder,
|
|
1279
|
+
ComponentEnum,
|
|
1225
1280
|
ComponentType,
|
|
1226
1281
|
ContainerBuilder,
|
|
1227
1282
|
ContentInventoryEntryBuilder,
|
|
1228
1283
|
ContextMenuCommandBuilder,
|
|
1284
|
+
CreateActionRow,
|
|
1285
|
+
CreateAttachment,
|
|
1286
|
+
CreateAttachmentOption,
|
|
1287
|
+
CreateBooleanOption,
|
|
1288
|
+
CreateButton,
|
|
1289
|
+
CreateChannelOption,
|
|
1290
|
+
CreateChannelSelectMenu,
|
|
1291
|
+
CreateContainer,
|
|
1292
|
+
CreateContentInventoryEntry,
|
|
1293
|
+
CreateContextMenuCommand,
|
|
1294
|
+
CreateEmbed,
|
|
1295
|
+
CreateEntitySelect,
|
|
1296
|
+
CreateFileComponent,
|
|
1297
|
+
CreateIntegerOption,
|
|
1298
|
+
CreateMediaGallery,
|
|
1299
|
+
CreateMentionableOption,
|
|
1300
|
+
CreateMentionableSelectMenu,
|
|
1301
|
+
CreateMessageCommand,
|
|
1302
|
+
CreateModal,
|
|
1303
|
+
CreateNumberOption,
|
|
1304
|
+
CreateRoleOption,
|
|
1305
|
+
CreateRoleSelectMenu,
|
|
1306
|
+
CreateSection,
|
|
1307
|
+
CreateSeparator,
|
|
1308
|
+
CreateSlashCommand,
|
|
1309
|
+
CreateStringOption,
|
|
1310
|
+
CreateStringSelect,
|
|
1311
|
+
CreateStringSelect as CreateStringSelectMenu,
|
|
1312
|
+
CreateSubcommand,
|
|
1313
|
+
CreateSubcommandGroup,
|
|
1314
|
+
CreateTextDisplay,
|
|
1315
|
+
CreateTextInput,
|
|
1316
|
+
CreateThumbnail,
|
|
1317
|
+
CreateUserCommand,
|
|
1318
|
+
CreateUserOption,
|
|
1319
|
+
CreateUserSelectMenu,
|
|
1229
1320
|
EmbedBuilder,
|
|
1230
1321
|
EntitySelectBuilder,
|
|
1231
1322
|
FileComponentBuilder,
|
|
@@ -1243,12 +1334,13 @@ export {
|
|
|
1243
1334
|
SlashCommandBuilder,
|
|
1244
1335
|
StringOptionBuilder,
|
|
1245
1336
|
StringSelectBuilder,
|
|
1246
|
-
|
|
1337
|
+
StringSelectMenuBuilder,
|
|
1247
1338
|
SubcommandBuilder,
|
|
1248
1339
|
SubcommandGroupBuilder,
|
|
1249
1340
|
TextDisplayBuilder,
|
|
1250
1341
|
TextInputBuilder,
|
|
1251
1342
|
TextInputStyle,
|
|
1343
|
+
TextInputType,
|
|
1252
1344
|
ThumbnailBuilder,
|
|
1253
1345
|
UserCommandBuilder,
|
|
1254
1346
|
UserOptionBuilder,
|
|
@@ -1256,4 +1348,4 @@ export {
|
|
|
1256
1348
|
componentsV2Message
|
|
1257
1349
|
};
|
|
1258
1350
|
|
|
1259
|
-
//# debugId=
|
|
1351
|
+
//# debugId=E27BC2383A77150B64756E2164756E21
|