@open-discord-bots/framework 0.4.4 → 0.4.6

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/api/main.js CHANGED
@@ -44,7 +44,7 @@ export class ODMain {
44
44
  constructor(managers, project) {
45
45
  this.project = project;
46
46
  this.versions = managers.versions;
47
- this.versions.add(ODVersion.fromString("opendiscord:api", "v0.4.4"));
47
+ this.versions.add(ODVersion.fromString("opendiscord:api", "v0.4.6"));
48
48
  this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
49
49
  this.debugfile = managers.debugfile;
50
50
  this.console = managers.console;
@@ -15,7 +15,7 @@ export declare class ODComponentFactoryInstance<Component extends ODComponent<ob
15
15
  /**The root component of this factory. */
16
16
  getComponent(): Component | null;
17
17
  /**Set the root component of this factory. */
18
- setComponent(c: Component | null): void;
18
+ setComponent<SetComponent extends Component | null>(c: SetComponent): SetComponent;
19
19
  }
20
20
  /**## ODComponentFactory `class`
21
21
  * An Open Discord component factory.
@@ -192,9 +192,9 @@ export declare abstract class ODGroupComponent<Data extends object, ChildCompone
192
192
  * - `after`: insert after an existing component `referenceId` (`end` if `referenceId` is invalid)
193
193
  * - `index`: insert at a certain index `referenceIndex` (`end` if `referenceIndex` is invalid)
194
194
  */
195
- addComponent(c: ChildComponent, mode: "start" | "end"): void;
196
- addComponent(c: ChildComponent, mode: "before" | "after", referenceId: ODValidId): void;
197
- addComponent(c: ChildComponent, mode: "index", referenceIndex: number): void;
195
+ addComponent(c: ChildComponent, mode: "start" | "end"): ChildComponent;
196
+ addComponent(c: ChildComponent, mode: "before" | "after", referenceId: ODValidId): ChildComponent;
197
+ addComponent(c: ChildComponent, mode: "index", referenceIndex: number): ChildComponent;
198
198
  /**Get a component with a certain ID in this group. Returns `null` if non-existent. Also able to search for components recursively. */
199
199
  getComponent(id: ODValidId): ChildComponent | null;
200
200
  getComponent(id: ODValidId, recursive: true, recursiveLimit?: number): ODComponent<any, any, ODComponentType> | null;
@@ -234,7 +234,7 @@ export declare abstract class ODParentComponent<Data extends object, ChildCompon
234
234
  /**The child component of this parent. */
235
235
  get child(): ChildComponent | null;
236
236
  /**Set the child component of this parent. */
237
- setComponent(c: ChildComponent | null): void;
237
+ setComponent(c: ChildComponent | null): ChildComponent | null;
238
238
  }
239
239
  /**## ODMessageComponentModifier `class`
240
240
  * This is an Open Discord message component modifier.
@@ -314,13 +314,13 @@ export declare class ODMessageComponent extends ODGroupComponent<ODMessageCompon
314
314
  supressNotifications: boolean;
315
315
  }>;
316
316
  /**Enable/disable ephemeral mode. */
317
- setEphemeral(value: boolean): void;
317
+ setEphemeral(value: boolean): this;
318
318
  /**Enable supress (hide) embeds mode. */
319
- setSupressEmbeds(value: boolean): void;
319
+ setSupressEmbeds(value: boolean): this;
320
320
  /**Enable supress (hide) notifications mode. */
321
- setSupressNotifications(value: boolean): void;
321
+ setSupressNotifications(value: boolean): this;
322
322
  /**Add an additional attachment which can be used in components as `attachment://...` */
323
- addAdditionalAttachments(...attachments: discord.AttachmentBuilder[]): void;
323
+ addAdditionalAttachments(...attachments: discord.AttachmentBuilder[]): this;
324
324
  }
325
325
  /**## ODSimpleMessageComponentData `type`
326
326
  * The configurable settings/options for the `ODSimpleMessageComponent`.
@@ -370,13 +370,13 @@ export declare class ODSimpleMessageComponent extends ODGroupComponent<ODSimpleM
370
370
  supressNotifications: boolean;
371
371
  }>;
372
372
  /**Enable/disable ephemeral mode. */
373
- setEphemeral(value: boolean): void;
373
+ setEphemeral(value: boolean): this;
374
374
  /**Enable supress (hide) embeds mode. */
