@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,8 +1,8 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODValidId } from "./base";
|
|
1
|
+
import { ODManager, ODManagerData, ODValidId } from "./base.js";
|
|
2
2
|
/**## ODWorkerCallback `type`
|
|
3
3
|
* This is the callback used in `ODWorker`!
|
|
4
4
|
*/
|
|
5
|
-
export type ODWorkerCallback<Instance,
|
|
5
|
+
export type ODWorkerCallback<Instance, Origin extends string, Params> = (instance: Instance, params: Params, origin: Origin, cancel: () => void) => void | Promise<void>;
|
|
6
6
|
/**## ODWorker `class`
|
|
7
7
|
* This is an Open Discord worker.
|
|
8
8
|
*
|
|
@@ -10,15 +10,15 @@ export type ODWorkerCallback<Instance, Source extends string, Params> = (instanc
|
|
|
10
10
|
*
|
|
11
11
|
* - It has an `id` for identification of the function
|
|
12
12
|
* - A `priority` to know when to execute this callback (related to others)
|
|
13
|
-
* - It knows who called this callback (`
|
|
13
|
+
* - It knows who called this callback (`origin`)
|
|
14
14
|
* - And much more!
|
|
15
15
|
*/
|
|
16
|
-
export declare class ODWorker<Instance,
|
|
16
|
+
export declare class ODWorker<Instance, Origin extends string, Params> extends ODManagerData {
|
|
17
17
|
/**The priority of this worker */
|
|
18
18
|
priority: number;
|
|
19
19
|
/**The main callback of this worker */
|
|
20
|
-
callback: ODWorkerCallback<Instance,
|
|
21
|
-
constructor(id: ODValidId, priority: number, callback: ODWorkerCallback<Instance,
|
|
20
|
+
callback: ODWorkerCallback<Instance, Origin, Params>;
|
|
21
|
+
constructor(id: ODValidId, priority: number, callback: ODWorkerCallback<Instance, Origin, Params>);
|
|
22
22
|
}
|
|
23
23
|
/**## ODWorker `class`
|
|
24
24
|
* This is an Open Discord worker manager.
|
|
@@ -27,21 +27,21 @@ export declare class ODWorker<Instance, Source extends string, Params> extends O
|
|
|
27
27
|
*
|
|
28
28
|
* You can register a custom worker in this class to create a message or button.
|
|
29
29
|
*/
|
|
30
|
-
export declare class ODWorkerManager<Instance,
|
|
30
|
+
export declare class ODWorkerManager<Instance, Origin extends string, Params, WorkerIds extends string = string> extends ODManager<ODWorker<Instance, Origin, Params>> {
|
|
31
31
|
#private;
|
|
32
32
|
/**The backup worker will be executed when one of the workers fails or cancels execution. */
|
|
33
33
|
backupWorker: ODWorker<{
|
|
34
34
|
reason: "error" | "cancel";
|
|
35
|
-
},
|
|
35
|
+
}, Origin, Params> | null;
|
|
36
36
|
constructor(priorityOrder: "ascending" | "descending");
|
|
37
37
|
/**Get all workers in sorted order. */
|
|
38
|
-
getSortedWorkers(priority: "ascending" | "descending"): ODWorker<Instance,
|
|
39
|
-
/**Execute all workers on an instance using the given
|
|
40
|
-
executeWorkers(instance: Instance,
|
|
41
|
-
get(id: WorkerIds): ODWorker<Instance,
|
|
42
|
-
get(id: ODValidId): ODWorker<Instance,
|
|
43
|
-
remove(id: WorkerIds): ODWorker<Instance,
|
|
44
|
-
remove(id: ODValidId): ODWorker<Instance,
|
|
38
|
+
getSortedWorkers(priority: "ascending" | "descending"): ODWorker<Instance, Origin, Params>[];
|
|
39
|
+
/**Execute all workers on an instance using the given origin & parameters. */
|
|
40
|
+
executeWorkers(instance: Instance, origin: Origin, params: Params): Promise<void>;
|
|
41
|
+
get(id: WorkerIds): ODWorker<Instance, Origin, Params>;
|
|
42
|
+
get(id: ODValidId): ODWorker<Instance, Origin, Params> | null;
|
|
43
|
+
remove(id: WorkerIds): ODWorker<Instance, Origin, Params>;
|
|
44
|
+
remove(id: ODValidId): ODWorker<Instance, Origin, Params> | null;
|
|
45
45
|
exists(id: WorkerIds): boolean;
|
|
46
46
|
exists(id: ODValidId): boolean;
|
|
47
47
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ODWorkerManager = exports.ODWorker = void 0;
|
|
4
1
|
///////////////////////////////////////
|
|
5
2
|
//WORKER MODULE
|
|
6
3
|
///////////////////////////////////////
|
|
7
|
-
|
|
4
|
+
import { ODManager, ODManagerData, ODSystemError } from "./base.js";
|
|
8
5
|
/**## ODWorker `class`
|
|
9
6
|
* This is an Open Discord worker.
|
|
10
7
|
*
|
|
@@ -12,10 +9,10 @@ const base_1 = require("./base");
|
|
|
12
9
|
*
|
|
13
10
|
* - It has an `id` for identification of the function
|
|
14
11
|
* - A `priority` to know when to execute this callback (related to others)
|
|
15
|
-
* - It knows who called this callback (`
|
|
12
|
+
* - It knows who called this callback (`origin`)
|
|
16
13
|
* - And much more!
|
|
17
14
|
*/
|
|
18
|
-
class ODWorker extends
|
|
15
|
+
export class ODWorker extends ODManagerData {
|
|
19
16
|
/**The priority of this worker */
|
|
20
17
|
priority;
|
|
21
18
|
/**The main callback of this worker */
|
|
@@ -26,7 +23,6 @@ class ODWorker extends base_1.ODManagerData {
|
|
|
26
23
|
this.callback = callback;
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
exports.ODWorker = ODWorker;
|
|
30
26
|
/**## ODWorker `class`
|
|
31
27
|
* This is an Open Discord worker manager.
|
|
32
28
|
*
|
|
@@ -34,7 +30,7 @@ exports.ODWorker = ODWorker;
|
|
|
34
30
|
*
|
|
35
31
|
* You can register a custom worker in this class to create a message or button.
|
|
36
32
|
*/
|
|
37
|
-
class ODWorkerManager extends
|
|
33
|
+
export class ODWorkerManager extends ODManager {
|
|
38
34
|
/**The order of execution for workers inside this manager. */
|
|
39
35
|
#priorityOrder;
|
|
40
36
|
/**The backup worker will be executed when one of the workers fails or cancels execution. */
|
|
@@ -53,8 +49,8 @@ class ODWorkerManager extends base_1.ODManager {
|
|
|
53
49
|
return b.priority - a.priority;
|
|
54
50
|
});
|
|
55
51
|
}
|
|
56
|
-
/**Execute all workers on an instance using the given
|
|
57
|
-
async executeWorkers(instance,
|
|
52
|
+
/**Execute all workers on an instance using the given origin & parameters. */
|
|
53
|
+
async executeWorkers(instance, origin, params) {
|
|
58
54
|
const derefParams = { ...params };
|
|
59
55
|
const workers = this.getSortedWorkers(this.#priorityOrder);
|
|
60
56
|
let didCancel = false;
|
|
@@ -63,29 +59,29 @@ class ODWorkerManager extends base_1.ODManager {
|
|
|
63
59
|
if (didCancel)
|
|
64
60
|
break;
|
|
65
61
|
try {
|
|
66
|
-
await worker.callback(instance, derefParams,
|
|
62
|
+
await worker.callback(instance, derefParams, origin, () => {
|
|
67
63
|
didCancel = true;
|
|
68
64
|
});
|
|
69
65
|
}
|
|
70
66
|
catch (err) {
|
|
71
|
-
process.emit("uncaughtException", err);
|
|
67
|
+
process.emit("uncaughtException", new ODSystemError(err));
|
|
72
68
|
didCrash = true;
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
71
|
if (didCancel && this.backupWorker) {
|
|
76
72
|
try {
|
|
77
|
-
await this.backupWorker.callback({ reason: "cancel" }, derefParams,
|
|
73
|
+
await this.backupWorker.callback({ reason: "cancel" }, derefParams, origin, () => { });
|
|
78
74
|
}
|
|
79
75
|
catch (err) {
|
|
80
|
-
process.emit("uncaughtException", err);
|
|
76
|
+
process.emit("uncaughtException", new ODSystemError(err));
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
else if (didCrash && this.backupWorker) {
|
|
84
80
|
try {
|
|
85
|
-
await this.backupWorker.callback({ reason: "error" }, derefParams,
|
|
81
|
+
await this.backupWorker.callback({ reason: "error" }, derefParams, origin, () => { });
|
|
86
82
|
}
|
|
87
83
|
catch (err) {
|
|
88
|
-
process.emit("uncaughtException", err);
|
|
84
|
+
process.emit("uncaughtException", new ODSystemError(err));
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
87
|
}
|
|
@@ -99,4 +95,3 @@ class ODWorkerManager extends base_1.ODManager {
|
|
|
99
95
|
return super.exists(id);
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
|
-
exports.ODWorkerManager = ODWorkerManager;
|
package/dist/cli/editConfig.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as api from "../api/index";
|
|
2
|
-
import { ODCliHeaderOpts } from ".";
|
|
1
|
+
import * as api from "../api/index.js";
|
|
2
|
+
import { ODCliHeaderOpts } from "./index.js";
|
|
3
3
|
export declare class ODCliEditConfigInstance {
|
|
4
4
|
private readonly opts;
|
|
5
5
|
private readonly opendiscord;
|