@open-discord-bots/framework 0.1.1 → 0.2.0

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.
Files changed (78) hide show
  1. package/dist/api/modules/action.d.ts +26 -4
  2. package/dist/api/modules/action.js +16 -0
  3. package/dist/api/modules/base.d.ts +12 -2
  4. package/dist/api/modules/base.js +11 -1
  5. package/dist/api/modules/builder.d.ts +117 -21
  6. package/dist/api/modules/builder.js +72 -0
  7. package/dist/api/modules/checker.d.ts +111 -15
  8. package/dist/api/modules/checker.js +201 -9
  9. package/dist/api/modules/client.d.ts +45 -22
  10. package/dist/api/modules/client.js +58 -34
  11. package/dist/api/modules/code.d.ts +11 -1
  12. package/dist/api/modules/code.js +9 -0
  13. package/dist/api/modules/config.d.ts +15 -5
  14. package/dist/api/modules/config.js +9 -0
  15. package/dist/api/modules/console.d.ts +11 -1
  16. package/dist/api/modules/console.js +9 -0
  17. package/dist/api/modules/cooldown.d.ts +11 -1
  18. package/dist/api/modules/cooldown.js +9 -0
  19. package/dist/api/modules/database.d.ts +36 -4
  20. package/dist/api/modules/database.js +9 -17
  21. package/dist/api/modules/event.d.ts +10 -1
  22. package/dist/api/modules/event.js +6 -0
  23. package/dist/api/modules/flag.d.ts +11 -1
  24. package/dist/api/modules/flag.js +9 -0
  25. package/dist/api/modules/helpmenu.d.ts +22 -2
  26. package/dist/api/modules/helpmenu.js +18 -0
  27. package/dist/api/modules/language.d.ts +15 -1
  28. package/dist/api/modules/language.js +9 -4
  29. package/dist/api/modules/permission.d.ts +11 -1
  30. package/dist/api/modules/permission.js +9 -0
  31. package/dist/api/modules/plugin.d.ts +23 -3
  32. package/dist/api/modules/plugin.js +18 -0
  33. package/dist/api/modules/post.d.ts +11 -1
  34. package/dist/api/modules/post.js +9 -0
  35. package/dist/api/modules/progressbar.d.ts +24 -3
  36. package/dist/api/modules/progressbar.js +19 -0
  37. package/dist/api/modules/responder.d.ts +105 -21
  38. package/dist/api/modules/responder.js +54 -0
  39. package/dist/api/modules/session.d.ts +11 -1
  40. package/dist/api/modules/session.js +9 -0
  41. package/dist/api/modules/startscreen.d.ts +17 -7
  42. package/dist/api/modules/startscreen.js +9 -0
  43. package/dist/api/modules/stat.d.ts +42 -8
  44. package/dist/api/modules/stat.js +18 -4
  45. package/dist/api/modules/verifybar.d.ts +18 -4
  46. package/dist/api/modules/verifybar.js +9 -0
  47. package/dist/api/modules/worker.d.ts +7 -1
  48. package/dist/api/modules/worker.js +9 -0
  49. package/dist/index.d.ts +1 -0
  50. package/dist/index.js +3 -1
  51. package/dist/utilities/index.js +1 -0
  52. package/package.json +1 -1
  53. package/src/api/main.ts +10 -10
  54. package/src/api/modules/action.ts +37 -4
  55. package/src/api/modules/base.ts +30 -3
  56. package/src/api/modules/builder.ts +226 -21
  57. package/src/api/modules/checker.ts +292 -17
  58. package/src/api/modules/client.ts +129 -43
  59. package/src/api/modules/code.ts +27 -1
  60. package/src/api/modules/config.ts +33 -7
  61. package/src/api/modules/console.ts +27 -1
  62. package/src/api/modules/cooldown.ts +27 -1
  63. package/src/api/modules/database.ts +55 -4
  64. package/src/api/modules/event.ts +24 -1
  65. package/src/api/modules/flag.ts +27 -1
  66. package/src/api/modules/helpmenu.ts +55 -2
  67. package/src/api/modules/language.ts +35 -1
  68. package/src/api/modules/permission.ts +27 -1
  69. package/src/api/modules/plugin.ts +55 -3
  70. package/src/api/modules/post.ts +27 -1
  71. package/src/api/modules/progressbar.ts +56 -3
  72. package/src/api/modules/responder.ts +184 -21
  73. package/src/api/modules/session.ts +27 -1
  74. package/src/api/modules/startscreen.ts +33 -7
  75. package/src/api/modules/stat.ts +79 -8
  76. package/src/api/modules/verifybar.ts +31 -5
  77. package/src/api/modules/worker.ts +22 -1
  78. package/src/utilities/index.ts +1 -0
@@ -5,6 +5,11 @@ import { ODSystemError, ODManager, ODManagerData, ODValidId } from "./base"
5
5
  import { ODDebugger } from "./console"
6
6
  import readline from "readline"
7
7
 
