@open-discord-bots/framework 0.2.17 → 0.3.1
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 +16 -15
- package/dist/api/index.js +16 -15
- package/dist/api/main.d.ts +31 -23
- package/dist/api/main.js +3 -1
- package/dist/api/modules/action.d.ts +2 -2
- package/dist/api/modules/action.js +1 -5
- package/dist/api/modules/base.d.ts +29 -11
- package/dist/api/modules/base.js +78 -80
- package/dist/api/modules/builder.d.ts +2 -11
- package/dist/api/modules/builder.js +0 -4
- package/dist/api/modules/checker.d.ts +28 -7
- package/dist/api/modules/checker.js +33 -37
- package/dist/api/modules/client.d.ts +66 -14
- package/dist/api/modules/client.js +146 -132
- package/dist/api/modules/component.d.ts +928 -0
- package/dist/api/modules/component.js +1346 -0
- package/dist/api/modules/config.d.ts +30 -2
- package/dist/api/modules/config.js +90 -7
- package/dist/api/modules/console.d.ts +16 -4
- package/dist/api/modules/console.js +25 -25
- package/dist/api/modules/cooldown.d.ts +5 -5
- package/dist/api/modules/cooldown.js +1 -17
- package/dist/api/modules/database.d.ts +21 -13
- package/dist/api/modules/database.js +0 -23
- package/dist/api/modules/event.d.ts +4 -2
- package/dist/api/modules/event.js +8 -10
- package/dist/api/modules/fuse.d.ts +1 -1
- package/dist/api/modules/helpmenu.d.ts +11 -9
- package/dist/api/modules/helpmenu.js +24 -22
- package/dist/api/modules/language.d.ts +4 -3
- package/dist/api/modules/language.js +9 -16
- package/dist/api/modules/permission.d.ts +10 -1
- package/dist/api/modules/permission.js +17 -20
- package/dist/api/modules/plugin.d.ts +2 -1
- package/dist/api/modules/plugin.js +2 -2
- package/dist/api/modules/post.d.ts +12 -4
- package/dist/api/modules/post.js +36 -10
- package/dist/api/modules/progressbar.d.ts +18 -6
- package/dist/api/modules/progressbar.js +35 -35
- package/dist/api/modules/responder.d.ts +97 -28
- package/dist/api/modules/responder.js +213 -176
- package/dist/api/modules/session.d.ts +11 -2
- package/dist/api/modules/session.js +16 -16
- package/dist/api/modules/startscreen.d.ts +2 -3
- package/dist/api/modules/startscreen.js +8 -9
- package/dist/api/modules/statistic.d.ts +2 -1
- package/dist/api/modules/statistic.js +4 -7
- package/dist/api/modules/worker.d.ts +2 -1
- package/dist/api/modules/worker.js +3 -3
- package/package.json +3 -2
- package/src/api/index.ts +16 -15
- package/src/api/main.ts +33 -24
- package/src/api/modules/action.ts +2 -4
- package/src/api/modules/base.ts +77 -79
- package/src/api/modules/builder.ts +2 -14
- package/src/api/modules/checker.ts +36 -37
- package/src/api/modules/client.ts +144 -136
- package/src/api/modules/component.ts +1826 -0
- package/src/api/modules/config.ts +86 -7
- package/src/api/modules/console.ts +25 -25
- package/src/api/modules/cooldown.ts +8 -13
- package/src/api/modules/database.ts +24 -32
- package/src/api/modules/event.ts +6 -10
- package/src/api/modules/fuse.ts +1 -1
- package/src/api/modules/helpmenu.ts +31 -27
- package/src/api/modules/language.ts +11 -16
- package/src/api/modules/permission.ts +17 -20
- package/src/api/modules/plugin.ts +2 -2
- package/src/api/modules/post.ts +31 -10
- package/src/api/modules/progressbar.ts +36 -37
- package/src/api/modules/responder.ts +234 -185
- package/src/api/modules/session.ts +15 -15
- package/src/api/modules/startscreen.ts +9 -10
- package/src/api/modules/statistic.ts +4 -7
- package/src/api/modules/worker.ts +3 -3
- package/src/api/modules/component.txt +0 -350
|
@@ -41,16 +41,25 @@ export type ODSessionTimeoutCallback = (id: string, timeout: "default" | "custom
|
|
|
41
41
|
/**## ODSession `class`
|
|
42
42
|
* This is an Open Discord session.
|
|
43
43
|
*
|
|
44
|
-
* It can be used to create
|
|
44
|
+
* It can be used to create unique user sessions with an ID. Each session can store additional data which isn't saved to the filesystem.
|
|
45
45
|
* You can almost compare it to the PHP session system.
|
|
46
46
|
*/
|
|
47
47
|
export declare class ODSession extends ODManagerData {
|
|
48
|
-
|
|
48
|
+
/**The history of previously generated instance ids. Used to reduce the risk of generating the same id twice. */
|
|
49
|
+
protected idHistory: string[];
|
|
50
|
+
/**The max length of the instance id history. */
|
|
51
|
+
protected maxIdHistoryLength: number;
|
|
49
52
|
/**An array of all the currently active session instances. */
|
|
50
53
|
sessions: ODSessionInstance[];
|
|
51
54
|
/**The default amount of minutes before a session automatically stops. */
|
|
52
55
|
timeoutMinutes: number;
|
|
56
|
+
/**The id of the auto-timeout session checker interval */
|
|
57
|
+
protected intervalId: NodeJS.Timeout;
|
|
58
|
+
/**Listeners for when a session times-out. */
|
|
59
|
+
protected timeoutListeners: ODSessionTimeoutCallback[];
|
|
53
60
|
constructor(id: ODValidId, intervalSeconds?: number);
|
|
61
|
+
/**Create a unique hex id of 8 characters and add it to the instance id history */
|
|
62
|
+
protected createUniqueId(): string;
|
|
54
63
|
/**Stop the global interval that automatically deletes timed-out sessions. (This action can't be reverted!) */
|
|
55
64
|
stopAutoTimeout(): void;
|
|
56
65
|
/**Start a session instance with data. Returns the unique id required to access the session. */
|
|
@@ -28,26 +28,26 @@ export class ODSessionManager extends ODManager {
|
|
|
28
28
|
/**## ODSession `class`
|
|
29
29
|
* This is an Open Discord session.
|
|
30
30
|
*
|
|
31
|
-
* It can be used to create
|
|
31
|
+
* It can be used to create unique user sessions with an ID. Each session can store additional data which isn't saved to the filesystem.
|
|
32
32
|
* You can almost compare it to the PHP session system.
|
|
33
33
|
*/
|
|
34
34
|
export class ODSession extends ODManagerData {
|
|
35
35
|
/**The history of previously generated instance ids. Used to reduce the risk of generating the same id twice. */
|
|
36
|
-
|
|
36
|
+
idHistory = [];
|
|
37
37
|
/**The max length of the instance id history. */
|
|
38
|
-
|
|
38
|
+
maxIdHistoryLength = 500;
|
|
39
39
|
/**An array of all the currently active session instances. */
|
|
40
40
|
sessions = [];
|
|
41
41
|
/**The default amount of minutes before a session automatically stops. */
|
|
42
42
|
timeoutMinutes = 30;
|
|
43
43
|
/**The id of the auto-timeout session checker interval */
|
|
44
|
-
|
|
44
|
+
intervalId;
|
|
45
45
|
/**Listeners for when a session times-out. */
|
|
46
|
-
|
|
46
|
+
timeoutListeners = [];
|
|
47
47
|
constructor(id, intervalSeconds) {
|
|
48
48
|
super(id);
|
|
49
49
|
//create the auto-timeout session checker
|
|
50
|
-
this
|
|
50
|
+
this.intervalId = setInterval(() => {
|
|
51
51
|
const deletableSessions = [];
|
|
52
52
|
//collect all deletable sessions
|
|
53
53
|
this.sessions.forEach((session) => {
|
|
@@ -65,30 +65,30 @@ export class ODSession extends ODManagerData {
|
|
|
65
65
|
const index = this.sessions.findIndex((s) => s.id === session.instance.id);
|
|
66
66
|
this.sessions.splice(index, 1);
|
|
67
67
|
//emit timeout listeners
|
|
68
|
-
this
|
|
68
|
+
this.timeoutListeners.forEach((cb) => cb(session.instance.id, session.reason, session.instance.data, new Date(session.instance.creation)));
|
|
69
69
|
});
|
|
70
70
|
}, ((intervalSeconds) ? (intervalSeconds * 1000) : 60000));
|
|
71
71
|
}
|
|
72
72
|
/**Create a unique hex id of 8 characters and add it to the instance id history */
|
|
73
|
-
|
|
73
|
+
createUniqueId() {
|
|
74
74
|
const hex = crypto.randomBytes(4).toString("hex");
|
|
75
|
-
if (this
|
|
76
|
-
return this
|
|
75
|
+
if (this.idHistory.includes(hex)) {
|
|
76
|
+
return this.createUniqueId();
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
|
-
this
|
|
80
|
-
if (this
|
|
81
|
-
this
|
|
79
|
+
this.idHistory.push(hex);
|
|
80
|
+
if (this.idHistory.length > this.maxIdHistoryLength)
|
|
81
|
+
this.idHistory.shift();
|
|
82
82
|
return hex;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
/**Stop the global interval that automatically deletes timed-out sessions. (This action can't be reverted!) */
|
|
86
86
|
stopAutoTimeout() {
|
|
87
|
-
clearInterval(this
|
|
87
|
+
clearInterval(this.intervalId);
|
|
88
88
|
}
|
|
89
89
|
/**Start a session instance with data. Returns the unique id required to access the session. */
|
|
90
90
|
start(data) {
|
|
91
|
-
const id = this
|
|
91
|
+
const id = this.createUniqueId();
|
|
92
92
|
this.sessions.push({
|
|
93
93
|
id, data,
|
|
94
94
|
creation: new Date().getTime(),
|
|
@@ -137,6 +137,6 @@ export class ODSession extends ODManagerData {
|
|
|
137
137
|
}
|
|
138
138
|
/**Listen for a session timeout (default or custom) */
|
|
139
139
|
onTimeout(callback) {
|
|
140
|
-
this
|
|
140
|
+
this.timeoutListeners.push(callback);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -17,7 +17,6 @@ export type ODStartScreenManagerIdConstraint = Record<string, ODStartScreenCompo
|
|
|
17
17
|
* The startscreen is the part you see when the bot has started up successfully. (e.g. the Open Discord logo, logs, livestatus, flags, ...)
|
|
18
18
|
*/
|
|
19
19
|
export declare class ODStartScreenManager<IdList extends ODStartScreenManagerIdConstraint = ODStartScreenManagerIdConstraint, LiveStatus extends ODLiveStatusManager = ODLiveStatusManager> extends ODManager<ODStartScreenComponent> {
|
|
20
|
-
#private;
|
|
21
20
|
/**Alias to the livestatus manager. */
|
|
22
21
|
livestatus: LiveStatus;
|
|
23
22
|
constructor(debug: ODDebugger, livestatus: LiveStatus);
|
|
@@ -40,7 +39,7 @@ export declare class ODStartScreenManager<IdList extends ODStartScreenManagerIdC
|
|
|
40
39
|
*
|
|
41
40
|
* It's recommended to use pre-built components except if you really need a custom one.
|
|
42
41
|
*/
|
|
43
|
-
export declare class ODStartScreenComponent extends ODManagerData {
|
|
42
|
+
export declare abstract class ODStartScreenComponent extends ODManagerData {
|
|
44
43
|
/**The priority of this component. */
|
|
45
44
|
priority: number;
|
|
46
45
|
/**An optional render function which will be inserted before the default renderer. */
|
|
@@ -49,7 +48,7 @@ export declare class ODStartScreenComponent extends ODManagerData {
|
|
|
49
48
|
render: ODStartScreenComponentRenderCallback;
|
|
50
49
|
/**An optional render function which will be inserted behind the default renderer. */
|
|
51
50
|
renderAfter: ODStartScreenComponentRenderCallback | null;
|
|
52
|
-
constructor(id: ODValidId, priority: number, render: ODStartScreenComponentRenderCallback);
|
|
51
|
+
constructor(id: ODValidId, priority: number, render: ODStartScreenComponentRenderCallback, renderBefore?: ODStartScreenComponentRenderCallback, renderAfter?: ODStartScreenComponentRenderCallback);
|
|
53
52
|
/**Render this component and combine it with the `renderBefore` & `renderAfter` contents. */
|
|
54
53
|
renderAll(location: number): Promise<string>;
|
|
55
54
|
}
|
|
@@ -11,13 +11,10 @@ import ansis from "ansis";
|
|
|
11
11
|
* The startscreen is the part you see when the bot has started up successfully. (e.g. the Open Discord logo, logs, livestatus, flags, ...)
|
|
12
12
|
*/
|
|
13
13
|
export class ODStartScreenManager extends ODManager {
|
|
14
|
-
/**Alias to the Open Discord debugger. */
|
|
15
|
-
#debug;
|
|
16
14
|
/**Alias to the livestatus manager. */
|
|
17
15
|
livestatus;
|
|
18
16
|
constructor(debug, livestatus) {
|
|
19
17
|
super(debug, "startscreen component");
|
|
20
|
-
this.#debug = debug;
|
|
21
18
|
this.livestatus = livestatus;
|
|
22
19
|
}
|
|
23
20
|
/**Get all components in sorted order. */
|
|
@@ -37,11 +34,11 @@ export class ODStartScreenManager extends ODManager {
|
|
|
37
34
|
try {
|
|
38
35
|
const renderedText = await component.renderAll(location);
|
|
39
36
|
console.log(renderedText);
|
|
40
|
-
this
|
|
37
|
+
this.debug?.console.debugfile.writeText("[STARTSCREEN] Component: \"" + component.id + "\"\n" + ansis.strip(renderedText));
|
|
41
38
|
}
|
|
42
39
|
catch (e) {
|
|
43
|
-
this
|
|
44
|
-
this
|
|
40
|
+
this.debug?.console.log("Unable to render \"" + component.id + "\" startscreen component!", "error");
|
|
41
|
+
this.debug?.console.debugfile.writeErrorMessage(new ODError(e, "uncaughtException"));
|
|
45
42
|
}
|
|
46
43
|
location++;
|
|
47
44
|
}
|
|
@@ -68,15 +65,17 @@ export class ODStartScreenComponent extends ODManagerData {
|
|
|
68
65
|
/**The priority of this component. */
|
|
69
66
|
priority;
|
|
70
67
|
/**An optional render function which will be inserted before the default renderer. */
|
|
71
|
-
renderBefore
|
|
68
|
+
renderBefore;
|
|
72
69
|
/**The render function which will render the contents of this component. */
|
|
73
70
|
render;
|
|
74
71
|
/**An optional render function which will be inserted behind the default renderer. */
|
|
75
|
-
renderAfter
|
|
76
|
-
constructor(id, priority, render) {
|
|
72
|
+
renderAfter;
|
|
73
|
+
constructor(id, priority, render, renderBefore, renderAfter) {
|
|
77
74
|
super(id);
|
|
78
75
|
this.priority = priority;
|
|
79
76
|
this.render = render;
|
|
77
|
+
this.renderBefore = renderBefore ?? null;
|
|
78
|
+
this.renderAfter = renderAfter ?? null;
|
|
80
79
|
}
|
|
81
80
|
/**Render this component and combine it with the `renderBefore` & `renderAfter` contents. */
|
|
82
81
|
async renderAll(location) {
|
|
@@ -29,9 +29,10 @@ export type ODStatisticManagerIdConstraint = Record<string, ODStatisticScope>;
|
|
|
29
29
|
* Statistic can be accessed in the individual scopes.
|
|
30
30
|
*/
|
|
31
31
|
export declare class ODStatisticManager<IdList extends ODStatisticManagerIdConstraint = ODStatisticManagerIdConstraint> extends ODManager<ODStatisticScope> {
|
|
32
|
-
#private;
|
|
33
32
|
/**Alias to Open Discord statistics database. */
|
|
34
33
|
database: ODDatabase<ODDatabaseIdConstraint> | null;
|
|
34
|
+
/**All the listeners for the init event. */
|
|
35
|
+
protected initListeners: ODStatisticManagerInitCallback[];
|
|
35
36
|
constructor(debug: ODDebugger);
|
|
36
37
|
/**Select the database to use to read/write all statistics from/to. */
|
|
37
38
|
useDatabase(database: ODDatabase<ODDatabaseIdConstraint>): void;
|
|
@@ -11,22 +11,19 @@ import { ODId, ODManager, ODManagerData, ODSystemError } from "./base.js";
|
|
|
11
11
|
* Statistic can be accessed in the individual scopes.
|
|
12
12
|
*/
|
|
13
13
|
export class ODStatisticManager extends ODManager {
|
|
14
|
-
/**Alias to Open Discord debugger. */
|
|
15
|
-
#debug;
|
|
16
14
|
/**Alias to Open Discord statistics database. */
|
|
17
15
|
database = null;
|
|
18
16
|
/**All the listeners for the init event. */
|
|
19
|
-
|
|
17
|
+
initListeners = [];
|
|
20
18
|
constructor(debug) {
|
|
21
19
|
super(debug, "statistic scope");
|
|
22
|
-
this.#debug = debug;
|
|
23
20
|
}
|
|
24
21
|
/**Select the database to use to read/write all statistics from/to. */
|
|
25
22
|
useDatabase(database) {
|
|
26
23
|
this.database = database;
|
|
27
24
|
}
|
|
28
25
|
add(data, overwrite) {
|
|
29
|
-
data.useDebug(this
|
|
26
|
+
data.useDebug(this.debug, "stat");
|
|
30
27
|
if (this.database)
|
|
31
28
|
data.useDatabase(this.database);
|
|
32
29
|
return super.add(data, overwrite);
|
|
@@ -48,7 +45,7 @@ export class ODStatisticManager extends ODManager {
|
|
|
48
45
|
deletableStats.push(data);
|
|
49
46
|
});
|
|
50
47
|
//do additional deletion
|
|
51
|
-
for (const cb of this
|
|
48
|
+
for (const cb of this.initListeners) {
|
|
52
49
|
await cb(data, deletableStats);
|
|
53
50
|
}
|
|
54
51
|
//delete all deletable statistics
|
|
@@ -69,7 +66,7 @@ export class ODStatisticManager extends ODManager {
|
|
|
69
66
|
}
|
|
70
67
|
/**Run a function when the statistics are initialized. This can be used to clear statistics from users that left the server or tickets which don't exist anymore. */
|
|
71
68
|
onInit(callback) {
|
|
72
|
-
this
|
|
69
|
+
this.initListeners.push(callback);
|
|
73
70
|
}
|
|
74
71
|
get(id) {
|
|
75
72
|
return super.get(id);
|
|
@@ -28,7 +28,8 @@ export declare class ODWorker<Instance, Origin extends string, Params> extends O
|
|
|
28
28
|
* You can register a custom worker in this class to create a message or button.
|
|
29
29
|
*/
|
|
30
30
|
export declare class ODWorkerManager<Instance, Origin extends string, Params, WorkerIds extends string = string> extends ODManager<ODWorker<Instance, Origin, Params>> {
|
|
31
|
-
|
|
31
|
+
/**The order of execution for workers inside this manager. */
|
|
32
|
+
protected priorityOrder: "ascending" | "descending";
|
|
32
33
|
/**The backup worker will be executed when one of the workers fails or cancels execution. */
|
|
33
34
|
backupWorker: ODWorker<{
|
|
34
35
|
reason: "error" | "cancel";
|
|
@@ -32,12 +32,12 @@ export class ODWorker extends ODManagerData {
|
|
|
32
32
|
*/
|
|
33
33
|
export class ODWorkerManager extends ODManager {
|
|
34
34
|
/**The order of execution for workers inside this manager. */
|
|
35
|
-
|
|
35
|
+
priorityOrder;
|
|
36
36
|
/**The backup worker will be executed when one of the workers fails or cancels execution. */
|
|
37
37
|
backupWorker = null;
|
|
38
38
|
constructor(priorityOrder) {
|
|
39
39
|
super();
|
|
40
|
-
this
|
|
40
|
+
this.priorityOrder = priorityOrder;
|
|
41
41
|
}
|
|
42
42
|
/**Get all workers in sorted order. */
|
|
43
43
|
getSortedWorkers(priority) {
|
|
@@ -52,7 +52,7 @@ export class ODWorkerManager extends ODManager {
|
|
|
52
52
|
/**Execute all workers on an instance using the given origin & parameters. */
|
|
53
53
|
async executeWorkers(instance, origin, params) {
|
|
54
54
|
const derefParams = { ...params };
|
|
55
|
-
const workers = this.getSortedWorkers(this
|
|
55
|
+
const workers = this.getSortedWorkers(this.priorityOrder);
|
|
56
56
|
let didCancel = false;
|
|
57
57
|
let didCrash = false;
|
|
58
58
|
for (const worker of workers) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-discord-bots/framework",
|
|
3
3
|
"author": "DJj123dj",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
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",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"@types/terminal-kit": "^2.5.7",
|
|
17
17
|
"ansis": "^4.2.0",
|
|
18
18
|
"discord.js": "^14.26.3",
|
|
19
|
-
"formatted-json-stringify": "^1.3.
|
|
19
|
+
"formatted-json-stringify": "^1.3.1",
|
|
20
|
+
"jsonc": "^2.0.0",
|
|
20
21
|
"terminal-kit": "^3.1.2",
|
|
21
22
|
"typescript": "^6.0.3"
|
|
22
23
|
},
|
package/src/api/index.ts
CHANGED
|
@@ -2,28 +2,29 @@
|
|
|
2
2
|
export * from "./main.js"
|
|
3
3
|
|
|
4
4
|
//BASE MODULES
|
|
5
|
+
export * from "./modules/action.js"
|
|
5
6
|
export * from "./modules/base.js"
|
|
6
|
-
export * from "./modules/
|
|
7
|
+
export * from "./modules/builder.js"
|
|
8
|
+
export * from "./modules/checker.js"
|
|
9
|
+
export * from "./modules/client.js"
|
|
10
|
+
export * from "./modules/code.js"
|
|
11
|
+
export * from "./modules/component.js"
|
|
7
12
|
export * from "./modules/config.js"
|
|
13
|
+
export * from "./modules/console.js"
|
|
14
|
+
export * from "./modules/cooldown.js"
|
|
8
15
|
export * from "./modules/database.js"
|
|
9
|
-
export * from "./modules/
|
|
16
|
+
export * from "./modules/event.js"
|
|
10
17
|
export * from "./modules/flag.js"
|
|
11
|
-
export * from "./modules/console.js"
|
|
12
18
|
export * from "./modules/fuse.js"
|
|
19
|
+
export * from "./modules/helpmenu.js"
|
|
20
|
+
export * from "./modules/language.js"
|
|
21
|
+
export * from "./modules/permission.js"
|
|
13
22
|
export * from "./modules/plugin.js"
|
|
14
|
-
export * from "./modules/
|
|
15
|
-
export * from "./modules/
|
|
16
|
-
export * from "./modules/worker.js"
|
|
17
|
-
export * from "./modules/builder.js"
|
|
23
|
+
export * from "./modules/post.js"
|
|
24
|
+
export * from "./modules/progressbar.js"
|
|
18
25
|
export * from "./modules/responder.js"
|
|
19
|
-
export * from "./modules/action.js"
|
|
20
|
-
export * from "./modules/permission.js"
|
|
21
|
-
export * from "./modules/helpmenu.js"
|
|
22
26
|
export * from "./modules/session.js"
|
|
27
|
+
export * from "./modules/startscreen.js"
|
|
23
28
|
export * from "./modules/statistic.js"
|
|
24
|
-
export * from "./modules/code.js"
|
|
25
|
-
export * from "./modules/cooldown.js"
|
|
26
|
-
export * from "./modules/post.js"
|
|
27
29
|
export * from "./modules/verifybar.js"
|
|
28
|
-
export * from "./modules/
|
|
29
|
-
export * from "./modules/startscreen.js"
|
|
30
|
+
export * from "./modules/worker.js"
|
package/src/api/main.ts
CHANGED
|
@@ -23,12 +23,13 @@ import { ODPostManager } from "./modules/post.js"
|
|
|
23
23
|
import { ODClientManager } from "./modules/client.js"
|
|
24
24
|
import { ODSharedFuseManager } from "./modules/fuse.js"
|
|
25
25
|
import { ODStartScreenManager } from "./modules/startscreen.js"
|
|
26
|
+
import { ODComponentManager } from "./modules/component.js"
|
|
26
27
|
|
|
27
28
|
/**## ODMainManagers `interface`
|
|
28
29
|
* The global properties for the main class of the bot.
|
|
29
30
|
*/
|
|
30
31
|
export interface ODMainManagers {
|
|
31
|
-
/**
|
|
32
|
+
/**A collection of versions of the bot, systems, frameworks & services. */
|
|
32
33
|
versions: ODVersionManager
|
|
33
34
|
|
|
34
35
|
/**The timestamp that the (node.js) process of the bot started. */
|
|
@@ -49,49 +50,55 @@ export interface ODMainManagers {
|
|
|
49
50
|
plugins: ODPluginManager
|
|
50
51
|
/**The manager that manages & checks all the console flags of the bot. (like `--debug`) */
|
|
51
52
|
flags: ODFlagManager
|
|
52
|
-
/**The manager responsible for progress bars in the console. */
|
|
53
|
+
/**The manager responsible for displaying progress bars in the console. */
|
|
53
54
|
progressbars: ODProgressBarManager
|
|
54
|
-
/**
|
|
55
|
+
/**A collection of all the config files of the bot and plugins. (like `config/general.json`) */
|
|
55
56
|
configs: ODConfigManager
|
|
56
|
-
/**
|
|
57
|
+
/**A collection of all the databases of the bot and plugins. (like `database/global.json`) */
|
|
57
58
|
databases: ODDatabaseManager
|
|
58
|
-
/**
|
|
59
|
+
/**A collection of all the sessions of the bot. (Sessions are temporary objects stored in memory) */
|
|
59
60
|
sessions: ODSessionManager
|
|
60
|
-
/**The manager
|
|
61
|
+
/**The global translation manager which manges all language files, translations & switches between them. (Does not manage translations for plugins) */
|
|
61
62
|
languages: ODLanguageManager
|
|
62
63
|
|
|
63
|
-
/**The manager
|
|
64
|
+
/**The manager responsible for checking the bot & plugin configs. (it checks for mistakes in your config) */
|
|
64
65
|
checkers: ODCheckerManager
|
|
65
|
-
/**
|
|
66
|
+
/**A collection of button, dropdown, embed, ... templates which can be used to construct messages and modals.
|
|
67
|
+
* ### (🚨 Better alternative: `opendiscord.components (ODComponentManager)`)
|
|
68
|
+
*/
|
|
66
69
|
builders: ODBuilderManager
|
|
67
|
-
/**
|
|
70
|
+
/**A collection of building blocks and templates for messages & modals with native support for Discord Components v2. (e.g. buttons, dropdowns, checkboxes, radio groups, file uploads, ...)
|
|
71
|
+
* ### (✅ New replacement for: `opendiscord.builders (ODBuilderManager)`)
|
|
72
|
+
*/
|
|
73
|
+
components: ODComponentManager
|
|
74
|
+
/**The manager that handles responses to all interactions of the bot. (e.g. slash/text commands, buttons, dropdowns, modals) */
|
|
68
75
|
responders: ODResponderManager
|
|
69
|
-
/**
|
|
76
|
+
/**A collection of procedures. A procedure is a complex task which can be executed from multiple responders or events. (e.g. ticket-creation, ticket-deletion, ticket-claiming, ...) */
|
|
70
77
|
actions: ODActionManager
|
|
71
|
-
/**
|
|
78
|
+
/**A collection of verify bars from the bot. (the ✅ ❌ buttons in messages) */
|
|
72
79
|
verifybars: ODVerifyBarManager
|
|
73
|
-
/**
|
|
80
|
+
/**A manager which will help with calculating permissions for commands & actions. */
|
|
74
81
|
permissions: ODPermissionManager
|
|
75
|
-
/**The manager
|
|
82
|
+
/**The manager which will manage cooldowns in the bot. (e.g. ticket-create cooldowns) */
|
|
76
83
|
cooldowns: ODCooldownManager
|
|
77
|
-
/**The manager that
|
|
84
|
+
/**The manager that collects & renders the Open Discord help menu contents. (not the final embed) */
|
|
78
85
|
helpmenu: ODHelpMenuManager
|
|
79
|
-
/**The manager that
|
|
86
|
+
/**The manager that registers, saves & updates statistics in the database. */
|
|
80
87
|
statistics: ODStatisticManager
|
|
81
|
-
/**
|
|
88
|
+
/**A place where you can put general-purpose code which will start on startup of the bot. (Perfect for background tasks) */
|
|
82
89
|
code: ODCodeManager
|
|
83
|
-
/**
|
|
90
|
+
/**A collection of static Discord post channels. It allows the bot to find back log, transcript or configured channels based on a linked ID. */
|
|
84
91
|
posts: ODPostManager
|
|
85
92
|
|
|
86
|
-
/**
|
|
93
|
+
/**A wrapper around the `discord.Client` class. It handles client login, activity and registering text/slash commands. */
|
|
87
94
|
client: ODClientManager
|
|
88
|
-
/**Shared fuses between Open Discord bots.
|
|
95
|
+
/**Shared fuses between Open Discord bots. Turn off "default behaviours" from the bot which is useful for replacing default behaviour with a custom implementation. */
|
|
89
96
|
sharedFuses: ODSharedFuseManager
|
|
90
|
-
/**
|
|
97
|
+
/**A manager which collects variables from the Process ENV and `.env` file. */
|
|
91
98
|
env: ODEnvHelper
|
|
92
|
-
/**
|
|
99
|
+
/**LiveStatus is a protocol which displays live updates from DJdj Development in the startscreen of the bot. (e.g. new version available) */
|
|
93
100
|
livestatus: ODLiveStatusManager
|
|
94
|
-
/**The manager responsible for the
|
|
101
|
+
/**The manager responsible for rendering the startscreen of the bot. */
|
|
95
102
|
startscreen: ODStartScreenManager
|
|
96
103
|
}
|
|
97
104
|
|
|
@@ -101,7 +108,7 @@ export interface ODMainManagers {
|
|
|
101
108
|
*
|
|
102
109
|
* This class can't be overwritten or extended & is available as the global variable `opendiscord`!
|
|
103
110
|
*/
|
|
104
|
-
export class ODMain implements ODMainManagers {
|
|
111
|
+
export abstract class ODMain implements ODMainManagers {
|
|
105
112
|
readonly project: ODProjectType
|
|
106
113
|
|
|
107
114
|
readonly versions: ODVersionManager
|
|
@@ -123,6 +130,7 @@ export class ODMain implements ODMainManagers {
|
|
|
123
130
|
|
|
124
131
|
readonly checkers: ODCheckerManager
|
|
125
132
|
readonly builders: ODBuilderManager
|
|
133
|
+
readonly components: ODComponentManager
|
|
126
134
|
readonly responders: ODResponderManager
|
|
127
135
|
readonly actions: ODActionManager
|
|
128
136
|
readonly verifybars: ODVerifyBarManager
|
|
@@ -142,7 +150,7 @@ export class ODMain implements ODMainManagers {
|
|
|
142
150
|
constructor(managers:ODMainManagers,project:ODProjectType){
|
|
143
151
|
this.project = project
|
|
144
152
|
this.versions = managers.versions
|
|
145
|
-
this.versions.add(ODVersion.fromString("opendiscord:api","v0.
|
|
153
|
+
this.versions.add(ODVersion.fromString("opendiscord:api","v0.3.1"))
|
|
146
154
|
this.versions.add(ODVersion.fromString("opendiscord:livestatus","v2.0.0"))
|
|
147
155
|
|
|
148
156
|
this.debugfile = managers.debugfile
|
|
@@ -160,6 +168,7 @@ export class ODMain implements ODMainManagers {
|
|
|
160
168
|
|
|
161
169
|
this.checkers = managers.checkers
|
|
162
170
|
this.builders = managers.builders
|
|
171
|
+
this.components = managers.components
|
|
163
172
|
this.client = managers.client
|
|
164
173
|
this.responders = managers.responders
|
|
165
174
|
this.actions = managers.actions
|
|
@@ -12,7 +12,7 @@ import { ODDebugger } from "./console.js"
|
|
|
12
12
|
*
|
|
13
13
|
* This class can't be used stand-alone & needs to be extended from!
|
|
14
14
|
*/
|
|
15
|
-
export class ODActionImplementation<Origin extends string,Params extends object,Result extends object,WorkerIds extends string = string> extends ODManagerData {
|
|
15
|
+
export abstract class ODActionImplementation<Origin extends string,Params extends object,Result extends object,WorkerIds extends string = string> extends ODManagerData {
|
|
16
16
|
/**The manager that has all workers of this implementation */
|
|
17
17
|
workers: ODWorkerManager<Partial<Result>,Origin,Params,WorkerIds>
|
|
18
18
|
|
|
@@ -22,9 +22,7 @@ export class ODActionImplementation<Origin extends string,Params extends object,
|
|
|
22
22
|
if (callback) this.workers.add(new ODWorker(callbackId ? callbackId : id,priority ?? 0,callback))
|
|
23
23
|
}
|
|
24
24
|
/**Execute all workers & return the result. */
|
|
25
|
-
|
|
26
|
-
throw new ODSystemError("Tried to build an unimplemented ODResponderImplementation")
|
|
27
|
-
}
|
|
25
|
+
abstract run(origin:Origin, params:Params): Promise<Partial<Result>>
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
/**## ODActionManagerIdConstraint `type`
|