@open-discord-bots/framework 0.2.11 → 0.2.13
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/index.d.ts +26 -26
- package/dist/api/index.js +26 -42
- package/dist/api/main.d.ts +24 -24
- package/dist/api/main.js +7 -11
- package/dist/api/modules/action.d.ts +12 -12
- package/dist/api/modules/action.js +11 -17
- package/dist/api/modules/base.d.ts +7 -5
- package/dist/api/modules/base.js +22 -67
- package/dist/api/modules/builder.d.ts +44 -44
- package/dist/api/modules/builder.js +81 -142
- package/dist/api/modules/checker.d.ts +7 -7
- package/dist/api/modules/checker.js +55 -87
- package/dist/api/modules/client.d.ts +4 -4
- package/dist/api/modules/client.js +71 -118
- package/dist/api/modules/code.d.ts +2 -2
- package/dist/api/modules/code.js +3 -8
- package/dist/api/modules/config.d.ts +2 -2
- package/dist/api/modules/config.js +21 -63
- package/dist/api/modules/console.d.ts +16 -16
- package/dist/api/modules/console.js +61 -83
- package/dist/api/modules/cooldown.d.ts +2 -2
- package/dist/api/modules/cooldown.js +13 -23
- package/dist/api/modules/database.d.ts +2 -2
- package/dist/api/modules/database.js +19 -29
- package/dist/api/modules/event.d.ts +2 -2
- package/dist/api/modules/event.js +6 -11
- package/dist/api/modules/flag.d.ts +2 -2
- package/dist/api/modules/flag.js +3 -8
- package/dist/api/modules/fuse.js +2 -7
- package/dist/api/modules/helpmenu.d.ts +2 -2
- package/dist/api/modules/helpmenu.js +8 -16
- package/dist/api/modules/language.d.ts +2 -2
- package/dist/api/modules/language.js +12 -21
- package/dist/api/modules/permission.d.ts +3 -3
- package/dist/api/modules/permission.js +9 -47
- package/dist/api/modules/plugin.d.ts +2 -2
- package/dist/api/modules/plugin.js +9 -18
- package/dist/api/modules/post.d.ts +3 -3
- package/dist/api/modules/post.js +3 -8
- package/dist/api/modules/progressbar.d.ts +2 -2
- package/dist/api/modules/progressbar.js +14 -26
- package/dist/api/modules/responder.d.ts +42 -42
- package/dist/api/modules/responder.js +79 -138
- package/dist/api/modules/session.d.ts +2 -2
- package/dist/api/modules/session.js +4 -42
- package/dist/api/modules/startscreen.d.ts +4 -4
- package/dist/api/modules/startscreen.js +28 -44
- package/dist/api/modules/statistic.d.ts +3 -3
- package/dist/api/modules/statistic.js +11 -22
- package/dist/api/modules/verifybar.d.ts +5 -5
- package/dist/api/modules/verifybar.js +6 -11
- package/dist/api/modules/worker.d.ts +15 -15
- package/dist/api/modules/worker.js +12 -17
- package/dist/cli/editConfig.d.ts +2 -2
- package/dist/cli/editConfig.js +194 -248
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +37 -62
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -13
- package/dist/startup/compilation.d.ts +1 -1
- package/dist/startup/compilation.js +35 -42
- package/dist/startup/dump.d.ts +1 -1
- package/dist/startup/dump.js +4 -41
- package/dist/startup/errorHandling.d.ts +1 -1
- package/dist/startup/errorHandling.js +2 -38
- package/dist/startup/pluginLauncher.d.ts +1 -1
- package/dist/startup/pluginLauncher.js +14 -52
- package/dist/utilities/index.d.ts +3 -3
- package/dist/utilities/index.js +20 -71
- package/package.json +5 -4
- package/src/api/index.ts +26 -26
- package/src/api/main.ts +25 -25
- package/src/api/modules/action.ts +13 -13
- package/src/api/modules/base.ts +14 -10
- package/src/api/modules/builder.ts +56 -56
- package/src/api/modules/checker.ts +7 -7
- package/src/api/modules/client.ts +18 -18
- package/src/api/modules/code.ts +2 -2
- package/src/api/modules/component.txt +350 -0
- package/src/api/modules/config.ts +3 -3
- package/src/api/modules/console.ts +28 -28
- package/src/api/modules/cooldown.ts +2 -2
- package/src/api/modules/database.ts +3 -3
- package/src/api/modules/event.ts +5 -5
- package/src/api/modules/flag.ts +2 -2
- package/src/api/modules/helpmenu.ts +4 -4
- package/src/api/modules/language.ts +3 -3
- package/src/api/modules/permission.ts +3 -3
- package/src/api/modules/plugin.ts +4 -4
- package/src/api/modules/post.ts +3 -3
- package/src/api/modules/progressbar.ts +5 -3
- package/src/api/modules/responder.ts +48 -48
- package/src/api/modules/session.ts +2 -2
- package/src/api/modules/startscreen.ts +4 -4
- package/src/api/modules/statistic.ts +3 -4
- package/src/api/modules/verifybar.ts +5 -5
- package/src/api/modules/worker.ts +25 -25
- package/src/cli/editConfig.ts +23 -37
- package/src/cli/index.ts +3 -3
- package/src/index.ts +5 -5
- package/src/startup/compilation.ts +2 -2
- package/src/startup/dump.ts +2 -2
- package/src/startup/errorHandling.ts +2 -2
- package/src/startup/pluginLauncher.ts +11 -8
- package/src/utilities/index.ts +4 -4
- package/tools/cleanup.js +1 -1
- package/tsconfig.json +2 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//PERMISSION MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODId, ODValidId, ODManager, ODSystemError, ODManagerData, ODNoGeneric } from "./base"
|
|
4
|
+
import { ODId, ODValidId, ODManager, ODSystemError, ODManagerData, ODNoGeneric } from "./base.js"
|
|
5
5
|
import * as discord from "discord.js"
|
|
6
|
-
import { ODDebugger } from "./console"
|
|
7
|
-
import { ODClientManager } from "./client"
|
|
6
|
+
import { ODDebugger } from "./console.js"
|
|
7
|
+
import { ODClientManager } from "./client.js"
|
|
8
8
|
|
|
9
9
|
/**## ODPermissionType `type`
|
|
10
10
|
* All available permission types/levels. Can be used in the `ODPermission` class.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//PLUGIN MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId, ODVersion } from "./base"
|
|
5
|
-
import { ODDebugger } from "./console"
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId, ODVersion } from "./base.js"
|
|
5
|
+
import { ODDebugger } from "./console.js"
|
|
6
6
|
import nodepath from "path"
|
|
7
7
|
|
|
8
8
|
/**## ODUnknownCrashedPlugin `interface`
|
|
@@ -180,12 +180,12 @@ export class ODPlugin extends ODManagerData {
|
|
|
180
180
|
if ((this.enabled && !this.crashed) || force){
|
|
181
181
|
try{
|
|
182
182
|
//import relative plugin directory path (works on windows & unix based systems)
|
|
183
|
-
const pluginPath = nodepath.join("
|
|
183
|
+
const pluginPath = nodepath.join(process.cwd(),"./dist/plugins/",this.getStartFile()).replaceAll("\\","/")
|
|
184
184
|
await import(pluginPath)
|
|
185
185
|
debug.console.log("Plugin \""+this.id.value+"\" loaded successfully!","plugin")
|
|
186
186
|
this.executed = true
|
|
187
187
|
return true
|
|
188
|
-
}catch(error){
|
|
188
|
+
}catch(error:any){
|
|
189
189
|
this.crashed = true
|
|
190
190
|
this.crashReason = "executed"
|
|
191
191
|
|
package/src/api/modules/post.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//POST MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base"
|
|
5
|
-
import { ODMessageBuildResult, ODMessageBuildSentResult } from "./builder"
|
|
6
|
-
import { ODDebugger } from "./console"
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js"
|
|
5
|
+
import { ODMessageBuildResult, ODMessageBuildSentResult } from "./builder.js"
|
|
6
|
+
import { ODDebugger } from "./console.js"
|
|
7
7
|
import * as discord from "discord.js"
|
|
8
8
|
|
|
9
9
|
/**## ODPostManagerIdConstraint `type`
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//PROGRESS BAR MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODSystemError, ODManager, ODManagerData, ODValidId, ODNoGeneric } from "./base"
|
|
5
|
-
import { ODDebugger, ODValidConsoleColor } from "./console"
|
|
4
|
+
import { ODSystemError, ODManager, ODManagerData, ODValidId, ODNoGeneric } from "./base.js"
|
|
5
|
+
import { ODDebugger, ODValidConsoleColor } from "./console.js"
|
|
6
6
|
import readline from "readline"
|
|
7
7
|
import ansis from "ansis"
|
|
8
8
|
|
|
@@ -122,9 +122,11 @@ export class ODProgressBarRenderer<Settings extends {}> extends ODManagerData {
|
|
|
122
122
|
|
|
123
123
|
withAdditionalSettings(settings:Partial<Settings>): ODProgressBarRenderer<Settings> {
|
|
124
124
|
const newSettings: Settings = {...this.settings}
|
|
125
|
-
for (const key of Object.keys(settings)){
|
|
125
|
+
for (const key of Object.keys(settings) as (keyof Partial<Settings>)[]){
|
|
126
126
|
if (typeof settings[key] != "undefined") newSettings[key] = settings[key]
|
|
127
127
|
}
|
|
128
|
+
|
|
129
|
+
const idk = Object.keys(settings)
|
|
128
130
|
return new ODProgressBarRenderer(this.id,this.#render,newSettings)
|
|
129
131
|
}
|
|
130
132
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//RESPONDER MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODId, ODManager, ODValidId, ODSystemError, ODManagerData, ODNoGeneric } from "./base"
|
|
4
|
+
import { ODId, ODManager, ODValidId, ODSystemError, ODManagerData, ODNoGeneric } from "./base.js"
|
|
5
5
|
import * as discord from "discord.js"
|
|
6
|
-
import { ODWorkerManager, ODWorkerCallback, ODWorker } from "./worker"
|
|
7
|
-
import { ODDebugger } from "./console"
|
|
8
|
-
import { ODClientManager, ODContextMenu, ODSlashCommand, ODTextCommand, ODTextCommandInteractionOption } from "./client"
|
|
9
|
-
import { ODDropdownData, ODMessageBuildResult, ODMessageBuildSentResult, ODModalBuildResult } from "./builder"
|
|
6
|
+
import { ODWorkerManager, ODWorkerCallback, ODWorker } from "./worker.js"
|
|
7
|
+
import { ODDebugger } from "./console.js"
|
|
8
|
+
import { ODClientManager, ODContextMenu, ODSlashCommand, ODTextCommand, ODTextCommandInteractionOption } from "./client.js"
|
|
9
|
+
import { ODDropdownData, ODMessageBuildResult, ODMessageBuildSentResult, ODModalBuildResult } from "./builder.js"
|
|
10
10
|
|
|
11
11
|
/**## ODResponderImplementation `class`
|
|
12
12
|
* This is an Open Discord responder implementation.
|
|
@@ -15,20 +15,20 @@ 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,
|
|
18
|
+
export class ODResponderImplementation<Instance,Origin extends string,Params,WorkerIds extends string = string> extends ODManagerData {
|
|
19
19
|
/**The manager that has all workers of this implementation */
|
|
20
|
-
workers: ODWorkerManager<Instance,
|
|
20
|
+
workers: ODWorkerManager<Instance,Origin,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
|
|
|
24
|
-
constructor(id:ODValidId, match:string|RegExp, callback?:ODWorkerCallback<Instance,
|
|
24
|
+
constructor(id:ODValidId, match:string|RegExp, callback?:ODWorkerCallback<Instance,Origin,Params>, priority?:number, callbackId?:ODValidId){
|
|
25
25
|
super(id)
|
|
26
26
|
this.match = match
|
|
27
27
|
this.workers = new ODWorkerManager("descending")
|
|
28
28
|
if (callback) this.workers.add(new ODWorker(callbackId ? callbackId : id,priority ?? 0,callback))
|
|
29
29
|
}
|
|
30
30
|
/**Execute all workers & return the result. */
|
|
31
|
-
async respond(instance:Instance,
|
|
31
|
+
async respond(instance:Instance, origin:Origin, params:Params): Promise<void> {
|
|
32
32
|
throw new ODSystemError("Tried to build an unimplemented ODResponderImplementation")
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -36,7 +36,7 @@ export class ODResponderImplementation<Instance,Source extends string,Params,Wor
|
|
|
36
36
|
/**## ODResponderTimeoutErrorCallback `type`
|
|
37
37
|
* This is the callback for the responder timeout function. It will be executed when something went wrong or the action takes too much time.
|
|
38
38
|
*/
|
|
39
|
-
export type ODResponderTimeoutErrorCallback<Instance,
|
|
39
|
+
export type ODResponderTimeoutErrorCallback<Instance, Origin extends "slash"|"text"|"button"|"dropdown"|"modal"|"other"|"context-menu"|"autocomplete"> = (instance:Instance, origin:Origin) => void|Promise<void>
|
|
40
40
|
|
|
41
41
|
/**## ODResponderManager `class`
|
|
42
42
|
* This is an Open Discord responder manager.
|
|
@@ -86,7 +86,7 @@ export class ODResponderManager<
|
|
|
86
86
|
/**## ODCommandResponderManagerIdConstraint `type`
|
|
87
87
|
* The constraint/layout for id mappings/interfaces of the `ODCommandResponderManager` class.
|
|
88
88
|
*/
|
|
89
|
-
export type ODCommandResponderManagerIdConstraint = Record<string,{
|
|
89
|
+
export type ODCommandResponderManagerIdConstraint = Record<string,{origin:"slash"|"text",params:object,workers:string}>
|
|
90
90
|
|
|
91
91
|
/**## ODCommandResponderManager `class`
|
|
92
92
|
* This is an Open Discord command responder manager.
|
|
@@ -141,14 +141,14 @@ export class ODCommandResponderManager<IdList extends ODCommandResponderManagerI
|
|
|
141
141
|
return res
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
get<CommandResponderId extends keyof ODNoGeneric<IdList>>(id:CommandResponderId): ODCommandResponder<IdList[CommandResponderId]["
|
|
144
|
+
get<CommandResponderId extends keyof ODNoGeneric<IdList>>(id:CommandResponderId): ODCommandResponder<IdList[CommandResponderId]["origin"],IdList[CommandResponderId]["params"],IdList[CommandResponderId]["workers"]>
|
|
145
145
|
get(id:ODValidId): ODCommandResponder<"slash"|"text",any>|null
|
|
146
146
|
|
|
147
147
|
get(id:ODValidId): ODCommandResponder<"slash"|"text",any>|null {
|
|
148
148
|
return super.get(id)
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
remove<CommandResponderId extends keyof ODNoGeneric<IdList>>(id:CommandResponderId): ODCommandResponder<IdList[CommandResponderId]["
|
|
151
|
+
remove<CommandResponderId extends keyof ODNoGeneric<IdList>>(id:CommandResponderId): ODCommandResponder<IdList[CommandResponderId]["origin"],IdList[CommandResponderId]["params"],IdList[CommandResponderId]["workers"]>
|
|
152
152
|
remove(id:ODValidId): ODCommandResponder<"slash"|"text",any>|null
|
|
153
153
|
|
|
154
154
|
remove(id:ODValidId): ODCommandResponder<"slash"|"text",any>|null {
|
|
@@ -471,26 +471,26 @@ export class ODCommandResponderInstance {
|
|
|
471
471
|
*
|
|
472
472
|
* This class manages all workers which are executed when the related command is triggered.
|
|
473
473
|
*/
|
|
474
|
-
export class ODCommandResponder<
|
|
474
|
+
export class ODCommandResponder<Origin extends "slash"|"text",Params,WorkerIds extends string = string> extends ODResponderImplementation<ODCommandResponderInstance,Origin,Params,WorkerIds> {
|
|
475
475
|
/**The prefix of the text command needs to match this */
|
|
476
476
|
prefix: string
|
|
477
477
|
|
|
478
|
-
constructor(id:ODValidId, prefix:string, match:string|RegExp, callback?:ODWorkerCallback<ODCommandResponderInstance,
|
|
478
|
+
constructor(id:ODValidId, prefix:string, match:string|RegExp, callback?:ODWorkerCallback<ODCommandResponderInstance,Origin,Params>, priority?:number, callbackId?:ODValidId){
|
|
479
479
|
super(id,match,callback,priority,callbackId)
|
|
480
480
|
this.prefix = prefix
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
/**Respond to this command */
|
|
484
|
-
async respond(instance:ODCommandResponderInstance,
|
|
484
|
+
async respond(instance:ODCommandResponderInstance, origin:Origin, params:Params){
|
|
485
485
|
//wait for workers to finish
|
|
486
|
-
await this.workers.executeWorkers(instance,
|
|
486
|
+
await this.workers.executeWorkers(instance,origin,params)
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
/**## ODButtonResponderManagerIdConstraint `type`
|
|
491
491
|
* The constraint/layout for id mappings/interfaces of the `ODButtonResponderManager` class.
|
|
492
492
|
*/
|
|
493
|
-
export type ODButtonResponderManagerIdConstraint = Record<string,{
|
|
493
|
+
export type ODButtonResponderManagerIdConstraint = Record<string,{origin:"button",params:object,workers:string}>
|
|
494
494
|
|
|
495
495
|
/**## ODButtonResponderManager `class`
|
|
496
496
|
* This is an Open Discord button responder manager.
|
|
@@ -543,14 +543,14 @@ export class ODButtonResponderManager<IdList extends ODButtonResponderManagerIdC
|
|
|
543
543
|
return res
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
-
get<ButtonResponderId extends keyof ODNoGeneric<IdList>>(id:ButtonResponderId): ODButtonResponder<IdList[ButtonResponderId]["
|
|
546
|
+
get<ButtonResponderId extends keyof ODNoGeneric<IdList>>(id:ButtonResponderId): ODButtonResponder<IdList[ButtonResponderId]["origin"],IdList[ButtonResponderId]["params"],IdList[ButtonResponderId]["workers"]>
|
|
547
547
|
get(id:ODValidId): ODButtonResponder<"button",any>|null
|
|
548
548
|
|
|
549
549
|
get(id:ODValidId): ODButtonResponder<"button",any>|null {
|
|
550
550
|
return super.get(id)
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
remove<ButtonResponderId extends keyof ODNoGeneric<IdList>>(id:ButtonResponderId): ODButtonResponder<IdList[ButtonResponderId]["
|
|
553
|
+
remove<ButtonResponderId extends keyof ODNoGeneric<IdList>>(id:ButtonResponderId): ODButtonResponder<IdList[ButtonResponderId]["origin"],IdList[ButtonResponderId]["params"],IdList[ButtonResponderId]["workers"]>
|
|
554
554
|
remove(id:ODValidId): ODButtonResponder<"button",any>|null
|
|
555
555
|
|
|
556
556
|
remove(id:ODValidId): ODButtonResponder<"button",any>|null {
|
|
@@ -703,18 +703,18 @@ export class ODButtonResponderInstance {
|
|
|
703
703
|
*
|
|
704
704
|
* This class manages all workers which are executed when the related button is triggered.
|
|
705
705
|
*/
|
|
706
|
-
export class ODButtonResponder<
|
|
706
|
+
export class ODButtonResponder<Origin extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODButtonResponderInstance,Origin,Params,WorkerIds> {
|
|
707
707
|
/**Respond to this button */
|
|
708
|
-
async respond(instance:ODButtonResponderInstance,
|
|
708
|
+
async respond(instance:ODButtonResponderInstance, origin:Origin, params:Params){
|
|
709
709
|
//wait for workers to finish
|
|
710
|
-
await this.workers.executeWorkers(instance,
|
|
710
|
+
await this.workers.executeWorkers(instance,origin,params)
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
713
|
|
|
714
714
|
/**## ODDropdownResponderManagerIdConstraint `type`
|
|
715
715
|
* The constraint/layout for id mappings/interfaces of the `ODDropdownResponderManager` class.
|
|
716
716
|
*/
|
|
717
|
-
export type ODDropdownResponderManagerIdConstraint = Record<string,{
|
|
717
|
+
export type ODDropdownResponderManagerIdConstraint = Record<string,{origin:"dropdown",params:object,workers:string}>
|
|
718
718
|
|
|
719
719
|
/**## ODDropdownResponderManager `class`
|
|
720
720
|
* This is an Open Discord dropdown responder manager.
|
|
@@ -767,14 +767,14 @@ export class ODDropdownResponderManager<IdList extends ODDropdownResponderManage
|
|
|
767
767
|
return res
|
|
768
768
|
}
|
|
769
769
|
|
|
770
|
-
get<DropdownResponderId extends keyof ODNoGeneric<IdList>>(id:DropdownResponderId): ODDropdownResponder<IdList[DropdownResponderId]["
|
|
770
|
+
get<DropdownResponderId extends keyof ODNoGeneric<IdList>>(id:DropdownResponderId): ODDropdownResponder<IdList[DropdownResponderId]["origin"],IdList[DropdownResponderId]["params"],IdList[DropdownResponderId]["workers"]>
|
|
771
771
|
get(id:ODValidId): ODDropdownResponder<"dropdown",any>|null
|
|
772
772
|
|
|
773
773
|
get(id:ODValidId): ODDropdownResponder<"dropdown",any>|null {
|
|
774
774
|
return super.get(id)
|
|
775
775
|
}
|
|
776
776
|
|
|
777
|
-
remove<DropdownResponderId extends keyof ODNoGeneric<IdList>>(id:DropdownResponderId): ODDropdownResponder<IdList[DropdownResponderId]["
|
|
777
|
+
remove<DropdownResponderId extends keyof ODNoGeneric<IdList>>(id:DropdownResponderId): ODDropdownResponder<IdList[DropdownResponderId]["origin"],IdList[DropdownResponderId]["params"],IdList[DropdownResponderId]["workers"]>
|
|
778
778
|
remove(id:ODValidId): ODDropdownResponder<"dropdown",any>|null
|
|
779
779
|
|
|
780
780
|
remove(id:ODValidId): ODDropdownResponder<"dropdown",any>|null {
|
|
@@ -1018,18 +1018,18 @@ export class ODDropdownResponderInstance {
|
|
|
1018
1018
|
*
|
|
1019
1019
|
* This class manages all workers which are executed when the related dropdown is triggered.
|
|
1020
1020
|
*/
|
|
1021
|
-
export class ODDropdownResponder<
|
|
1021
|
+
export class ODDropdownResponder<Origin extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODDropdownResponderInstance,Origin,Params,WorkerIds> {
|
|
1022
1022
|
/**Respond to this dropdown */
|
|
1023
|
-
async respond(instance:ODDropdownResponderInstance,
|
|
1023
|
+
async respond(instance:ODDropdownResponderInstance, origin:Origin, params:Params){
|
|
1024
1024
|
//wait for workers to finish
|
|
1025
|
-
await this.workers.executeWorkers(instance,
|
|
1025
|
+
await this.workers.executeWorkers(instance,origin,params)
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
1028
|
|
|
1029
1029
|
/**## ODModalResponderManagerIdConstraint `type`
|
|
1030
1030
|
* The constraint/layout for id mappings/interfaces of the `ODModalResponderManager` class.
|
|
1031
1031
|
*/
|
|
1032
|
-
export type ODModalResponderManagerIdConstraint = Record<string,{
|
|
1032
|
+
export type ODModalResponderManagerIdConstraint = Record<string,{origin:"modal",params:object,workers:string}>
|
|
1033
1033
|
|
|
1034
1034
|
/**## ODModalResponderManager `class`
|
|
1035
1035
|
* This is an Open Discord modal responder manager.
|
|
@@ -1082,14 +1082,14 @@ export class ODModalResponderManager<IdList extends ODModalResponderManagerIdCon
|
|
|
1082
1082
|
return res
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
1085
|
-
get<ModalResponderId extends keyof ODNoGeneric<IdList>>(id:ModalResponderId): ODModalResponder<IdList[ModalResponderId]["
|
|
1085
|
+
get<ModalResponderId extends keyof ODNoGeneric<IdList>>(id:ModalResponderId): ODModalResponder<IdList[ModalResponderId]["origin"],IdList[ModalResponderId]["params"],IdList[ModalResponderId]["workers"]>
|
|
1086
1086
|
get(id:ODValidId): ODModalResponder<"modal",any>|null
|
|
1087
1087
|
|
|
1088
1088
|
get(id:ODValidId): ODModalResponder<"modal",any>|null {
|
|
1089
1089
|
return super.get(id)
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
1092
|
-
remove<ModalResponderId extends keyof ODNoGeneric<IdList>>(id:ModalResponderId): ODModalResponder<IdList[ModalResponderId]["
|
|
1092
|
+
remove<ModalResponderId extends keyof ODNoGeneric<IdList>>(id:ModalResponderId): ODModalResponder<IdList[ModalResponderId]["origin"],IdList[ModalResponderId]["params"],IdList[ModalResponderId]["workers"]>
|
|
1093
1093
|
remove(id:ODValidId): ODModalResponder<"modal",any>|null
|
|
1094
1094
|
|
|
1095
1095
|
remove(id:ODValidId): ODModalResponder<"modal",any>|null {
|
|
@@ -1225,18 +1225,18 @@ export class ODModalResponderInstance {
|
|
|
1225
1225
|
*
|
|
1226
1226
|
* This class manages all workers which are executed when the related modal is triggered.
|
|
1227
1227
|
*/
|
|
1228
|
-
export class ODModalResponder<
|
|
1228
|
+
export class ODModalResponder<Origin extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODModalResponderInstance,Origin,Params,WorkerIds> {
|
|
1229
1229
|
/**Respond to this modal */
|
|
1230
|
-
async respond(instance:ODModalResponderInstance,
|
|
1230
|
+
async respond(instance:ODModalResponderInstance, origin:Origin, params:Params){
|
|
1231
1231
|
//wait for workers to finish
|
|
1232
|
-
await this.workers.executeWorkers(instance,
|
|
1232
|
+
await this.workers.executeWorkers(instance,origin,params)
|
|
1233
1233
|
}
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
1236
1236
|
/**## ODContextMenuResponderManagerIdConstraint `type`
|
|
1237
1237
|
* The constraint/layout for id mappings/interfaces of the `ODContextMenuResponderManager` class.
|
|
1238
1238
|
*/
|
|
1239
|
-
export type ODContextMenuResponderManagerIdConstraint = Record<string,{
|
|
1239
|
+
export type ODContextMenuResponderManagerIdConstraint = Record<string,{origin:"context-menu",params:object,workers:string}>
|
|
1240
1240
|
|
|
1241
1241
|
/**## ODContextMenuResponderManager `class`
|
|
1242
1242
|
* This is an Open Discord context menu responder manager.
|
|
@@ -1282,14 +1282,14 @@ export class ODContextMenuResponderManager<IdList extends ODContextMenuResponder
|
|
|
1282
1282
|
return res
|
|
1283
1283
|
}
|
|
1284
1284
|
|
|
1285
|
-
get<ModalResponderId extends keyof ODNoGeneric<IdList>>(id:ModalResponderId): ODContextMenuResponder<IdList[ModalResponderId]["
|
|
1285
|
+
get<ModalResponderId extends keyof ODNoGeneric<IdList>>(id:ModalResponderId): ODContextMenuResponder<IdList[ModalResponderId]["origin"],IdList[ModalResponderId]["params"],IdList[ModalResponderId]["workers"]>
|
|
1286
1286
|
get(id:ODValidId): ODContextMenuResponder<"context-menu",any>|null
|
|
1287
1287
|
|
|
1288
1288
|
get(id:ODValidId): ODContextMenuResponder<"context-menu",any>|null {
|
|
1289
1289
|
return super.get(id)
|
|
1290
1290
|
}
|
|
1291
1291
|
|
|
1292
|
-
remove<ModalResponderId extends keyof ODNoGeneric<IdList>>(id:ModalResponderId): ODContextMenuResponder<IdList[ModalResponderId]["
|
|
1292
|
+
remove<ModalResponderId extends keyof ODNoGeneric<IdList>>(id:ModalResponderId): ODContextMenuResponder<IdList[ModalResponderId]["origin"],IdList[ModalResponderId]["params"],IdList[ModalResponderId]["workers"]>
|
|
1293
1293
|
remove(id:ODValidId): ODContextMenuResponder<"context-menu",any>|null
|
|
1294
1294
|
|
|
1295
1295
|
remove(id:ODValidId): ODContextMenuResponder<"context-menu",any>|null {
|
|
@@ -1411,18 +1411,18 @@ export class ODContextMenuResponderInstance {
|
|
|
1411
1411
|
*
|
|
1412
1412
|
* This class manages all workers which are executed when the related context menu is triggered.
|
|
1413
1413
|
*/
|
|
1414
|
-
export class ODContextMenuResponder<
|
|
1414
|
+
export class ODContextMenuResponder<Origin extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODContextMenuResponderInstance,Origin,Params,WorkerIds> {
|
|
1415
1415
|
/**Respond to this button */
|
|
1416
|
-
async respond(instance:ODContextMenuResponderInstance,
|
|
1416
|
+
async respond(instance:ODContextMenuResponderInstance, origin:Origin, params:Params){
|
|
1417
1417
|
//wait for workers to finish
|
|
1418
|
-
await this.workers.executeWorkers(instance,
|
|
1418
|
+
await this.workers.executeWorkers(instance,origin,params)
|
|
1419
1419
|
}
|
|
1420
1420
|
}
|
|
1421
1421
|
|
|
1422
1422
|
/**## ODAutocompleteResponderManagerIdConstraint `type`
|
|
1423
1423
|
* The constraint/layout for id mappings/interfaces of the `ODAutocompleteResponderManager` class.
|
|
1424
1424
|
*/
|
|
1425
|
-
export type ODAutocompleteResponderManagerIdConstraint = Record<string,{
|
|
1425
|
+
export type ODAutocompleteResponderManagerIdConstraint = Record<string,{origin:"autocomplete",params:object,workers:string}>
|
|
1426
1426
|
|
|
1427
1427
|
/**## ODAutocompleteResponderManager `class`
|
|
1428
1428
|
* This is an Open Discord autocomplete responder manager.
|
|
@@ -1468,14 +1468,14 @@ export class ODAutocompleteResponderManager<IdList extends ODAutocompleteRespond
|
|
|
1468
1468
|
return res
|
|
1469
1469
|
}
|
|
1470
1470
|
|
|
1471
|
-
get<AutocompleteResponderId extends keyof ODNoGeneric<IdList>>(id:AutocompleteResponderId): ODAutocompleteResponder<IdList[AutocompleteResponderId]["
|
|
1471
|
+
get<AutocompleteResponderId extends keyof ODNoGeneric<IdList>>(id:AutocompleteResponderId): ODAutocompleteResponder<IdList[AutocompleteResponderId]["origin"],IdList[AutocompleteResponderId]["params"],IdList[AutocompleteResponderId]["workers"]>
|
|
1472
1472
|
get(id:ODValidId): ODAutocompleteResponder<"autocomplete",any>|null
|
|
1473
1473
|
|
|
1474
1474
|
get(id:ODValidId): ODAutocompleteResponder<"autocomplete",any>|null {
|
|
1475
1475
|
return super.get(id)
|
|
1476
1476
|
}
|
|
1477
1477
|
|
|
1478
|
-
remove<AutocompleteResponderId extends keyof ODNoGeneric<IdList>>(id:AutocompleteResponderId): ODAutocompleteResponder<IdList[AutocompleteResponderId]["
|
|
1478
|
+
remove<AutocompleteResponderId extends keyof ODNoGeneric<IdList>>(id:AutocompleteResponderId): ODAutocompleteResponder<IdList[AutocompleteResponderId]["origin"],IdList[AutocompleteResponderId]["params"],IdList[AutocompleteResponderId]["workers"]>
|
|
1479
1479
|
remove(id:ODValidId): ODAutocompleteResponder<"autocomplete",any>|null
|
|
1480
1480
|
|
|
1481
1481
|
remove(id:ODValidId): ODAutocompleteResponder<"autocomplete",any>|null {
|
|
@@ -1564,18 +1564,18 @@ export class ODAutocompleteResponderInstance {
|
|
|
1564
1564
|
*
|
|
1565
1565
|
* This class manages all workers which are executed when the related autocomplete is triggered.
|
|
1566
1566
|
*/
|
|
1567
|
-
export class ODAutocompleteResponder<
|
|
1567
|
+
export class ODAutocompleteResponder<Origin extends string,Params,WorkerIds extends string = string> extends ODResponderImplementation<ODAutocompleteResponderInstance,Origin,Params,WorkerIds> {
|
|
1568
1568
|
/**The slash command of the autocomplete should match the following regex. */
|
|
1569
1569
|
cmdMatch: string|RegExp
|
|
1570
1570
|
|
|
1571
|
-
constructor(id:ODValidId,cmdMatch:string|RegExp,match:string|RegExp,callback?:ODWorkerCallback<ODAutocompleteResponderInstance,
|
|
1571
|
+
constructor(id:ODValidId,cmdMatch:string|RegExp,match:string|RegExp,callback?:ODWorkerCallback<ODAutocompleteResponderInstance,Origin,Params>,priority?:number,callbackId?:ODValidId){
|
|
1572
1572
|
super(id,match,callback,priority,callbackId)
|
|
1573
1573
|
this.cmdMatch = cmdMatch
|
|
1574
1574
|
}
|
|
1575
1575
|
|
|
1576
1576
|
/**Respond to this autocomplete interaction. */
|
|
1577
|
-
async respond(instance:ODAutocompleteResponderInstance,
|
|
1577
|
+
async respond(instance:ODAutocompleteResponderInstance, origin:Origin, params:Params){
|
|
1578
1578
|
//wait for workers to finish
|
|
1579
|
-
await this.workers.executeWorkers(instance,
|
|
1579
|
+
await this.workers.executeWorkers(instance,origin,params)
|
|
1580
1580
|
}
|
|
1581
1581
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//SESSION MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base"
|
|
5
|
-
import { ODDebugger } from "./console"
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js"
|
|
5
|
+
import { ODDebugger } from "./console.js"
|
|
6
6
|
import * as crypto from "crypto"
|
|
7
7
|
|
|
8
8
|
/**## ODSessionManagerIdConstraint `type`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//STARTSCREEN MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base"
|
|
5
|
-
import { ODDebugger, ODError, ODLiveStatusManager, ODLiveStatusManagerIdConstraint } from "./console"
|
|
6
|
-
import { ODFlag } from "./flag"
|
|
7
|
-
import { ODPlugin, ODUnknownCrashedPlugin } from "./plugin"
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js"
|
|
5
|
+
import { ODDebugger, ODError, ODLiveStatusManager, ODLiveStatusManagerIdConstraint } from "./console.js"
|
|
6
|
+
import { ODFlag } from "./flag.js"
|
|
7
|
+
import { ODPlugin, ODUnknownCrashedPlugin } from "./plugin.js"
|
|
8
8
|
import ansis from "ansis"
|
|
9
9
|
|
|
10
10
|
/**## ODStartScreenComponentRenderCallback `type`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//STATISTIC MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODSystemError, ODValidId } from "./base"
|
|
5
|
-
import { ODDebugger } from "./console"
|
|
6
|
-
import { ODDatabase, ODDatabaseIdConstraint, ODJsonDatabaseStructure } from "./database"
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODSystemError, ODValidId } from "./base.js"
|
|
5
|
+
import { ODDebugger } from "./console.js"
|
|
6
|
+
import { ODDatabase, ODDatabaseIdConstraint, ODJsonDatabaseStructure } from "./database.js"
|
|
7
7
|
import * as discord from "discord.js"
|
|
8
8
|
|
|
9
9
|
/**## ODValidStatisticValue `type`
|
|
@@ -91,7 +91,6 @@ export class ODStatisticManager<IdList extends ODStatisticManagerIdConstraint =
|
|
|
91
91
|
if (!this.database) return
|
|
92
92
|
const data = await this.database.getAll()
|
|
93
93
|
for (const d of data){
|
|
94
|
-
if (!this.database) return
|
|
95
94
|
await this.database.delete(d.category,d.key)
|
|
96
95
|
}
|
|
97
96
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//VERIFYBAR MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base"
|
|
5
|
-
import { ODMessage } from "./builder"
|
|
6
|
-
import { ODDebugger } from "./console"
|
|
7
|
-
import { ODButtonResponderInstance } from "./responder"
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js"
|
|
5
|
+
import { ODMessage } from "./builder.js"
|
|
6
|
+
import { ODDebugger } from "./console.js"
|
|
7
|
+
import { ODButtonResponderInstance } from "./responder.js"
|
|
8
8
|
import * as discord from "discord.js"
|
|
9
|
-
import { ODWorkerManager } from "./worker"
|
|
9
|
+
import { ODWorkerManager } from "./worker.js"
|
|
10
10
|
|
|
11
11
|
/**## ODVerifyBar `class`
|
|
12
12
|
* This is an Open Discord verifybar.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//WORKER MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODId, ODManager, ODManagerData, ODValidId } from "./base"
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODSystemError, ODValidId } from "./base.js"
|
|
5
5
|
|
|
6
6
|
/**## ODWorkerCallback `type`
|
|
7
7
|
* This is the callback used in `ODWorker`!
|
|
8
8
|
*/
|
|
9
|
-
export type ODWorkerCallback<Instance,
|
|
9
|
+
export type ODWorkerCallback<Instance, Origin extends string, Params> = (instance:Instance, params:Params, origin:Origin, cancel:() => void) => void|Promise<void>
|
|
10
10
|
|
|
11
11
|
/**## ODWorker `class`
|
|
12
12
|
* This is an Open Discord worker.
|
|
@@ -15,16 +15,16 @@ export type ODWorkerCallback<Instance, Source extends string, Params> = (instanc
|
|
|
15
15
|
*
|
|
16
16
|
* - It has an `id` for identification of the function
|
|
17
17
|
* - A `priority` to know when to execute this callback (related to others)
|
|
18
|
-
* - It knows who called this callback (`
|
|
18
|
+
* - It knows who called this callback (`origin`)
|
|
19
19
|
* - And much more!
|
|
20
20
|
*/
|
|
21
|
-
export class ODWorker<Instance,
|
|
21
|
+
export class ODWorker<Instance, Origin extends string, Params> extends ODManagerData {
|
|
22
22
|
/**The priority of this worker */
|
|
23
23
|
priority: number
|
|
24
24
|
/**The main callback of this worker */
|
|
25
|
-
callback: ODWorkerCallback<Instance,
|
|
25
|
+
callback: ODWorkerCallback<Instance,Origin,Params>
|
|
26
26
|
|
|
27
|
-
constructor(id:ODValidId, priority:number, callback:ODWorkerCallback<Instance,
|
|
27
|
+
constructor(id:ODValidId, priority:number, callback:ODWorkerCallback<Instance,Origin,Params>){
|
|
28
28
|
super(id)
|
|
29
29
|
this.priority = priority
|
|
30
30
|
this.callback = callback
|
|
@@ -38,11 +38,11 @@ export class ODWorker<Instance, Source extends string, Params> extends ODManager
|
|
|
38
38
|
*
|
|
39
39
|
* You can register a custom worker in this class to create a message or button.
|
|
40
40
|
*/
|
|
41
|
-
export class ODWorkerManager<Instance,
|
|
41
|
+
export class ODWorkerManager<Instance, Origin extends string, Params,WorkerIds extends string = string> extends ODManager<ODWorker<Instance,Origin,Params>> {
|
|
42
42
|
/**The order of execution for workers inside this manager. */
|
|
43
43
|
#priorityOrder: "ascending"|"descending"
|
|
44
44
|
/**The backup worker will be executed when one of the workers fails or cancels execution. */
|
|
45
|
-
backupWorker: ODWorker<{reason:"error"|"cancel"},
|
|
45
|
+
backupWorker: ODWorker<{reason:"error"|"cancel"},Origin,Params>|null = null
|
|
46
46
|
|
|
47
47
|
constructor(priorityOrder:"ascending"|"descending"){
|
|
48
48
|
super()
|
|
@@ -58,8 +58,8 @@ export class ODWorkerManager<Instance, Source extends string, Params,WorkerIds e
|
|
|
58
58
|
else return b.priority-a.priority
|
|
59
59
|
})
|
|
60
60
|
}
|
|
61
|
-
/**Execute all workers on an instance using the given
|
|
62
|
-
async executeWorkers(instance:Instance,
|
|
61
|
+
/**Execute all workers on an instance using the given origin & parameters. */
|
|
62
|
+
async executeWorkers(instance:Instance, origin:Origin, params:Params){
|
|
63
63
|
const derefParams = {...params}
|
|
64
64
|
const workers = this.getSortedWorkers(this.#priorityOrder)
|
|
65
65
|
let didCancel = false
|
|
@@ -68,40 +68,40 @@ export class ODWorkerManager<Instance, Source extends string, Params,WorkerIds e
|
|
|
68
68
|
for (const worker of workers){
|
|
69
69
|
if (didCancel) break
|
|
70
70
|
try {
|
|
71
|
-
await worker.callback(instance,derefParams,
|
|
71
|
+
await worker.callback(instance,derefParams,origin,() => {
|
|
72
72
|
didCancel = true
|
|
73
73
|
})
|
|
74
|
-
}catch(err){
|
|
75
|
-
process.emit("uncaughtException",err)
|
|
74
|
+
}catch(err:any){
|
|
75
|
+
process.emit("uncaughtException",new ODSystemError(err))
|
|
76
76
|
didCrash = true
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
if (didCancel && this.backupWorker){
|
|
80
80
|
try{
|
|
81
|
-
await this.backupWorker.callback({reason:"cancel"},derefParams,
|
|
82
|
-
}catch(err){
|
|
83
|
-
process.emit("uncaughtException",err)
|
|
81
|
+
await this.backupWorker.callback({reason:"cancel"},derefParams,origin,() => {})
|
|
82
|
+
}catch(err:any){
|
|
83
|
+
process.emit("uncaughtException",new ODSystemError(err))
|
|
84
84
|
}
|
|
85
85
|
}else if (didCrash && this.backupWorker){
|
|
86
86
|
try{
|
|
87
|
-
await this.backupWorker.callback({reason:"error"},derefParams,
|
|
88
|
-
}catch(err){
|
|
89
|
-
process.emit("uncaughtException",err)
|
|
87
|
+
await this.backupWorker.callback({reason:"error"},derefParams,origin,() => {})
|
|
88
|
+
}catch(err:any){
|
|
89
|
+
process.emit("uncaughtException",new ODSystemError(err))
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
get(id:WorkerIds): ODWorker<Instance,
|
|
95
|
-
get(id:ODValidId): ODWorker<Instance,
|
|
94
|
+
get(id:WorkerIds): ODWorker<Instance,Origin,Params>
|
|
95
|
+
get(id:ODValidId): ODWorker<Instance,Origin,Params>|null
|
|
96
96
|
|
|
97
|
-
get(id:ODValidId): ODWorker<Instance,
|
|
97
|
+
get(id:ODValidId): ODWorker<Instance,Origin,Params>|null {
|
|
98
98
|
return super.get(id)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
remove(id:WorkerIds): ODWorker<Instance,
|
|
102
|
-
remove(id:ODValidId): ODWorker<Instance,
|
|
101
|
+
remove(id:WorkerIds): ODWorker<Instance,Origin,Params>
|
|
102
|
+
remove(id:ODValidId): ODWorker<Instance,Origin,Params>|null
|
|
103
103
|
|
|
104
|
-
remove(id:ODValidId): ODWorker<Instance,
|
|
104
|
+
remove(id:ODValidId): ODWorker<Instance,Origin,Params>|null {
|
|
105
105
|
return super.remove(id)
|
|
106
106
|
}
|
|
107
107
|
|