375
- setSupressEmbeds(value: boolean): void;
375
+ setSupressEmbeds(value: boolean): this;
376
376
  /**Enable supress (hide) notifications mode. */
377
- setSupressNotifications(value: boolean): void;
377
+ setSupressNotifications(value: boolean): this;
378
378
  /**Add an additional attachment which can be used in components as `attachment://...` */
379
- addAdditionalAttachments(...attachments: discord.AttachmentBuilder[]): void;
379
+ addAdditionalAttachments(...attachments: discord.AttachmentBuilder[]): this;
380
380
  }
381
381
  /**## ODModalComponentData `type`
382
382
  * The configurable settings/options for the `ODModalComponent`.
@@ -399,7 +399,7 @@ export declare class ODModalComponent extends ODGroupComponent<ODModalComponentD
399
399
  constructor(id: ODValidId, data?: Partial<ODModalComponentData>);
400
400
  build(): Promise<discord.ModalBuilder>;
401
401
  /**Set the title of the modal. */
402
- setTitle(title: string): void;
402
+ setTitle(title: string): this;
403
403
  /**Set the custom id of this modal. */
404
404
  setCustomId(id: string | null): this;
405
405
  }
@@ -445,9 +445,9 @@ export declare class ODContainerComponent extends ODGroupComponent<ODContainerCo
445
445
  attachments: discord.AttachmentBuilder[];
446
446
  }>;
447
447
  /**Set the accent color of this embed-like container. */
448
- setColor(color: discord.ColorResolvable | null): void;
448
+ setColor(color: discord.ColorResolvable | null): this;
449
449
  /**Mark the contents of this container as spoiler. */
450
- setSpoiler(spoiler: boolean): void;
450
+ setSpoiler(spoiler: boolean): this;
451
451
  }
452
452
  /**## ODSectionComponentData `type`
453
453
  * The configurable settings/options for the `ODSectionComponent`.
@@ -465,7 +465,7 @@ export declare class ODSectionComponent extends ODGroupComponent<ODSectionCompon
465
465
  constructor(id: ODValidId, data?: Partial<ODSectionComponentData>);
466
466
  build(): Promise<discord.SectionBuilder>;
467
467
  /**Set the accessory component shown on the right side of the section. */
468
- setAccessory(accessory: ODButtonComponent | ODThumbnailComponent | null): void;
468
+ setAccessory(accessory: ODButtonComponent | ODThumbnailComponent | null): this;
469
469
  }
470
470
  /**## ODLabelComponentData `type`
471
471
  * The configurable settings/options for the `ODLabelComponent`.
@@ -487,9 +487,9 @@ export declare class ODLabelComponent extends ODParentComponent<ODLabelComponent
487
487
  constructor(id: ODValidId, data: Partial<ODLabelComponentData>);
488
488
  build(): Promise<discord.LabelBuilder>;
489
489
  /**Set the title of the child component in the modal. */
490
- setTitle(title: string): void;
490
+ setTitle(title: string): this;
491
491
  /**Set the description of the child component in the modal. */
492
- setDescription(description: string | null): void;
492
+ setDescription(description: string | null): this;
493
493
  }
494
494
  /**## ODSeparatorComponentData `type`
495
495
  * The configurable settings/options for the `ODSeparatorComponent`.
@@ -507,9 +507,9 @@ export declare class ODSeparatorComponent extends ODComponent<ODSeparatorCompone
507
507
  constructor(id: ODValidId, data: Partial<ODSeparatorComponentData>);
508
508
  build(): Promise<discord.SeparatorBuilder>;
509
509
  /**Set whether a visual divider should be displayed in the component. (Default: `true`). */
510
- setDivider(divider: boolean): void;
510
+ setDivider(divider: boolean): this;
511
511
  /**Set the size of separator padding (Default `small`). */
512
- setSpacing(spacing: "small" | "large"): void;
512
+ setSpacing(spacing: "small" | "large"): this;
513
513
  }
514
514
  /**## ODTextComponentData `type`
515
515
  * The configurable settings/options for the `ODTextComponent`.
@@ -525,7 +525,7 @@ export declare class ODTextComponent extends ODComponent<ODTextComponentData, di
525
525
  constructor(id: ODValidId, data: Partial<ODTextComponentData>);
526
526
  build(): Promise<discord.TextDisplayBuilder>;
527
527
  /**Set the text to display. */
