@open-discord-bots/framework 0.5.2 → 0.5.3
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 +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/main.d.ts +4 -4
- package/dist/api/main.js +3 -3
- package/dist/api/modules/fuse.d.ts +4 -4
- package/dist/api/modules/fuse.js +2 -2
- package/dist/api/modules/task.d.ts +43 -0
- package/dist/api/modules/{code.js → task.js} +15 -15
- package/package.json +1 -1
- package/dist/api/modules/code.d.ts +0 -43
package/dist/api/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export * from "./modules/base.js";
|
|
|
4
4
|
export * from "./modules/builder.js";
|
|
5
5
|
export * from "./modules/checker.js";
|
|
6
6
|
export * from "./modules/client.js";
|
|
7
|
-
export * from "./modules/code.js";
|
|
8
7
|
export * from "./modules/component.js";
|
|
9
8
|
export * from "./modules/config.js";
|
|
10
9
|
export * from "./modules/console.js";
|
|
@@ -24,5 +23,6 @@ export * from "./modules/session.js";
|
|
|
24
23
|
export * from "./modules/startscreen.js";
|
|
25
24
|
export * from "./modules/state.js";
|
|
26
25
|
export * from "./modules/statistic.js";
|
|
26
|
+
export * from "./modules/task.js";
|
|
27
27
|
export * from "./modules/verifybar.js";
|
|
28
28
|
export * from "./modules/worker.js";
|
package/dist/api/index.js
CHANGED
|
@@ -6,7 +6,6 @@ export * from "./modules/base.js";
|
|
|
6
6
|
export * from "./modules/builder.js";
|
|
7
7
|
export * from "./modules/checker.js";
|
|
8
8
|
export * from "./modules/client.js";
|
|
9
|
-
export * from "./modules/code.js";
|
|
10
9
|
export * from "./modules/component.js";
|
|
11
10
|
export * from "./modules/config.js";
|
|
12
11
|
export * from "./modules/console.js";
|
|
@@ -26,5 +25,6 @@ export * from "./modules/session.js";
|
|
|
26
25
|
export * from "./modules/startscreen.js";
|
|
27
26
|
export * from "./modules/state.js";
|
|
28
27
|
export * from "./modules/statistic.js";
|
|
28
|
+
export * from "./modules/task.js";
|
|
29
29
|
export * from "./modules/verifybar.js";
|
|
30
30
|
export * from "./modules/worker.js";
|
package/dist/api/main.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { ODPermissionManager } from "./modules/permission.js";
|
|
|
17
17
|
import { ODCooldownManager } from "./modules/cooldown.js";
|
|
18
18
|
import { ODHelpMenuManager } from "./modules/helpmenu.js";
|
|
19
19
|
import { ODStatisticManager } from "./modules/statistic.js";
|
|
20
|
-
import {
|
|
20
|
+
import { ODTaskManager } from "./modules/task.js";
|
|
21
21
|
import { ODPostManager } from "./modules/post.js";
|
|
22
22
|
import { ODClientManager } from "./modules/client.js";
|
|
23
23
|
import { ODSharedFuseManager } from "./modules/fuse.js";
|
|
@@ -80,8 +80,8 @@ export interface ODMainManagers {
|
|
|
80
80
|
helpmenu: ODHelpMenuManager;
|
|
81
81
|
/**The manager that registers, saves & updates statistics in the database. */
|
|
82
82
|
statistics: ODStatisticManager;
|
|
83
|
-
/**A place
|
|
84
|
-
|
|
83
|
+
/**A place to put general-purpose code and background tasks which will execute on startup. */
|
|
84
|
+
tasks: ODTaskManager;
|
|
85
85
|
/**A collection of static Discord post channels. It allows the bot to find back log, transcript or configured channels based on a linked ID. */
|
|
86
86
|
posts: ODPostManager;
|
|
87
87
|
/**A system for tracking messages or linking metadata, states or progress to Discord messages (ID-based). Features automatic garbage collection. */
|
|
@@ -129,7 +129,7 @@ export declare abstract class ODMain implements ODMainManagers {
|
|
|
129
129
|
readonly cooldowns: ODCooldownManager;
|
|
130
130
|
readonly helpmenu: ODHelpMenuManager;
|
|
131
131
|
readonly statistics: ODStatisticManager;
|
|
132
|
-
readonly
|
|
132
|
+
readonly tasks: ODTaskManager;
|
|
133
133
|
readonly posts: ODPostManager;
|
|
134
134
|
readonly states: ODStateManager;
|
|
135
135
|
readonly client: ODClientManager;
|
package/dist/api/main.js
CHANGED
|
@@ -33,7 +33,7 @@ export class ODMain {
|
|
|
33
33
|
cooldowns;
|
|
34
34
|
helpmenu;
|
|
35
35
|
statistics;
|
|
36
|
-
|
|
36
|
+
tasks;
|
|
37
37
|
posts;
|
|
38
38
|
states;
|
|
39
39
|
client;
|
|
@@ -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.5.
|
|
47
|
+
this.versions.add(ODVersion.fromString("opendiscord:api", "v0.5.3"));
|
|
48
48
|
this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
|
|
49
49
|
this.debugfile = managers.debugfile;
|
|
50
50
|
this.console = managers.console;
|
|
@@ -68,7 +68,7 @@ export class ODMain {
|
|
|
68
68
|
this.cooldowns = managers.cooldowns;
|
|
69
69
|
this.helpmenu = managers.helpmenu;
|
|
70
70
|
this.statistics = managers.statistics;
|
|
71
|
-
this.
|
|
71
|
+
this.tasks = managers.tasks;
|
|
72
72
|
this.posts = managers.posts;
|
|
73
73
|
this.states = managers.states;
|
|
74
74
|
this.sharedFuses = managers.sharedFuses;
|
|
@@ -198,10 +198,10 @@ export interface ODSharedFuseList {
|
|
|
198
198
|
statisticLoading: boolean;
|
|
199
199
|
/**Initiate the default Open Discord statistics. */
|
|
200
200
|
statisticInitiating: boolean;
|
|
201
|
-
/**Load the default Open Discord
|
|
202
|
-
|
|
203
|
-
/**Execute the default Open Discord
|
|
204
|
-
|
|
201
|
+
/**Load the default Open Discord task/functions. */
|
|
202
|
+
taskLoading: boolean;
|
|
203
|
+
/**Execute the default Open Discord task/functions. */
|
|
204
|
+
taskExecution: boolean;
|
|
205
205
|
/**Load the default Open Discord livestatus. */
|
|
206
206
|
liveStatusLoading: boolean;
|
|
207
207
|
/**Load the default Open Discord startscreen. */
|
package/dist/api/modules/fuse.js
CHANGED
|
@@ -110,8 +110,8 @@ export class ODSharedFuseManager extends ODFuseManager {
|
|
|
110
110
|
statisticScopesLoading: true,
|
|
111
111
|
statisticLoading: true,
|
|
112
112
|
statisticInitiating: true,
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
taskLoading: true,
|
|
114
|
+
taskExecution: true,
|
|
115
115
|
liveStatusLoading: true,
|
|
116
116
|
startScreenLoading: true,
|
|
117
117
|
startScreenRendering: true,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
|
|
2
|
+
import { ODDebugger } from "./console.js";
|
|
3
|
+
/**## ODTask `class`
|
|
4
|
+
* This is an Open Discord task runner.
|
|
5
|
+
*
|
|
6
|
+
* Use this to execute a function just before the startup screen. (with more than 90% of the code already loaded)
|
|
7
|
+
* You can also specify a priority to change the execution order.
|
|
8
|
+
* In Open Ticket, this is used for the following processes:
|
|
9
|
+
* - Autoclose/delete
|
|
10
|
+
* - Database syncronisation (with tickets, statistics & used options)
|
|
11
|
+
* - Panel auto-update
|
|
12
|
+
* - Database Garbage Collection (removing tickets that don't exist anymore)
|
|
13
|
+
* - And more!
|
|
14
|
+
*/
|
|
15
|
+
export declare class ODTask extends ODManagerData {
|
|
16
|
+
/**The priority of this task */
|
|
17
|
+
priority: number;
|
|
18
|
+
/**The main function of this task */
|
|
19
|
+
func: () => void | Promise<void>;
|
|
20
|
+
constructor(id: ODValidId, priority: number, func: () => void | Promise<void>);
|
|
21
|
+
}
|
|
22
|
+
/**## ODTaskManagerIdConstraint `type`
|
|
23
|
+
* The constraint/layout for id mappings/interfaces of the `ODTaskManager` class.
|
|
24
|
+
*/
|
|
25
|
+
export type ODTaskManagerIdConstraint = Record<string, ODTask>;
|
|
26
|
+
/**## ODTaskManager `class`
|
|
27
|
+
* This is an Open Discord task manager.
|
|
28
|
+
*
|
|
29
|
+
* It manages & executes `ODTask`'s in the correct order.
|
|
30
|
+
*
|
|
31
|
+
* Register functions/tasks that execute just before the startup screen. (with more than 90% of the code already loaded)
|
|
32
|
+
*/
|
|
33
|
+
export declare class ODTaskManager<IdList extends ODTaskManagerIdConstraint = ODTaskManagerIdConstraint> extends ODManager<ODTask> {
|
|
34
|
+
constructor(debug: ODDebugger);
|
|
35
|
+
/**Execute all `ODTask` functions in order of their priority (high to low). */
|
|
36
|
+
execute(): Promise<void>;
|
|
37
|
+
get<TaskId extends keyof ODNoGeneric<IdList>>(id: TaskId): IdList[TaskId];
|
|
38
|
+
get(id: ODValidId): ODTask | null;
|
|
39
|
+
remove<TaskId extends keyof ODNoGeneric<IdList>>(id: TaskId): IdList[TaskId];
|
|
40
|
+
remove(id: ODValidId): ODTask | null;
|
|
41
|
+
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
42
|
+
exists(id: ODValidId): boolean;
|
|
43
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
|
-
//
|
|
2
|
+
//TASK MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
4
|
import { ODManager, ODManagerData } from "./base.js";
|
|
5
|
-
/**##
|
|
6
|
-
* This is an Open Discord
|
|
5
|
+
/**## ODTask `class`
|
|
6
|
+
* This is an Open Discord task runner.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Use this to execute a function just before the startup screen. (with more than 90% of the code already loaded)
|
|
9
9
|
* You can also specify a priority to change the execution order.
|
|
10
|
-
* In Open
|
|
10
|
+
* In Open Ticket, this is used for the following processes:
|
|
11
11
|
* - Autoclose/delete
|
|
12
12
|
* - Database syncronisation (with tickets, statistics & used options)
|
|
13
13
|
* - Panel auto-update
|
|
14
14
|
* - Database Garbage Collection (removing tickets that don't exist anymore)
|
|
15
15
|
* - And more!
|
|
16
16
|
*/
|
|
17
|
-
export class
|
|
18
|
-
/**The priority of this
|
|
17
|
+
export class ODTask extends ODManagerData {
|
|
18
|
+
/**The priority of this task */
|
|
19
19
|
priority;
|
|
20
|
-
/**The main function of this
|
|
20
|
+
/**The main function of this task */
|
|
21
21
|
func;
|
|
22
22
|
constructor(id, priority, func) {
|
|
23
23
|
super(id);
|
|
@@ -25,18 +25,18 @@ export class ODCode extends ODManagerData {
|
|
|
25
25
|
this.func = func;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
/**##
|
|
29
|
-
* This is an Open Discord
|
|
28
|
+
/**## ODTaskManager `class`
|
|
29
|
+
* This is an Open Discord task manager.
|
|
30
30
|
*
|
|
31
|
-
* It manages & executes `
|
|
31
|
+
* It manages & executes `ODTask`'s in the correct order.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
33
|
+
* Register functions/tasks that execute just before the startup screen. (with more than 90% of the code already loaded)
|
|
34
34
|
*/
|
|
35
|
-
export class
|
|
35
|
+
export class ODTaskManager extends ODManager {
|
|
36
36
|
constructor(debug) {
|
|
37
|
-
super(debug, "
|
|
37
|
+
super(debug, "task");
|
|
38
38
|
}
|
|
39
|
-
/**Execute all `
|
|
39
|
+
/**Execute all `ODTask` functions in order of their priority (high to low). */
|
|
40
40
|
async execute() {
|
|
41
41
|
const derefArray = [...this.getAll()];
|
|
42
42
|
const workers = derefArray.sort((a, b) => b.priority - a.priority);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-discord-bots/framework",
|
|
3
3
|
"author": "DJj123dj",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.3",
|
|
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",
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
|
|
2
|
-
import { ODDebugger } from "./console.js";
|
|
3
|
-
/**## ODCode `class`
|
|
4
|
-
* This is an Open Discord code runner.
|
|
5
|
-
*
|
|
6
|
-
* Using this, you're able to execute a function just before the startup screen. (90% of the code is already loaded)
|
|
7
|
-
* You can also specify a priority to change the execution order.
|
|
8
|
-
* In Open Discord, this is used for the following processes:
|
|
9
|
-
* - Autoclose/delete
|
|
10
|
-
* - Database syncronisation (with tickets, statistics & used options)
|
|
11
|
-
* - Panel auto-update
|
|
12
|
-
* - Database Garbage Collection (removing tickets that don't exist anymore)
|
|
13
|
-
* - And more!
|
|
14
|
-
*/
|
|
15
|
-
export declare class ODCode extends ODManagerData {
|
|
16
|
-
/**The priority of this code */
|
|
17
|
-
priority: number;
|
|
18
|
-
/**The main function of this code */
|
|
19
|
-
func: () => void | Promise<void>;
|
|
20
|
-
constructor(id: ODValidId, priority: number, func: () => void | Promise<void>);
|
|
21
|
-
}
|
|
22
|
-
/**## ODCodeManagerIdConstraint `type`
|
|
23
|
-
* The constraint/layout for id mappings/interfaces of the `ODCodeManager` class.
|
|
24
|
-
*/
|
|
25
|
-
export type ODCodeManagerIdConstraint = Record<string, ODCode>;
|
|
26
|
-
/**## ODCodeManager `class`
|
|
27
|
-
* This is an Open Discord code manager.
|
|
28
|
-
*
|
|
29
|
-
* It manages & executes `ODCode`'s in the correct order.
|
|
30
|
-
*
|
|
31
|
-
* Use this to register a function/code which executes just before the startup screen. (90% is already loaded)
|
|
32
|
-
*/
|
|
33
|
-
export declare class ODCodeManager<IdList extends ODCodeManagerIdConstraint = ODCodeManagerIdConstraint> extends ODManager<ODCode> {
|
|
34
|
-
constructor(debug: ODDebugger);
|
|
35
|
-
/**Execute all `ODCode` functions in order of their priority (high to low). */
|
|
36
|
-
execute(): Promise<void>;
|
|
37
|
-
get<CodeId extends keyof ODNoGeneric<IdList>>(id: CodeId): IdList[CodeId];
|
|
38
|
-
get(id: ODValidId): ODCode | null;
|
|
39
|
-
remove<CodeId extends keyof ODNoGeneric<IdList>>(id: CodeId): IdList[CodeId];
|
|
40
|
-
remove(id: ODValidId): ODCode | null;
|
|
41
|
-
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
42
|
-
exists(id: ODValidId): boolean;
|
|
43
|
-
}
|