8
+ /**## ODProgressBarRendererManagerIdConstraint `type`
9
+ * The constraint/layout for id mappings/interfaces of the `ODProgressBarRendererManager` class.
10
+ */
11
+ export type ODProgressBarRendererManagerIdConstraint = Record<string,ODProgressBarRenderer<{}>>
12
+
8
13
  /**## ODProgressBarRendererManager `class`
9
14
  * This is an Open Discord progress bar renderer manager.
10
15
  *
@@ -12,12 +17,38 @@ import readline from "readline"
12
17
  *
13
18
  * A renderer is a function which will try to visualize the progress bar in the console.
14
19
  */
15
- export class ODProgressBarRendererManager extends ODManager<ODProgressBarRenderer<{}>> {
20
+ export class ODProgressBarRendererManager<IdList extends ODProgressBarRendererManagerIdConstraint = ODProgressBarRendererManagerIdConstraint> extends ODManager<ODProgressBarRenderer<{}>> {
16
21
  constructor(debug:ODDebugger){
17
22
  super(debug,"progress bar renderer")
18
23
  }
24
+
25
+ get<RendererId extends keyof IdList>(id:RendererId): IdList[RendererId]
26
+ get(id:ODValidId): ODProgressBarRenderer<{}>|null
27
+
28
+ get(id:ODValidId): ODProgressBarRenderer<{}>|null {
29
+ return super.get(id)
30
+ }
31
+
32
+ remove<RendererId extends keyof IdList>(id:RendererId): IdList[RendererId]
33
+ remove(id:ODValidId): ODProgressBarRenderer<{}>|null
34
+
35
+ remove(id:ODValidId): ODProgressBarRenderer<{}>|null {
36
+ return super.remove(id)
37
+ }
38
+
39
+ exists(id:keyof IdList): boolean
40
+ exists(id:ODValidId): boolean
41
+
42
+ exists(id:ODValidId): boolean {
43
+ return super.exists(id)
44
+ }
19
45
  }
20
46
 
47
+ /**## ODProgressBarManagerIdConstraint `type`
48
+ * The constraint/layout for id mappings/interfaces of the `ODProgressBarManager` class.
49
+ */
50
+ export type ODProgressBarManagerIdConstraint = Record<string,ODProgressBar>
51
+
21
52
  /**## ODProgressBarManager `class`
22
53
  * This is an Open Discord progress bar manager.
23
54
  *
@@ -25,13 +56,35 @@ export class ODProgressBarRendererManager extends ODManager<ODProgressBarRendere
25
56
  *
26
57
  * There are many types of progress bars available, but you can also create your own!
27
58
  */
28
- export class ODProgressBarManager extends ODManager<ODProgressBar> {
29
- renderers: ODProgressBarRendererManager
59
+ export class ODProgressBarManager<IdList extends ODProgressBarManagerIdConstraint = ODProgressBarManagerIdConstraint,RendererIdList extends ODProgressBarRendererManagerIdConstraint = ODProgressBarRendererManagerIdConstraint> extends ODManager<ODProgressBar> {
60
+ /**A collection of render types for progress bars. */
61
+ renderers: ODProgressBarRendererManager<ODProgressBarRendererManagerIdConstraint>
30
62
 
31
63
  constructor(debug:ODDebugger){
32
64
  super(debug,"progress bar")
33
65
  this.renderers = new ODProgressBarRendererManager(debug)
34
66
  }
67
+
68
+ get<ProgressBarId extends keyof IdList>(id:ProgressBarId): IdList[ProgressBarId]
69
+ get(id:ODValidId): ODProgressBar|null
70
+
71
+ get(id:ODValidId): ODProgressBar|null {
72
+ return super.get(id)
73
+ }
74
+
75
+ remove<ProgressBarId extends keyof IdList>(id:ProgressBarId): IdList[ProgressBarId]
76
+ remove(id:ODValidId): ODProgressBar|null
77
+
78
+ remove(id:ODValidId): ODProgressBar|null {
79
+ return super.remove(id)
80
+ }
81
+
82
+ exists(id:keyof IdList): boolean
83
+ exists(id:ODValidId): boolean
84
+
85
+ exists(id:ODValidId): boolean {
86
+ return super.exists(id)
87
+ }
35
88
  }
36
89
 
37
90
  /**## ODProgressBarRenderFunc `type`
@@ -15,9 +15,9 @@ import { ODDropdownData, ODMessageBuildResult, ODMessageBuildSentResult, ODModal
15
15
  *
16
16
  * This class can't be used stand-alone & needs to be extended from!
17
17
  */
18
- export class ODResponderImplementation<Instance,Source extends string,Params> extends ODManagerData {
18
+ export class ODResponderImplementation<Instance,Source extends string,Params,WorkerIds extends string = string> extends ODManagerData {
19
19
  /**The manager that has all workers of this implementation */
20
- workers: ODWorkerManager<Instance,Source,Params>
20
+ workers: ODWorkerManager<Instance,Source,Params,WorkerIds>
21
21
  /**The `commandName` or `customId` needs to match this string or regex for this responder to be executed. */
22
22
  match: string|RegExp
23
23
 
@@ -52,19 +52,26 @@ export type ODResponderTimeoutErrorCallback<Instance, Source extends "slash"|"te
52
52
  * - know where the request came from & parse options/subcommands & without errors!
53
53
  * - And so much more!
54
54
  */
55
- export class ODResponderManager {
55
+ export class ODResponderManager<
56
+ CommandIdList extends ODCommandResponderManagerIdConstraint = ODCommandResponderManagerIdConstraint,
57
+ ButtonIdList extends ODButtonResponderManagerIdConstraint = ODButtonResponderManagerIdConstraint,
58
+ DropdownIdList extends ODDropdownResponderManagerIdConstraint = ODDropdownResponderManagerIdConstraint,
59
+ ModalIdList extends ODModalResponderManagerIdConstraint = ODModalResponderManagerIdConstraint,
60
+ ContextMenuIdList extends ODContextMenuResponderManagerIdConstraint = ODContextMenuResponderManagerIdConstraint,
61
+ AutocompleteIdList extends ODAutocompleteResponderManagerIdConstraint = ODAutocompleteResponderManagerIdConstraint
62
+ > {
56
63
  /**A manager for all (text & slash) command responders. */
57
- commands: ODCommandResponderManager
64
+ commands: ODCommandResponderManager<CommandIdList>
58
65
  /**A manager for all button responders. */
59
- buttons: ODButtonResponderManager
66
+ buttons: ODButtonResponderManager<ButtonIdList>
60
67
  /**A manager for all dropdown/select menu responders. */
61
- dropdowns: ODDropdownResponderManager
68
+ dropdowns: ODDropdownResponderManager<DropdownIdList>
62
69
  /**A manager for all modal responders. */
63
- modals: ODModalResponderManager
70
+ modals: ODModalResponderManager<ModalIdList>
64
71
  /**A manager for all context menu responders. */
65
- contextMenus: ODContextMenuResponderManager
72
+ contextMenus: ODContextMenuResponderManager<ContextMenuIdList>
66
73
  /**A manager for all autocomplete responders. */
67
- autocomplete: ODAutocompleteResponderManager
74
+ autocomplete: ODAutocompleteResponderManager<AutocompleteIdList>
68
75
 
69
76
  constructor(debug:ODDebugger, client:ODClientManager){
70
77
  this.commands = new ODCommandResponderManager(debug,"command responder",client)
@@ -76,6 +83,11 @@ export class ODResponderManager {
76
83
  }
77
84
  }
78
85
 
86
+ /**## ODCommandResponderManagerIdConstraint `type`
87
+ * The constraint/layout for id mappings/interfaces of the `ODCommandResponderManager` class.
88
+ */
89
+ export type ODCommandResponderManagerIdConstraint = Record<string,{source:"slash"|"text",params:object,workers:string}>
90
+
79
91
  /**## ODCommandResponderManager `class`
80
92
  * This is an Open Discord command responder manager.
81
93
  *
@@ -90,7 +102,7 @@ export class ODResponderManager {
90
102
  * - know where the request came from & parse options/subcommands & without errors!
91
103
  * - And so much more!
92
104
  */
93
- export class ODCommandResponderManager extends ODManager<ODCommandResponder<"slash"|"text",any>> {
105
+ export class ODCommandResponderManager<IdList extends ODCommandResponderManagerIdConstraint = ODCommandResponderManagerIdConstraint> extends ODManager<ODCommandResponder<"slash"|"text",any>> {
94
106
  /**An alias to the Open Discord client manager. */
95
107
  #client: ODClientManager
96
108
  /**The callback executed when the default workers take too much time to reply. */
@@ -128,6 +140,27 @@ export class ODCommandResponderManager extends ODManager<ODCommandResponder<"sla
128
140
 
129
141
  return res
130
142
  }
143
+
144
+ get<CommandResponderId extends keyof IdList>(id:CommandResponderId): ODCommandResponder<IdList[CommandResponderId]["source"],IdList[CommandResponderId]["params"],IdList[CommandResponderId]["workers"]>
145
+ get(id:ODValidId): ODCommandResponder<"slash"|"text",any>|null
146
+
147
+ get(id:ODValidId): ODCommandResponder<"slash"|"text",any>|null {
148
+ return super.get(id)
149
+ }
150
+
151
+ remove<CommandResponderId extends keyof IdList>(id:CommandResponderId): ODCommandResponder<IdList[CommandResponderId]["source"],IdList[CommandResponderId]["params"],IdList[CommandResponderId]["workers"]>
152
+ remove(id:ODValidId): ODCommandResponder<"slash"|"text",any>|null
153
+
154
+ remove(id:ODValidId): ODCommandResponder<"slash"|"text",any>|null {
155
+ return super.remove(id)
156
+ }
157
+
158
+ exists(id:keyof IdList): boolean
159
+ exists(id:ODValidId): boolean
160
+
161
+ exists(id:ODValidId): boolean {
162
+ return super.exists(id)
163
+ }
131
164
  }
132
165
 
133
166
  /**## ODCommandResponderInstanceOptions `class`
@@ -438,7 +471,7 @@ export class ODCommandResponderInstance {
438
471
  *
439
472
  * This class manages all workers which are executed when the related command is triggered.
440
473
  */
441
- export class ODCommandResponder<Source extends "slash"|"text",Params> extends ODResponderImplementation<ODCommandResponderInstance,Source,Params> {
474
+ export class ODCommandResponder<Source extends "slash"|"text",Params,WorkerIds extends string = string> extends ODResponderImplementation<ODCommandResponderInstance,Source,Params,WorkerIds> {
442
475
  /**The prefix of the text command needs to match this */
443
476
  prefix: string
444
477
 
@@ -454,6 +487,11 @@ export class ODCommandResponder<Source extends "slash"|"text",Params> extends OD
454
487
  }
455
488
  }
456
489
 
490
+ /**## ODButtonResponderManagerIdConstraint `type`
491
+ * The constraint/layout for id mappings/interfaces of the `ODButtonResponderManager` class.
492
+ */
493
+ export type ODButtonResponderManagerIdConstraint = Record<string,{source:"button",params:object,workers:string}>
494
+
457
495
  /**## ODButtonResponderManager `class`
458
496
  * This is an Open Discord button responder manager.
459
497
  *
@@ -467,7 +505,7 @@ export class ODCommandResponder<Source extends "slash"|"text",Params> extends OD
467
505
  * - know where the request came from!
468
506
  * - And so much more!
469
507
  */
470
- export class ODButtonResponderManager extends ODManager<ODButtonResponder<"button",any>> {
508
+ export class ODButtonResponderManager<IdList extends ODButtonResponderManagerIdConstraint = ODButtonResponderManagerIdConstraint> extends ODManager<ODButtonResponder<"button",any>> {
471
509
  /**An alias to the Open Discord client manager. */
472
510
  #client: ODClientManager
473
511
  /**The callback executed when the default workers take too much time to reply. */
@@ -504,6 +542,27 @@ export class ODButtonResponderManager extends ODManager<ODButtonResponder<"butto
504
542
 
505
543
  return res
506
544
  }
545
+
546
+ get<ButtonResponderId extends keyof IdList>(id:ButtonResponderId): ODButtonResponder<IdList[ButtonResponderId]["source"],IdList[ButtonResponderId]["params"],IdList[ButtonResponderId]["workers"]>
547
+ get(id:ODValidId): ODButtonResponder<"button",any>|null
548
+
549
+ get(id:ODValidId): ODButtonResponder<"button",any>|null {
550
+ return super.get(id)
551
+ }
552
+
553
+ remove<ButtonResponderId extends keyof IdList>(id:ButtonResponderId): ODButtonResponder<IdList[ButtonResponderId]["source"],IdList[ButtonResponderId]["params"],IdList[ButtonResponderId]["workers"]>
554
+ remove(id:ODValidId): ODButtonResponder<"button",any>|null
555
+
556
+ remove(id:ODValidId): ODButtonResponder<"button",any>|null {
557
+ return super.remove(id)
558
+ }
559
+
560
+ exists(id:keyof IdList): boolean
561
+ exists(id:ODValidId): boolean
562
+
563
+ exists(id:ODValidId): boolean {
564
+ return super.exists(id)
565
+ }
507
566
  }
508
567
 
509
568
  /**## ODButtonResponderInstance `class`
@@ -644,7 +703,7 @@ export class ODButtonResponderInstance {
644
703
  *
645
704
  * This class manages all workers which are executed when the related button is triggered.
646
705
  */
647
- export class ODButtonResponder<Source extends string,Params> extends ODResponderImplementation<ODButtonResponderInstance,Source,Params> {
706
+ export class ODButtonResponder<Source extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODButtonResponderInstance,Source,Params,WorkerIds> {
648
707
  /**Respond to this button */
649
708
  async respond(instance:ODButtonResponderInstance, source:Source, params:Params){
650
709
  //wait for workers to finish
@@ -652,6 +711,11 @@ export class ODButtonResponder<Source extends string,Params> extends ODResponder
652
711
  }
653
712
  }
654
713
 
714
+ /**## ODDropdownResponderManagerIdConstraint `type`
715
+ * The constraint/layout for id mappings/interfaces of the `ODDropdownResponderManager` class.
716
+ */
717
+ export type ODDropdownResponderManagerIdConstraint = Record<string,{source:"dropdown",params:object,workers:string}>
718
+
655
719
  /**## ODDropdownResponderManager `class`
656
720
  * This is an Open Discord dropdown responder manager.
657
721
  *
@@ -665,7 +729,7 @@ export class ODButtonResponder<Source extends string,Params> extends ODResponder
665
729
  * - know where the request came from!
666
730
  * - And so much more!
667
731
  */
668
- export class ODDropdownResponderManager extends ODManager<ODDropdownResponder<"dropdown",any>> {
732
+ export class ODDropdownResponderManager<IdList extends ODDropdownResponderManagerIdConstraint = ODDropdownResponderManagerIdConstraint> extends ODManager<ODDropdownResponder<"dropdown",any>> {
669
733
  /**An alias to the Open Discord client manager. */
670
734
  #client: ODClientManager
671
735
  /**The callback executed when the default workers take too much time to reply. */
@@ -702,6 +766,27 @@ export class ODDropdownResponderManager extends ODManager<ODDropdownResponder<"d
702
766
 
703
767
  return res
704
768
  }
769
+
770
+ get<DropdownResponderId extends keyof IdList>(id:DropdownResponderId): ODDropdownResponder<IdList[DropdownResponderId]["source"],IdList[DropdownResponderId]["params"],IdList[DropdownResponderId]["workers"]>
771
+ get(id:ODValidId): ODDropdownResponder<"dropdown",any>|null
772
+
773
+ get(id:ODValidId): ODDropdownResponder<"dropdown",any>|null {
774
+ return super.get(id)
775
+ }
776
+
777
+ remove<DropdownResponderId extends keyof IdList>(id:DropdownResponderId): ODDropdownResponder<IdList[DropdownResponderId]["source"],IdList[DropdownResponderId]["params"],IdList[DropdownResponderId]["workers"]>
778
+ remove(id:ODValidId): ODDropdownResponder<"dropdown",any>|null
779
+
780
+ remove(id:ODValidId): ODDropdownResponder<"dropdown",any>|null {
781
+ return super.remove(id)
782
+ }
783
+
784
+ exists(id:keyof IdList): boolean
785
+ exists(id:ODValidId): boolean
786
+
787
+ exists(id:ODValidId): boolean {
788
+ return super.exists(id)
789
+ }
705
790
  }
706
791
 
707
792
  /**## ODDropdownResponderInstanceValues `class`
@@ -933,7 +1018,7 @@ export class ODDropdownResponderInstance {
933
1018
  *
934
1019
  * This class manages all workers which are executed when the related dropdown is triggered.
935
1020
  */
936
- export class ODDropdownResponder<Source extends string,Params> extends ODResponderImplementation<ODDropdownResponderInstance,Source,Params> {
1021
+ export class ODDropdownResponder<Source extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODDropdownResponderInstance,Source,Params,WorkerIds> {
937
1022
  /**Respond to this dropdown */
938
1023
  async respond(instance:ODDropdownResponderInstance, source:Source, params:Params){
939
1024
  //wait for workers to finish
@@ -941,6 +1026,11 @@ export class ODDropdownResponder<Source extends string,Params> extends ODRespond
941
1026
  }
942
1027
  }
943
1028
 
1029
+ /**## ODModalResponderManagerIdConstraint `type`
1030
+ * The constraint/layout for id mappings/interfaces of the `ODModalResponderManager` class.
1031
+ */
1032
+ export type ODModalResponderManagerIdConstraint = Record<string,{source:"modal",params:object,workers:string}>
1033
+
944
1034
  /**## ODModalResponderManager `class`
945
1035
  * This is an Open Discord modal responder manager.
946
1036
  *
@@ -954,7 +1044,7 @@ export class ODDropdownResponder<Source extends string,Params> extends ODRespond
954
1044
  * - know where the request came from!
955
1045
  * - And so much more!
956
1046
  */
957
- export class ODModalResponderManager extends ODManager<ODModalResponder<"modal",any>> {
1047
+ export class ODModalResponderManager<IdList extends ODModalResponderManagerIdConstraint = ODModalResponderManagerIdConstraint> extends ODManager<ODModalResponder<"modal",any>> {
958
1048
  /**An alias to the Open Discord client manager. */
959
1049
  #client: ODClientManager
960
1050
  /**The callback executed when the default workers take too much time to reply. */
@@ -991,6 +1081,27 @@ export class ODModalResponderManager extends ODManager<ODModalResponder<"modal",
991
1081
 
992
1082
  return res
993
1083
  }
1084
+
1085
+ get<ModalResponderId extends keyof IdList>(id:ModalResponderId): ODModalResponder<IdList[ModalResponderId]["source"],IdList[ModalResponderId]["params"],IdList[ModalResponderId]["workers"]>
1086
+ get(id:ODValidId): ODModalResponder<"modal",any>|null
1087
+
1088
+ get(id:ODValidId): ODModalResponder<"modal",any>|null {
1089
+ return super.get(id)
1090
+ }
1091
+
1092
+ remove<ModalResponderId extends keyof IdList>(id:ModalResponderId): ODModalResponder<IdList[ModalResponderId]["source"],IdList[ModalResponderId]["params"],IdList[ModalResponderId]["workers"]>
1093
+ remove(id:ODValidId): ODModalResponder<"modal",any>|null
1094
+
1095
+ remove(id:ODValidId): ODModalResponder<"modal",any>|null {
1096
+ return super.remove(id)
1097
+ }
1098
+
1099
+ exists(id:keyof IdList): boolean
1100
+ exists(id:ODValidId): boolean
1101
+
1102
+ exists(id:ODValidId): boolean {
1103
+ return super.exists(id)
1104
+ }
994
1105
  }
995
1106
 
996
1107
  /**## ODModalResponderInstanceValues `class`
@@ -1114,7 +1225,7 @@ export class ODModalResponderInstance {
1114
1225
  *
1115
1226
  * This class manages all workers which are executed when the related modal is triggered.
1116
1227
  */
1117
- export class ODModalResponder<Source extends string,Params> extends ODResponderImplementation<ODModalResponderInstance,Source,Params> {
1228
+ export class ODModalResponder<Source extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODModalResponderInstance,Source,Params,WorkerIds> {
1118
1229
  /**Respond to this modal */
1119
1230
  async respond(instance:ODModalResponderInstance, source:Source, params:Params){
1120
1231
  //wait for workers to finish
@@ -1122,6 +1233,11 @@ export class ODModalResponder<Source extends string,Params> extends ODResponderI
1122
1233
  }
1123
1234
  }
1124
1235
 
1236
+ /**## ODContextMenuResponderManagerIdConstraint `type`
1237
+ * The constraint/layout for id mappings/interfaces of the `ODContextMenuResponderManager` class.
1238
+ */
1239
+ export type ODContextMenuResponderManagerIdConstraint = Record<string,{source:"context-menu",params:object,workers:string}>
1240
+
1125
1241
  /**## ODContextMenuResponderManager `class`
1126
1242
  * This is an Open Discord context menu responder manager.
1127
1243
  *
@@ -1135,7 +1251,7 @@ export class ODModalResponder<Source extends string,Params> extends ODResponderI
1135
1251
  * - know where the request came from!
1136
1252
  * - And so much more!
1137
1253
  */
1138
- export class ODContextMenuResponderManager extends ODManager<ODContextMenuResponder<"context-menu",any>> {
1254
+ export class ODContextMenuResponderManager<IdList extends ODContextMenuResponderManagerIdConstraint = ODContextMenuResponderManagerIdConstraint> extends ODManager<ODContextMenuResponder<"context-menu",any>> {
1139
1255
  /**An alias to the Open Discord client manager. */
1140
1256
  #client: ODClientManager
1141
1257
  /**The callback executed when the default workers take too much time to reply. */
@@ -1165,6 +1281,27 @@ export class ODContextMenuResponderManager extends ODManager<ODContextMenuRespon
1165
1281
 
1166
1282
  return res
1167
1283
  }
1284
+
1285
+ get<ModalResponderId extends keyof IdList>(id:ModalResponderId): ODContextMenuResponder<IdList[ModalResponderId]["source"],IdList[ModalResponderId]["params"],IdList[ModalResponderId]["workers"]>
1286
+ get(id:ODValidId): ODContextMenuResponder<"context-menu",any>|null
1287
+
1288
+ get(id:ODValidId): ODContextMenuResponder<"context-menu",any>|null {
1289
+ return super.get(id)
1290
+ }
1291
+
1292
+ remove<ModalResponderId extends keyof IdList>(id:ModalResponderId): ODContextMenuResponder<IdList[ModalResponderId]["source"],IdList[ModalResponderId]["params"],IdList[ModalResponderId]["workers"]>
1293
+ remove(id:ODValidId): ODContextMenuResponder<"context-menu",any>|null
1294
+
1295
+ remove(id:ODValidId): ODContextMenuResponder<"context-menu",any>|null {
1296
+ return super.remove(id)
1297
+ }
1298
+
1299
+ exists(id:keyof IdList): boolean
1300
+ exists(id:ODValidId): boolean
1301
+
1302
+ exists(id:ODValidId): boolean {
1303
+ return super.exists(id)
1304
+ }
1168
1305
  }
1169
1306
 
1170
1307
  /**## ODContextMenuResponderInstance `class`
@@ -1274,7 +1411,7 @@ export class ODContextMenuResponderInstance {
1274
1411
  *
1275
1412
  * This class manages all workers which are executed when the related context menu is triggered.
1276
1413
  */
1277
- export class ODContextMenuResponder<Source extends string,Params> extends ODResponderImplementation<ODContextMenuResponderInstance,Source,Params> {
1414
+ export class ODContextMenuResponder<Source extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODContextMenuResponderInstance,Source,Params,WorkerIds> {
1278
1415
  /**Respond to this button */
1279
1416
  async respond(instance:ODContextMenuResponderInstance, source:Source, params:Params){
1280
1417
  //wait for workers to finish
@@ -1282,6 +1419,11 @@ export class ODContextMenuResponder<Source extends string,Params> extends ODResp
1282
1419
  }
1283
1420
  }
1284
1421
 
1422
+ /**## ODAutocompleteResponderManagerIdConstraint `type`
1423
+ * The constraint/layout for id mappings/interfaces of the `ODAutocompleteResponderManager` class.
1424
+ */
1425
+ export type ODAutocompleteResponderManagerIdConstraint = Record<string,{source:"autocomplete",params:object,workers:string}>
1426
+
1285
1427
  /**## ODAutocompleteResponderManager `class`
1286
1428
  * This is an Open Discord autocomplete responder manager.
1287
1429
  *
@@ -1295,7 +1437,7 @@ export class ODContextMenuResponder<Source extends string,Params> extends ODResp
1295
1437
  * - know where the request came from!
1296
1438
  * - And so much more!
1297
1439
  */
1298
- export class ODAutocompleteResponderManager extends ODManager<ODAutocompleteResponder<"autocomplete",any>> {
1440
+ export class ODAutocompleteResponderManager<IdList extends ODAutocompleteResponderManagerIdConstraint = ODAutocompleteResponderManagerIdConstraint> extends ODManager<ODAutocompleteResponder<"autocomplete",any>> {
1299
1441
  /**An alias to the Open Discord client manager. */
1300
1442
  #client: ODClientManager
1301
1443
  /**The callback executed when the default workers take too much time to reply. */
@@ -1325,6 +1467,27 @@ export class ODAutocompleteResponderManager extends ODManager<ODAutocompleteResp
1325
1467
 
1326
1468
  return res
1327
1469
  }
1470
+
1471
+ get<AutocompleteResponderId extends keyof IdList>(id:AutocompleteResponderId): ODAutocompleteResponder<IdList[AutocompleteResponderId]["source"],IdList[AutocompleteResponderId]["params"],IdList[AutocompleteResponderId]["workers"]>
1472
+ get(id:ODValidId): ODAutocompleteResponder<"autocomplete",any>|null
1473
+
1474
+ get(id:ODValidId): ODAutocompleteResponder<"autocomplete",any>|null {
1475
+ return super.get(id)
1476
+ }
1477
+
1478
+ remove<AutocompleteResponderId extends keyof IdList>(id:AutocompleteResponderId): ODAutocompleteResponder<IdList[AutocompleteResponderId]["source"],IdList[AutocompleteResponderId]["params"],IdList[AutocompleteResponderId]["workers"]>
1479
+ remove(id:ODValidId): ODAutocompleteResponder<"autocomplete",any>|null
1480
+
1481
+ remove(id:ODValidId): ODAutocompleteResponder<"autocomplete",any>|null {
1482
+ return super.remove(id)
1483
+ }
1484
+
1485
+ exists(id:keyof IdList): boolean
1486
+ exists(id:ODValidId): boolean
1487
+
1488
+ exists(id:ODValidId): boolean {
1489
+ return super.exists(id)
1490
+ }
1328
1491
  }
1329
1492
 
1330
1493
  /**## ODAutocompleteResponderInstance `class`
@@ -1401,7 +1564,7 @@ export class ODAutocompleteResponderInstance {
1401
1564
  *
1402
1565
  * This class manages all workers which are executed when the related autocomplete is triggered.
1403
1566
  */
1404
- export class ODAutocompleteResponder<Source extends string,Params> extends ODResponderImplementation<ODAutocompleteResponderInstance,Source,Params> {
1567
+ export class ODAutocompleteResponder<Source extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODAutocompleteResponderInstance,Source,Params,WorkerIds> {
1405
1568
  /**The slash command of the autocomplete should match the following regex. */
1406
1569
  cmdMatch: string|RegExp
1407
1570
 
@@ -5,6 +5,11 @@ import { ODId, ODManager, ODManagerData, ODValidId } from "./base"
5
5
  import { ODDebugger } from "./console"
6
6
  import * as crypto from "crypto"
7
7
 
8
+ /**## ODSessionManagerIdConstraint `type`
9
+ * The constraint/layout for id mappings/interfaces of the `ODSessionManager` class.
10
+ */
11
+ export type ODSessionManagerIdConstraint = Record<string,ODSession>
12
+
8
13
  /**## ODSessionManager `class`
9
14
  * This is an Open Discord session manager.
10
15
  *
@@ -13,10 +18,31 @@ import * as crypto from "crypto"
13
18
  *
14
19
  * Visit the `ODSession` class for more info
15
20
  */
16
- export class ODSessionManager extends ODManager<ODSession> {
21
+ export class ODSessionManager<IdList extends ODSessionManagerIdConstraint = ODSessionManagerIdConstraint> extends ODManager<ODSession> {
17
22
  constructor(debug:ODDebugger){
18
23
  super(debug,"session")
19
24
  }
25
+
26
+ get<SessionId extends keyof IdList>(id:SessionId): IdList[SessionId]
27
+ get(id:ODValidId): ODSession|null
28
+
29
+ get(id:ODValidId): ODSession|null {
30
+ return super.get(id)
31
+ }
32
+
33
+ remove<SessionId extends keyof IdList>(id:SessionId): IdList[SessionId]
34
+ remove(id:ODValidId): ODSession|null
35
+
36
+ remove(id:ODValidId): ODSession|null {
37
+ return super.remove(id)
38
+ }
39
+
40
+ exists(id:keyof IdList): boolean
41
+ exists(id:ODValidId): boolean
42
+
43
+ exists(id:ODValidId): boolean {
44
+ return super.exists(id)
45
+ }
20
46
  }
21
47
 
22
48
  /**## ODSessionInstance `interface`
@@ -2,7 +2,7 @@
2
2
  //STARTSCREEN MODULE
3
3
  ///////////////////////////////////////
4
4
  import { ODId, ODManager, ODManagerData, ODValidId } from "./base"
5
- import { ODDebugger, ODError, ODLiveStatusManager } from "./console"
5
+ import { ODDebugger, ODError, ODLiveStatusManager, ODLiveStatusManagerIdConstraint } from "./console"
6
6
  import { ODFlag } from "./flag"
7
7
  import { ODPlugin, ODUnknownCrashedPlugin } from "./plugin"
8
8
  import ansis from "ansis"
@@ -12,19 +12,24 @@ import ansis from "ansis"
12
12
  */
13
13
  export type ODStartScreenComponentRenderCallback = (location:number) => string|Promise<string>
14
14
 
15
+ /**## ODStartScreenManagerIdConstraint `type`
16
+ * The constraint/layout for id mappings/interfaces of the `ODStartScreenManager` class.
17
+ */
18
+ export type ODStartScreenManagerIdConstraint = Record<string,ODStartScreenComponent>
19
+
15
20
  /**## ODStartScreenManager `class`
16
21
  * This is an Open Discord startscreen manager.
17
22
  *
18
23
  * This class is responsible for managing & rendering the startscreen of the bot.
19
24
  * The startscreen is the part you see when the bot has started up successfully. (e.g. the Open Discord logo, logs, livestatus, flags, ...)
20
25
  */
21
- export class ODStartScreenManager extends ODManager<ODStartScreenComponent> {
26
+ export class ODStartScreenManager<IdList extends ODStartScreenManagerIdConstraint = ODStartScreenManagerIdConstraint,LiveStatus extends ODLiveStatusManager = ODLiveStatusManager> extends ODManager<ODStartScreenComponent> {
22
27
  /**Alias to the Open Discord debugger. */
23
28
  #debug: ODDebugger
24
29
  /**Alias to the livestatus manager. */
25
- livestatus: ODLiveStatusManager
30
+ livestatus: LiveStatus
26
31
 
27
- constructor(debug:ODDebugger,livestatus:ODLiveStatusManager){
32
+ constructor(debug:ODDebugger,livestatus:LiveStatus){
28
33
  super(debug,"startscreen component")
29
34
  this.#debug = debug
30
35
  this.livestatus = livestatus
@@ -54,6 +59,27 @@ export class ODStartScreenManager extends ODManager<ODStartScreenComponent> {
54
59
  location++
55
60
  }
56
61
  }
62
+
63
+ get<StartScreenId extends keyof IdList>(id:StartScreenId): IdList[StartScreenId]
64
+ get(id:ODValidId): ODStartScreenComponent|null
65
+
66
+ get(id:ODValidId): ODStartScreenComponent|null {
67
+ return super.get(id)
68
+ }
69
+
70
+ remove<StartScreenId extends keyof IdList>(id:StartScreenId): IdList[StartScreenId]
71
+ remove(id:ODValidId): ODStartScreenComponent|null
72
+
73
+ remove(id:ODValidId): ODStartScreenComponent|null {
74
+ return super.remove(id)
75
+ }
76
+
77
+ exists(id:keyof IdList): boolean
78
+ exists(id:ODValidId): boolean
79
+
80
+ exists(id:ODValidId): boolean {
81
+ return super.exists(id)
82
+ }
57
83
  }
58
84
 
59
85
  /**## ODStartScreenComponent `class`
@@ -294,11 +320,11 @@ export class ODStartScreenPluginsCategoryComponent extends ODStartScreenCategory
294
320
  * This component will render a livestatus category to the startscreen. This will list the livestatus messages in the category.
295
321
  * An optional priority can be specified to choose the location of the component.
296
322
  */
297
- export class ODStartScreenLiveStatusCategoryComponent extends ODStartScreenCategoryComponent {
323
+ export class ODStartScreenLiveStatusCategoryComponent<LiveStatus extends ODLiveStatusManager<ODLiveStatusManagerIdConstraint>> extends ODStartScreenCategoryComponent {
298
324
  /**A reference to the Open Discord livestatus manager. */
299
- livestatus: ODLiveStatusManager
325
+ livestatus: LiveStatus
300
326
 
301
- constructor(id:ODValidId, priority:number, livestatus:ODLiveStatusManager){
327
+ constructor(id:ODValidId, priority:number, livestatus:LiveStatus){
302
328
  super(id,priority,"livestatus",async () => {
303
329
  const messages = await this.livestatus.getAllMessages()
304
330
  return this.livestatus.renderer.render(messages)