528
- setContent(value: string): void;
528
+ setContent(value: string): this;
529
529
  }
530
530
  /**## ODFileComponentData `type`
531
531
  * The configurable settings/options for the `ODFileComponent`.
@@ -555,15 +555,15 @@ export declare class ODFileComponent extends ODComponent<ODFileComponentData, {
555
555
  file: discord.FileBuilder;
556
556
  }>;
557
557
  /**Set the filename + extension. */
558
- setName(value: string): void;
558
+ setName(value: string): this;
559
559
  /**Set the file description. */
560
- setDescription(value: string | null): void;
560
+ setDescription(value: string | null): this;
561
561
  /**Set the text/binary contents of the file. */
562
- setContent(value: discord.BufferResolvable | null): void;
562
+ setContent(value: discord.BufferResolvable | null): this;
563
563
  /**Set a URL to an external file or image. When used, `setContent()` will be ignored! */
564
- setExternalUrl(value: string | null): void;
564
+ setExternalUrl(value: string | null): this;
565
565
  /**Mark the file as spoiler. */
566
- setSpoiler(value: boolean): void;
566
+ setSpoiler(value: boolean): this;
567
567
  }
568
568
  /**## ODGalleryComponentData `type`
569
569
  * The configurable settings/options for the `ODGalleryComponent`.
@@ -603,11 +603,11 @@ export declare class ODThumbnailComponent extends ODComponent<ODThumbnailCompone
603
603
  constructor(id: ODValidId, data: Partial<ODThumbnailComponentData>);
604
604
  build(): Promise<discord.ThumbnailBuilder>;
605
605
  /**Set the URL of the thumbnail image. */
606
- setUrl(value: string): void;
606
+ setUrl(value: string): this;
607
607
  /**Set the alt text/description of the thumbnail image. */
608
- setDescription(value: string | null): void;
608
+ setDescription(value: string | null): this;
609
609
  /**Mark the thumbnail as a spoiler. */
610
- setSpoiler(value: boolean): void;
610
+ setSpoiler(value: boolean): this;
611
611
  }
612
612
  /**## ODContentComponentData `type`
613
613
  * The configurable settings/options for the `ODContentComponent`.
@@ -627,7 +627,7 @@ export declare class ODContentComponent extends ODComponent<ODContentComponentDa
627
627
  content: string;
628
628
  }>;
629
629
  /**Set the text to display. */
630
- setContent(value: string): void;
630
+ setContent(value: string): this;
631
631
  }
632
632
  /**## ODEmbedComponentData `type`
633
633
  * The configurable settings/options for the `ODEmbedComponent`.
@@ -719,15 +719,15 @@ export declare class ODPollComponent extends ODComponent<ODPollComponentData, di
719
719
  answers: discord.PollAnswerData[];
720
720
  }>;
721
721
  /**Set the poll question. */
722
- setQuestion(question: string): void;
722
+ setQuestion(question: string): this;
723
723
  /**Set the poll duration in hours. */
724
- setDurationHours(duration: number): void;
724
+ setDurationHours(duration: number): this;
725
725
  /**Allow selecting multiple answers. */
726
- setMultiSelect(multi: boolean): void;
726
+ setMultiSelect(multi: boolean): this;
727
727
  /**Set the poll answers. */
728
- setAnswers(answers: discord.PollAnswerData[]): void;
728
+ setAnswers(answers: discord.PollAnswerData[]): this;
729
729
  /**Add additional poll answers. */
730
- addAnswers(...answers: discord.PollAnswerData[]): void;
730
+ addAnswers(...answers: discord.PollAnswerData[]): this;
731
731
  }
732
732
  /**## ODButtonComponentData `type`
733
733
  * The configurable settings/options for the `ODButtonComponent`.
@@ -20,6 +20,7 @@ export class ODComponentFactoryInstance {
20
20
  /**Set the root component of this factory. */
21
21
  setComponent(c) {
22
22
  this.rootComponent = c;
23
+ return c;
23
24
  }
24
25
  }
25
26
  /**## ODComponentFactory `class`
@@ -209,6 +210,7 @@ export class ODGroupComponent extends ODComponent {
209
210
  this.children.splice(reference, 0, c); //insert at position 'reference'
210
211
  }
211
212
  }
213
+ return c;
212
214
  }
213
215
  getComponent(id, recursive, recursiveLimit = 15) {
214
216
  const component = this.children.find((c) => c.id.value === new ODId(id).value);
@@ -308,6 +310,7 @@ export class ODParentComponent extends ODComponent {
308
310
  /**Set the child component of this parent. */
309
311
  setComponent(c) {
310
312
  this.rawChild = c;
313
+ return this.rawChild;
311
314
  }
312
315
  }
313
316
  /////////////////////////////
@@ -404,20 +407,24 @@ export class ODMessageComponent extends ODGroupComponent {
404
407
  /**Enable/disable ephemeral mode. */
405
408
  setEphemeral(value) {
406
409
  this.data.ephemeral = value;
410
+ return this;
407
411
  }
408
412
  /**Enable supress (hide) embeds mode. */
409
413
  setSupressEmbeds(value) {
410
414
  this.data.supressEmbeds = value;
415
+ return this;
411
416
  }
412
417
  /**Enable supress (hide) notifications mode. */
413
418
  setSupressNotifications(value) {
414
419
  this.data.supressNotifications = value;
420
+ return this;
415
421
  }
416
422
  /**Add an additional attachment which can be used in components as `attachment://...` */
417
423
  addAdditionalAttachments(...attachments) {
418
424
  if (!this.data.additionalAttachments)
419
425
  this.data.additionalAttachments = [];
420
426
  this.data.additionalAttachments.push(...attachments);
427
+ return this;
421
428
  }
422
429
  }
423
430
  /**## ODSimpleMessageComponent `class`
@@ -482,20 +489,24 @@ export class ODSimpleMessageComponent extends ODGroupComponent {
482
489
  /**Enable/disable ephemeral mode. */
483
490
  setEphemeral(value) {
484
491
  this.data.ephemeral = value;
492
+ return this;
485
493
  }
486
494
  /**Enable supress (hide) embeds mode. */
487
495
  setSupressEmbeds(value) {
488
496
  this.data.supressEmbeds = value;
497
+ return this;
489
498
  }
490
499
  /**Enable supress (hide) notifications mode. */
491
500
  setSupressNotifications(value) {
492
501
  this.data.supressNotifications = value;
502
+ return this;
493
503
  }
494
504
  /**Add an additional attachment which can be used in components as `attachment://...` */
495
505
  addAdditionalAttachments(...attachments) {
496
506
  if (!this.data.additionalAttachments)
497
507
  this.data.additionalAttachments = [];
498
508
  this.data.additionalAttachments.push(...attachments);
509
+ return this;
499
510
  }
500
511
  }
501
512
  /**## ODModalComponent `class`
@@ -536,6 +547,7 @@ export class ODModalComponent extends ODGroupComponent {
536
547
  /**Set the title of the modal. */
537
548
  setTitle(title) {
538
549
  this.data.title = title;
550
+ return this;
539
551
  }
540
552
  /**Set the custom id of this modal. */
541
553
  setCustomId(id) {
@@ -615,10 +627,12 @@ export class ODContainerComponent extends ODGroupComponent {
615
627
  /**Set the accent color of this embed-like container. */
616
628
  setColor(color) {
617
629
  this.data.color = color ?? undefined;
630
+ return this;
618
631
  }
619
632
  /**Mark the contents of this container as spoiler. */
620
633
  setSpoiler(spoiler) {
621
634
  this.data.spoiler = spoiler;
635
+ return this;
622
636
  }
623
637
  }
624
638
  /**## ODSectionComponent `class`
@@ -654,6 +668,7 @@ export class ODSectionComponent extends ODGroupComponent {
654
668
  /**Set the accessory component shown on the right side of the section. */
655
669
  setAccessory(accessory) {
656
670
  this.data.accessory = accessory ?? undefined;
671
+ return this;
657
672
  }
658
673
  }
659
674
  /**## ODLabelComponent `class`
@@ -680,10 +695,12 @@ export class ODLabelComponent extends ODParentComponent {
680
695
  /**Set the title of the child component in the modal. */
681
696
  setTitle(title) {
682
697
  this.data.title = title;
698
+ return this;
683
699
  }
684
700
  /**Set the description of the child component in the modal. */
685
701
  setDescription(description) {
686
702
  this.data.description = description ?? undefined;
703
+ return this;
687
704
  }
688
705
  }
689
706
  /**## ODSeparatorComponent `class`
@@ -703,10 +720,12 @@ export class ODSeparatorComponent extends ODComponent {
703
720
  /**Set whether a visual divider should be displayed in the component. (Default: `true`). */
704
721
  setDivider(divider) {
705
722
  this.data.divider = divider;
723
+ return this;
706
724
  }
707
725
  /**Set the size of separator padding (Default `small`). */
708
726
  setSpacing(spacing) {
709
727
  this.data.spacing = spacing;
728
+ return this;
710
729
  }
711
730
  }
712
731
  /**## ODTextComponent `class`
@@ -727,6 +746,7 @@ export class ODTextComponent extends ODComponent {
727
746
  /**Set the text to display. */
728
747
  setContent(value) {
729
748
  this.data.content = value;
749
+ return this;
730
750
  }
731
751
  }
732
752
  /**## ODFileComponent `class`
@@ -757,22 +777,27 @@ export class ODFileComponent extends ODComponent {
757
777
  /**Set the filename + extension. */
758
778
  setName(value) {
759
779
  this.data.name = value;
780
+ return this;
760
781
  }
761
782
  /**Set the file description. */
762
783
  setDescription(value) {
763
784
  this.data.description = value ?? undefined;
785
+ return this;
764
786
  }
765
787
  /**Set the text/binary contents of the file. */
766
788
  setContent(value) {
767
789
  this.data.content = value ?? undefined;
790
+ return this;
768
791
  }
769
792
  /**Set a URL to an external file or image. When used, `setContent()` will be ignored! */
770
793
  setExternalUrl(value) {
771
794
  this.data.externalUrl = value ?? undefined;
795
+ return this;
772
796
  }
773
797
  /**Mark the file as spoiler. */
774
798
  setSpoiler(value) {
775
799
  this.data.spoiler = value;
800
+ return this;
776
801
  }
777
802
  }
778
803
  /**## ODGalleryComponent `class`
@@ -829,14 +854,17 @@ export class ODThumbnailComponent extends ODComponent {
829
854
  /**Set the URL of the thumbnail image. */
830
855
  setUrl(value) {
831
856
  this.data.url = value;
857
+ return this;
832
858
  }
833
859
  /**Set the alt text/description of the thumbnail image. */
834
860
  setDescription(value) {
835
861
  this.data.description = value ?? undefined;
862
+ return this;
836
863
  }
837
864
  /**Mark the thumbnail as a spoiler. */
838
865
  setSpoiler(value) {
839
866
  this.data.spoiler = value;
867
+ return this;
840
868
  }
841
869
  }
842
870
  /**## ODContentComponent `class`
@@ -857,6 +885,7 @@ export class ODContentComponent extends ODComponent {
857
885
  /**Set the text to display. */
858
886
  setContent(value) {
859
887
  this.data.content = value;
888
+ return this;
860
889
  }
861
890
  }
862
891
  /**## ODEmbedComponent `class`
@@ -1009,22 +1038,27 @@ export class ODPollComponent extends ODComponent {
1009
1038
  /**Set the poll question. */
1010
1039
  setQuestion(question) {
1011
1040
  this.data.question = question;
1041
+ return this;
1012
1042
  }
1013
1043
  /**Set the poll duration in hours. */
1014
1044
  setDurationHours(duration) {
1015
1045
  this.data.durationHours = duration;
1046
+ return this;
1016
1047
  }
1017
1048
  /**Allow selecting multiple answers. */
1018
1049
  setMultiSelect(multi) {
1019
1050
  this.data.allowMultiSelect = multi;
1051
+ return this;
1020
1052
  }
1021
1053
  /**Set the poll answers. */
1022
1054
  setAnswers(answers) {
1023
1055
  this.data.answers = answers;
1056
+ return this;
1024
1057
  }
1025
1058
  /**Add additional poll answers. */
1026
1059
  addAnswers(...answers) {
1027
1060
  this.data.answers.push(...answers);
1061
+ return this;
1028
1062
  }
1029
1063
  }
1030
1064
  /**## ODButtonComponent `class`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-discord-bots/framework",
3
3
  "author": "DJj123dj",
4
- "version": "0.4.4",
4
+ "version": "0.4.6",
5
5
  "description": "The core framework of the popular open-source discord bots: Open Ticket & Open Moderation.",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",