@open-discord-bots/framework 0.2.11 → 0.2.12
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/main.js +1 -1
- package/dist/api/modules/action.d.ts +9 -9
- package/dist/api/modules/action.js +3 -3
- package/dist/api/modules/base.d.ts +5 -3
- package/dist/api/modules/base.js +8 -4
- package/dist/api/modules/builder.d.ts +41 -41
- package/dist/api/modules/builder.js +20 -20
- package/dist/api/modules/checker.d.ts +3 -3
- package/dist/api/modules/client.js +2 -2
- package/dist/api/modules/console.d.ts +15 -15
- package/dist/api/modules/console.js +31 -31
- package/dist/api/modules/event.js +2 -2
- package/dist/api/modules/helpmenu.js +1 -1
- package/dist/api/modules/progressbar.js +1 -0
- package/dist/api/modules/responder.d.ts +37 -37
- package/dist/api/modules/responder.js +13 -13
- package/dist/api/modules/statistic.js +0 -2
- package/dist/api/modules/worker.d.ts +14 -14
- package/dist/api/modules/worker.js +9 -9
- package/dist/cli/editConfig.js +6 -20
- package/dist/startup/pluginLauncher.js +6 -4
- package/dist/utilities/index.d.ts +2 -2
- package/package.json +4 -4
- package/src/api/main.ts +1 -1
- package/src/api/modules/action.ts +10 -10
- package/src/api/modules/base.ts +12 -8
- package/src/api/modules/builder.ts +53 -53
- package/src/api/modules/checker.ts +3 -3
- package/src/api/modules/client.ts +15 -15
- package/src/api/modules/component.txt +350 -0
- package/src/api/modules/config.ts +1 -1
- package/src/api/modules/console.ts +26 -26
- package/src/api/modules/database.ts +1 -1
- package/src/api/modules/event.ts +5 -5
- package/src/api/modules/helpmenu.ts +3 -3
- package/src/api/modules/language.ts +1 -1
- package/src/api/modules/plugin.ts +1 -1
- package/src/api/modules/progressbar.ts +3 -1
- package/src/api/modules/responder.ts +43 -43
- package/src/api/modules/statistic.ts +0 -1
- package/src/api/modules/worker.ts +25 -25
- package/src/cli/editConfig.ts +20 -34
- package/src/startup/compilation.ts +2 -2
- package/src/startup/pluginLauncher.ts +9 -6
- package/src/utilities/index.ts +3 -3
- package/tsconfig.json +1 -0
package/dist/api/main.js
CHANGED
|
@@ -45,7 +45,7 @@ class ODMain {
|
|
|
45
45
|
constructor(managers, project) {
|
|
46
46
|
this.project = project;
|
|
47
47
|
this.versions = managers.versions;
|
|
48
|
-
this.versions.add(base_1.ODVersion.fromString("opendiscord:api", "v0.2.
|
|
48
|
+
this.versions.add(base_1.ODVersion.fromString("opendiscord:api", "v0.2.12"));
|
|
49
49
|
this.versions.add(base_1.ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
|
|
50
50
|
this.debugfile = managers.debugfile;
|
|
51
51
|
this.console = managers.console;
|
|
@@ -8,18 +8,18 @@ import { ODDebugger } from "./console";
|
|
|
8
8
|
*
|
|
9
9
|
* This class can't be used stand-alone & needs to be extended from!
|
|
10
10
|
*/
|
|
11
|
-
export declare class ODActionImplementation<
|
|
11
|
+
export declare class ODActionImplementation<Origin extends string, Params extends object, Result extends object, WorkerIds extends string = string> extends ODManagerData {
|
|
12
12
|
/**The manager that has all workers of this implementation */
|
|
13
|
-
workers: ODWorkerManager<Partial<Result>,
|
|
14
|
-
constructor(id: ODValidId, callback?: ODWorkerCallback<Result
|
|
13
|
+
workers: ODWorkerManager<Partial<Result>, Origin, Params, WorkerIds>;
|
|
14
|
+
constructor(id: ODValidId, callback?: ODWorkerCallback<Partial<Result>, Origin, Params>, priority?: number, callbackId?: ODValidId);
|
|
15
15
|
/**Execute all workers & return the result. */
|
|
16
|
-
run(
|
|
16
|
+
run(origin: Origin, params: Params): Promise<Partial<Result>>;
|
|
17
17
|
}
|
|
18
18
|
/**## ODActionManagerIdConstraint `type`
|
|
19
19
|
* The constraint/layout for id mappings/interfaces of the `ODActionManager` class.
|
|
20
20
|
*/
|
|
21
21
|
export type ODActionManagerIdConstraint = Record<string, {
|
|
22
|
-
|
|
22
|
+
origin: string;
|
|
23
23
|
params: object;
|
|
24
24
|
result: object;
|
|
25
25
|
workers: string;
|
|
@@ -36,9 +36,9 @@ export type ODActionManagerIdConstraint = Record<string, {
|
|
|
36
36
|
*/
|
|
37
37
|
export declare class ODActionManager<IdList extends ODActionManagerIdConstraint = ODActionManagerIdConstraint> extends ODManager<ODAction<string, {}, {}, string>> {
|
|
38
38
|
constructor(debug: ODDebugger);
|
|
39
|
-
get<ActionId extends keyof ODNoGeneric<IdList>>(id: ActionId): ODAction<IdList[ActionId]["
|
|
39
|
+
get<ActionId extends keyof ODNoGeneric<IdList>>(id: ActionId): ODAction<IdList[ActionId]["origin"], IdList[ActionId]["params"], IdList[ActionId]["result"], IdList[ActionId]["workers"]>;
|
|
40
40
|
get(id: ODValidId): ODAction<string, {}, {}, string> | null;
|
|
41
|
-
remove<ActionId extends keyof ODNoGeneric<IdList>>(id: ActionId): ODAction<IdList[ActionId]["
|
|
41
|
+
remove<ActionId extends keyof ODNoGeneric<IdList>>(id: ActionId): ODAction<IdList[ActionId]["origin"], IdList[ActionId]["params"], IdList[ActionId]["result"], IdList[ActionId]["workers"]>;
|
|
42
42
|
remove(id: ODValidId): ODAction<string, {}, {}, string> | null;
|
|
43
43
|
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
44
44
|
exists(id: ODValidId): boolean;
|
|
@@ -50,7 +50,7 @@ export declare class ODActionManager<IdList extends ODActionManagerIdConstraint
|
|
|
50
50
|
*
|
|
51
51
|
* Can be used standalone.
|
|
52
52
|
*/
|
|
53
|
-
export declare class ODAction<
|
|
53
|
+
export declare class ODAction<Origin extends string, Params extends object, Result extends object, WorkerIds extends string = string> extends ODActionImplementation<Origin, Params, Result, WorkerIds> {
|
|
54
54
|
/**Run this action */
|
|
55
|
-
run(
|
|
55
|
+
run(origin: Origin, params: Params): Promise<Partial<Result>>;
|
|
56
56
|
}
|
|
@@ -23,7 +23,7 @@ class ODActionImplementation extends base_1.ODManagerData {
|
|
|
23
23
|
this.workers.add(new worker_1.ODWorker(callbackId ? callbackId : id, priority ?? 0, callback));
|
|
24
24
|
}
|
|
25
25
|
/**Execute all workers & return the result. */
|
|
26
|
-
async run(
|
|
26
|
+
async run(origin, params) {
|
|
27
27
|
throw new base_1.ODSystemError("Tried to build an unimplemented ODResponderImplementation");
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -62,11 +62,11 @@ exports.ODActionManager = ODActionManager;
|
|
|
62
62
|
*/
|
|
63
63
|
class ODAction extends ODActionImplementation {
|
|
64
64
|
/**Run this action */
|
|
65
|
-
async run(
|
|
65
|
+
async run(origin, params) {
|
|
66
66
|
//create instance
|
|
67
67
|
const instance = {};
|
|
68
68
|
//wait for workers to finish
|
|
69
|
-
await this.workers.executeWorkers(instance,
|
|
69
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
70
70
|
//return data generated by workers
|
|
71
71
|
return instance;
|
|
72
72
|
}
|
|
@@ -27,7 +27,9 @@ export type ODValidId = string | number | symbol | ODId;
|
|
|
27
27
|
*
|
|
28
28
|
* list: `string`, `number`, `boolean`, `array`, `object`, `null`
|
|
29
29
|
*/
|
|
30
|
-
export type ODValidJsonType = string | number | boolean |
|
|
30
|
+
export type ODValidJsonType = string | number | boolean | {
|
|
31
|
+
[key: string]: ODValidJsonType;
|
|
32
|
+
} | ODValidJsonType[] | null;
|
|
31
33
|
/**## ODInterfaceWithPartialProperty `type`
|
|
32
34
|
* A utility type to create an interface where some properties are optional!
|
|
33
35
|
*/
|
|
@@ -309,9 +311,9 @@ export declare class ODHTTPPostRequest {
|
|
|
309
311
|
export declare class ODEnvHelper {
|
|
310
312
|
#private;
|
|
311
313
|
/**All variables found in the `.env` file */
|
|
312
|
-
dotenv:
|
|
314
|
+
dotenv: Record<string, any>;
|
|
313
315
|
/**All variables found in `process.env` */
|
|
314
|
-
env:
|
|
316
|
+
env: Record<string, any>;
|
|
315
317
|
constructor(customEnvPath?: string);
|
|
316
318
|
/**Get a variable from the env */
|
|
317
319
|
getVariable(name: string, source?: "dotenv" | "env"): any | undefined;
|
package/dist/api/modules/base.js
CHANGED
|
@@ -792,8 +792,10 @@ class ODSystemError extends Error {
|
|
|
792
792
|
_ODErrorType = "system";
|
|
793
793
|
/**Create an `ODSystemError` directly from an `Error` class */
|
|
794
794
|
static fromError(err) {
|
|
795
|
-
|
|
796
|
-
|
|
795
|
+
const modifiedErr = Object.assign(err, {
|
|
796
|
+
_ODErrorType: "system"
|
|
797
|
+
});
|
|
798
|
+
return modifiedErr;
|
|
797
799
|
}
|
|
798
800
|
}
|
|
799
801
|
exports.ODSystemError = ODSystemError;
|
|
@@ -807,8 +809,10 @@ class ODPluginError extends Error {
|
|
|
807
809
|
_ODErrorType = "plugin";
|
|
808
810
|
/**Create an `ODPluginError` directly from an `Error` class */
|
|
809
811
|
static fromError(err) {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
+
const modifiedErr = Object.assign(err, {
|
|
813
|
+
_ODErrorType: "plugin"
|
|
814
|
+
});
|
|
815
|
+
return modifiedErr;
|
|
812
816
|
}
|
|
813
817
|
}
|
|
814
818
|
exports.ODPluginError = ODPluginError;
|
|
@@ -9,24 +9,24 @@ import { ODDebugger } from "./console";
|
|
|
9
9
|
*
|
|
10
10
|
* This class can't be used stand-alone & needs to be extended from!
|
|
11
11
|
*/
|
|
12
|
-
export declare class ODBuilderImplementation<Instance,
|
|
12
|
+
export declare class ODBuilderImplementation<Instance, Origin extends string, Params, BuildType extends {
|
|
13
13
|
id: ODId;
|
|
14
14
|
}, WorkerIds extends string = string> extends ODManagerData {
|
|
15
15
|
/**The manager that has all workers of this implementation */
|
|
16
|
-
workers: ODWorkerManager<Instance,
|
|
16
|
+
workers: ODWorkerManager<Instance, Origin, Params, WorkerIds>;
|
|
17
17
|
/**Cache a build or create it every time from scratch when this.build() gets executed. */
|
|
18
18
|
allowCache: boolean;
|
|
19
19
|
/**Did the build already got created/cached? */
|
|
20
20
|
didCache: boolean;
|
|
21
21
|
/**The cache of this build. */
|
|
22
22
|
cache: BuildType | null;
|
|
23
|
-
constructor(id: ODValidId, callback?: ODWorkerCallback<Instance,
|
|
23
|
+
constructor(id: ODValidId, callback?: ODWorkerCallback<Instance, Origin, Params>, priority?: number, callbackId?: ODValidId);
|
|
24
24
|
/**Set if caching is allowed */
|
|
25
25
|
setCacheMode(allowed: boolean): this;
|
|
26
26
|
/**Reset the current cache */
|
|
27
27
|
resetCache(): this;
|
|
28
28
|
/**Execute all workers & return the result. */
|
|
29
|
-
build(
|
|
29
|
+
build(origin: Origin, params: Params): Promise<BuildType>;
|
|
30
30
|
}
|
|
31
31
|
/**## ODBuilderManager `class`
|
|
32
32
|
* This is an Open Discord builder manager.
|
|
@@ -39,7 +39,7 @@ export declare class ODBuilderImplementation<Instance, Source extends string, Pa
|
|
|
39
39
|
* - independent workers (with priority)
|
|
40
40
|
* - fail-safe design using try-catch
|
|
41
41
|
* - cache frequently used objects
|
|
42
|
-
* - get to know the
|
|
42
|
+
* - get to know the origin of the build request for a specific message, button, etc
|
|
43
43
|
* - And so much more!
|
|
44
44
|
*/
|
|
45
45
|
export declare class ODBuilderManager<ButtonIdList extends ODButtonManagerIdConstraint = ODButtonManagerIdConstraint, DropdownIdList extends ODDropdownManagerIdConstraint = ODDropdownManagerIdConstraint, FileIdList extends ODFileManagerIdConstraint = ODFileManagerIdConstraint, EmbedIdList extends ODEmbedManagerIdConstraint = ODEmbedManagerIdConstraint, MessageIdList extends ODMessageManagerIdConstraint = ODMessageManagerIdConstraint, ModalIdList extends ODModalManagerIdConstraint = ODModalManagerIdConstraint> {
|
|
@@ -70,7 +70,7 @@ export interface ODComponentBuildResult {
|
|
|
70
70
|
* The constraint/layout for id mappings/interfaces of the `ODButtonManager` class.
|
|
71
71
|
*/
|
|
72
72
|
export type ODButtonManagerIdConstraint = Record<string, {
|
|
73
|
-
|
|
73
|
+
origin: string;
|
|
74
74
|
params: object;
|
|
75
75
|
workers: string;
|
|
76
76
|
}>;
|
|
@@ -85,13 +85,13 @@ export declare class ODButtonManager<IdList extends ODButtonManagerIdConstraint
|
|
|
85
85
|
constructor(debug: ODDebugger);
|
|
86
86
|
/**Get a newline component for buttons & dropdowns! */
|
|
87
87
|
getNewLine(id: ODValidId): ODComponentBuildResult;
|
|
88
|
-
get<ButtonId extends keyof ODNoGeneric<IdList>>(id: ButtonId): ODButton<IdList[ButtonId]["
|
|
88
|
+
get<ButtonId extends keyof ODNoGeneric<IdList>>(id: ButtonId): ODButton<IdList[ButtonId]["origin"], IdList[ButtonId]["params"], IdList[ButtonId]["workers"]>;
|
|
89
89
|
get(id: ODValidId): ODButton<string, {}, string> | null;
|
|
90
|
-
remove<ButtonId extends keyof ODNoGeneric<IdList>>(id: ButtonId): ODButton<IdList[ButtonId]["
|
|
90
|
+
remove<ButtonId extends keyof ODNoGeneric<IdList>>(id: ButtonId): ODButton<IdList[ButtonId]["origin"], IdList[ButtonId]["params"], IdList[ButtonId]["workers"]>;
|
|
91
91
|
remove(id: ODValidId): ODButton<string, {}, string> | null;
|
|
92
92
|
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
93
93
|
exists(id: ODValidId): boolean;
|
|
94
|
-
getSafe<ButtonId extends keyof ODNoGeneric<IdList>>(id: ButtonId): ODButton<IdList[ButtonId]["
|
|
94
|
+
getSafe<ButtonId extends keyof ODNoGeneric<IdList>>(id: ButtonId): ODButton<IdList[ButtonId]["origin"], IdList[ButtonId]["params"], IdList[ButtonId]["workers"]>;
|
|
95
95
|
getSafe(id: ODValidId): ODButton<string, {}, string>;
|
|
96
96
|
}
|
|
97
97
|
/**## ODButtonData `interface`
|
|
@@ -144,9 +144,9 @@ export declare class ODButtonInstance {
|
|
|
144
144
|
*
|
|
145
145
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
146
146
|
*/
|
|
147
|
-
export declare class ODButton<
|
|
147
|
+
export declare class ODButton<Origin extends string, Params, WorkerIds extends string = string> extends ODBuilderImplementation<ODButtonInstance, Origin, Params, ODComponentBuildResult, WorkerIds> {
|
|
148
148
|
/**Build this button & compile it for discord.js */
|
|
149
|
-
build(
|
|
149
|
+
build(origin: Origin, params: Params): Promise<ODComponentBuildResult>;
|
|
150
150
|
}
|
|
151
151
|
/**## ODQuickButton `class`
|
|
152
152
|
* This is an Open Discord quick button builder.
|
|
@@ -169,7 +169,7 @@ export declare class ODQuickButton {
|
|
|
169
169
|
* The constraint/layout for id mappings/interfaces of the `ODDropdownManager` class.
|
|
170
170
|
*/
|
|
171
171
|
export type ODDropdownManagerIdConstraint = Record<string, {
|
|
172
|
-
|
|
172
|
+
origin: string;
|
|
173
173
|
params: object;
|
|
174
174
|
workers: string;
|
|
175
175
|
}>;
|
|
@@ -184,13 +184,13 @@ export declare class ODDropdownManager<IdList extends ODDropdownManagerIdConstra
|
|
|
184
184
|
constructor(debug: ODDebugger);
|
|
185
185
|
/**Get a newline component for buttons & dropdowns! */
|
|
186
186
|
getNewLine(id: ODValidId): ODComponentBuildResult;
|
|
187
|
-
get<DropdownId extends keyof ODNoGeneric<IdList>>(id: DropdownId): ODDropdown<IdList[DropdownId]["
|
|
187
|
+
get<DropdownId extends keyof ODNoGeneric<IdList>>(id: DropdownId): ODDropdown<IdList[DropdownId]["origin"], IdList[DropdownId]["params"], IdList[DropdownId]["workers"]>;
|
|
188
188
|
get(id: ODValidId): ODDropdown<string, {}, string> | null;
|
|
189
|
-
remove<DropdownId extends keyof ODNoGeneric<IdList>>(id: DropdownId): ODDropdown<IdList[DropdownId]["
|
|
189
|
+
remove<DropdownId extends keyof ODNoGeneric<IdList>>(id: DropdownId): ODDropdown<IdList[DropdownId]["origin"], IdList[DropdownId]["params"], IdList[DropdownId]["workers"]>;
|
|
190
190
|
remove(id: ODValidId): ODDropdown<string, {}, string> | null;
|
|
191
191
|
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
192
192
|
exists(id: ODValidId): boolean;
|
|
193
|
-
getSafe<DropdownId extends keyof ODNoGeneric<IdList>>(id: DropdownId): ODDropdown<IdList[DropdownId]["
|
|
193
|
+
getSafe<DropdownId extends keyof ODNoGeneric<IdList>>(id: DropdownId): ODDropdown<IdList[DropdownId]["origin"], IdList[DropdownId]["params"], IdList[DropdownId]["workers"]>;
|
|
194
194
|
getSafe(id: ODValidId): ODDropdown<string, {}, string>;
|
|
195
195
|
}
|
|
196
196
|
/**## ODDropdownData `interface`
|
|
@@ -263,9 +263,9 @@ export declare class ODDropdownInstance {
|
|
|
263
263
|
*
|
|
264
264
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
265
265
|
*/
|
|
266
|
-
export declare class ODDropdown<
|
|
266
|
+
export declare class ODDropdown<Origin extends string, Params, WorkerIds extends string = string> extends ODBuilderImplementation<ODDropdownInstance, Origin, Params, ODComponentBuildResult, WorkerIds> {
|
|
267
267
|
/**Build this dropdown & compile it for discord.js */
|
|
268
|
-
build(
|
|
268
|
+
build(origin: Origin, params: Params): Promise<ODComponentBuildResult>;
|
|
269
269
|
}
|
|
270
270
|
/**## ODQuickDropdown `class`
|
|
271
271
|
* This is an Open Discord quick dropdown builder.
|
|
@@ -288,7 +288,7 @@ export declare class ODQuickDropdown {
|
|
|
288
288
|
* The constraint/layout for id mappings/interfaces of the `ODFileManager` class.
|
|
289
289
|
*/
|
|
290
290
|
export type ODFileManagerIdConstraint = Record<string, {
|
|
291
|
-
|
|
291
|
+
origin: string;
|
|
292
292
|
params: object;
|
|
293
293
|
workers: string;
|
|
294
294
|
}>;
|
|
@@ -301,13 +301,13 @@ export type ODFileManagerIdConstraint = Record<string, {
|
|
|
301
301
|
*/
|
|
302
302
|
export declare class ODFileManager<IdList extends ODFileManagerIdConstraint = ODFileManagerIdConstraint> extends ODManagerWithSafety<ODFile<string, {}, string>> {
|
|
303
303
|
constructor(debug: ODDebugger);
|
|
304
|
-
get<FileId extends keyof ODNoGeneric<IdList>>(id: FileId): ODFile<IdList[FileId]["
|
|
304
|
+
get<FileId extends keyof ODNoGeneric<IdList>>(id: FileId): ODFile<IdList[FileId]["origin"], IdList[FileId]["params"], IdList[FileId]["workers"]>;
|
|
305
305
|
get(id: ODValidId): ODFile<string, {}, string> | null;
|
|
306
|
-
remove<FileId extends keyof ODNoGeneric<IdList>>(id: FileId): ODFile<IdList[FileId]["
|
|
306
|
+
remove<FileId extends keyof ODNoGeneric<IdList>>(id: FileId): ODFile<IdList[FileId]["origin"], IdList[FileId]["params"], IdList[FileId]["workers"]>;
|
|
307
307
|
remove(id: ODValidId): ODFile<string, {}, string> | null;
|
|
308
308
|
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
309
309
|
exists(id: ODValidId): boolean;
|
|
310
|
-
getSafe<FileId extends keyof ODNoGeneric<IdList>>(id: FileId): ODFile<IdList[FileId]["
|
|
310
|
+
getSafe<FileId extends keyof ODNoGeneric<IdList>>(id: FileId): ODFile<IdList[FileId]["origin"], IdList[FileId]["params"], IdList[FileId]["workers"]>;
|
|
311
311
|
getSafe(id: ODValidId): ODFile<string, {}, string>;
|
|
312
312
|
}
|
|
313
313
|
/**## ODFileData `interface`
|
|
@@ -359,9 +359,9 @@ export declare class ODFileInstance {
|
|
|
359
359
|
*
|
|
360
360
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
361
361
|
*/
|
|
362
|
-
export declare class ODFile<
|
|
362
|
+
export declare class ODFile<Origin extends string, Params, WorkerIds extends string = string> extends ODBuilderImplementation<ODFileInstance, Origin, Params, ODFileBuildResult, WorkerIds> {
|
|
363
363
|
/**Build this attachment & compile it for discord.js */
|
|
364
|
-
build(
|
|
364
|
+
build(origin: Origin, params: Params): Promise<ODFileBuildResult>;
|
|
365
365
|
}
|
|
366
366
|
/**## ODQuickFile `class`
|
|
367
367
|
* This is an Open Discord quick file builder.
|
|
@@ -384,7 +384,7 @@ export declare class ODQuickFile {
|
|
|
384
384
|
* The constraint/layout for id mappings/interfaces of the `ODEmbedManager` class.
|
|
385
385
|
*/
|
|
386
386
|
export type ODEmbedManagerIdConstraint = Record<string, {
|
|
387
|
-
|
|
387
|
+
origin: string;
|
|
388
388
|
params: object;
|
|
389
389
|
workers: string;
|
|
390
390
|
}>;
|
|
@@ -397,13 +397,13 @@ export type ODEmbedManagerIdConstraint = Record<string, {
|
|
|
397
397
|
*/
|
|
398
398
|
export declare class ODEmbedManager<IdList extends ODEmbedManagerIdConstraint = ODEmbedManagerIdConstraint> extends ODManagerWithSafety<ODEmbed<string, {}, string>> {
|
|
399
399
|
constructor(debug: ODDebugger);
|
|
400
|
-
get<EmbedId extends keyof ODNoGeneric<IdList>>(id: EmbedId): ODEmbed<IdList[EmbedId]["
|
|
400
|
+
get<EmbedId extends keyof ODNoGeneric<IdList>>(id: EmbedId): ODEmbed<IdList[EmbedId]["origin"], IdList[EmbedId]["params"], IdList[EmbedId]["workers"]>;
|
|
401
401
|
get(id: ODValidId): ODEmbed<string, {}, string> | null;
|
|
402
|
-
remove<EmbedId extends keyof ODNoGeneric<IdList>>(id: EmbedId): ODEmbed<IdList[EmbedId]["
|
|
402
|
+
remove<EmbedId extends keyof ODNoGeneric<IdList>>(id: EmbedId): ODEmbed<IdList[EmbedId]["origin"], IdList[EmbedId]["params"], IdList[EmbedId]["workers"]>;
|
|
403
403
|
remove(id: ODValidId): ODEmbed<string, {}, string> | null;
|
|
404
404
|
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
405
405
|
exists(id: ODValidId): boolean;
|
|
406
|
-
getSafe<EmbedId extends keyof ODNoGeneric<IdList>>(id: EmbedId): ODEmbed<IdList[EmbedId]["
|
|
406
|
+
getSafe<EmbedId extends keyof ODNoGeneric<IdList>>(id: EmbedId): ODEmbed<IdList[EmbedId]["origin"], IdList[EmbedId]["params"], IdList[EmbedId]["workers"]>;
|
|
407
407
|
getSafe(id: ODValidId): ODEmbed<string, {}, string>;
|
|
408
408
|
}
|
|
409
409
|
/**## ODEmbedData `interface`
|
|
@@ -487,9 +487,9 @@ export declare class ODEmbedInstance {
|
|
|
487
487
|
*
|
|
488
488
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
489
489
|
*/
|
|
490
|
-
export declare class ODEmbed<
|
|
490
|
+
export declare class ODEmbed<Origin extends string, Params, WorkerIds extends string = string> extends ODBuilderImplementation<ODEmbedInstance, Origin, Params, ODEmbedBuildResult, WorkerIds> {
|
|
491
491
|
/**Build this embed & compile it for discord.js */
|
|
492
|
-
build(
|
|
492
|
+
build(origin: Origin, params: Params): Promise<ODEmbedBuildResult>;
|
|
493
493
|
}
|
|
494
494
|
/**## ODQuickEmbed `class`
|
|
495
495
|
* This is an Open Discord quick embed builder.
|
|
@@ -512,7 +512,7 @@ export declare class ODQuickEmbed {
|
|
|
512
512
|
* The constraint/layout for id mappings/interfaces of the `ODMessageManager` class.
|
|
513
513
|
*/
|
|
514
514
|
export type ODMessageManagerIdConstraint = Record<string, {
|
|
515
|
-
|
|
515
|
+
origin: string;
|
|
516
516
|
params: object;
|
|
517
517
|
workers: string;
|
|
518
518
|
}>;
|
|
@@ -525,13 +525,13 @@ export type ODMessageManagerIdConstraint = Record<string, {
|
|
|
525
525
|
*/
|
|
526
526
|
export declare class ODMessageManager<IdList extends ODMessageManagerIdConstraint = ODMessageManagerIdConstraint> extends ODManagerWithSafety<ODMessage<string, {}, string>> {
|
|
527
527
|
constructor(debug: ODDebugger);
|
|
528
|
-
get<MessageId extends keyof ODNoGeneric<IdList>>(id: MessageId): ODMessage<IdList[MessageId]["
|
|
528
|
+
get<MessageId extends keyof ODNoGeneric<IdList>>(id: MessageId): ODMessage<IdList[MessageId]["origin"], IdList[MessageId]["params"], IdList[MessageId]["workers"]>;
|
|
529
529
|
get(id: ODValidId): ODMessage<string, {}, string> | null;
|
|
530
|
-
remove<MessageId extends keyof ODNoGeneric<IdList>>(id: MessageId): ODMessage<IdList[MessageId]["
|
|
530
|
+
remove<MessageId extends keyof ODNoGeneric<IdList>>(id: MessageId): ODMessage<IdList[MessageId]["origin"], IdList[MessageId]["params"], IdList[MessageId]["workers"]>;
|
|
531
531
|
remove(id: ODValidId): ODMessage<string, {}, string> | null;
|
|
532
532
|
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
533
533
|
exists(id: ODValidId): boolean;
|
|
534
|
-
getSafe<MessageId extends keyof ODNoGeneric<IdList>>(id: MessageId): ODMessage<IdList[MessageId]["
|
|
534
|
+
getSafe<MessageId extends keyof ODNoGeneric<IdList>>(id: MessageId): ODMessage<IdList[MessageId]["origin"], IdList[MessageId]["params"], IdList[MessageId]["workers"]>;
|
|
535
535
|
getSafe(id: ODValidId): ODMessage<string, {}, string>;
|
|
536
536
|
}
|
|
537
537
|
/**## ODMessageData `interface`
|
|
@@ -620,9 +620,9 @@ export declare class ODMessageInstance {
|
|
|
620
620
|
*
|
|
621
621
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
622
622
|
*/
|
|
623
|
-
export declare class ODMessage<
|
|
623
|
+
export declare class ODMessage<Origin extends string, Params, WorkerIds extends string = string> extends ODBuilderImplementation<ODMessageInstance, Origin, Params, ODMessageBuildResult, WorkerIds> {
|
|
624
624
|
/**Build this message & compile it for discord.js */
|
|
625
|
-
build(
|
|
625
|
+
build(origin: Origin, params: Params): Promise<ODMessageBuildResult>;
|
|
626
626
|
}
|
|
627
627
|
/**## ODQuickMessage `class`
|
|
628
628
|
* This is an Open Discord quick message builder.
|
|
@@ -645,7 +645,7 @@ export declare class ODQuickMessage {
|
|
|
645
645
|
* The constraint/layout for id mappings/interfaces of the `ODModalManager` class.
|
|
646
646
|
*/
|
|
647
647
|
export type ODModalManagerIdConstraint = Record<string, {
|
|
648
|
-
|
|
648
|
+
origin: string;
|
|
649
649
|
params: object;
|
|
650
650
|
workers: string;
|
|
651
651
|
}>;
|
|
@@ -658,13 +658,13 @@ export type ODModalManagerIdConstraint = Record<string, {
|
|
|
658
658
|
*/
|
|
659
659
|
export declare class ODModalManager<IdList extends ODModalManagerIdConstraint = ODModalManagerIdConstraint> extends ODManagerWithSafety<ODModal<string, {}, string>> {
|
|
660
660
|
constructor(debug: ODDebugger);
|
|
661
|
-
get<ModalId extends keyof ODNoGeneric<IdList>>(id: ModalId): ODModal<IdList[ModalId]["
|
|
661
|
+
get<ModalId extends keyof ODNoGeneric<IdList>>(id: ModalId): ODModal<IdList[ModalId]["origin"], IdList[ModalId]["params"], IdList[ModalId]["workers"]>;
|
|
662
662
|
get(id: ODValidId): ODModal<string, {}, string> | null;
|
|
663
|
-
remove<ModalId extends keyof ODNoGeneric<IdList>>(id: ModalId): ODModal<IdList[ModalId]["
|
|
663
|
+
remove<ModalId extends keyof ODNoGeneric<IdList>>(id: ModalId): ODModal<IdList[ModalId]["origin"], IdList[ModalId]["params"], IdList[ModalId]["workers"]>;
|
|
664
664
|
remove(id: ODValidId): ODModal<string, {}, string> | null;
|
|
665
665
|
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
666
666
|
exists(id: ODValidId): boolean;
|
|
667
|
-
getSafe<ModalId extends keyof ODNoGeneric<IdList>>(id: ModalId): ODModal<IdList[ModalId]["
|
|
667
|
+
getSafe<ModalId extends keyof ODNoGeneric<IdList>>(id: ModalId): ODModal<IdList[ModalId]["origin"], IdList[ModalId]["params"], IdList[ModalId]["workers"]>;
|
|
668
668
|
getSafe(id: ODValidId): ODModal<string, {}, string>;
|
|
669
669
|
}
|
|
670
670
|
/**## ODModalDataQuestion `interface`
|
|
@@ -737,7 +737,7 @@ export declare class ODModalInstance {
|
|
|
737
737
|
*
|
|
738
738
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
739
739
|
*/
|
|
740
|
-
export declare class ODModal<
|
|
740
|
+
export declare class ODModal<Origin extends string, Params, WorkerIds extends string = string> extends ODBuilderImplementation<ODModalInstance, Origin, Params, ODModalBuildResult, WorkerIds> {
|
|
741
741
|
/**Build this modal & compile it for discord.js */
|
|
742
|
-
build(
|
|
742
|
+
build(origin: Origin, params: Params): Promise<ODModalBuildResult>;
|
|
743
743
|
}
|
|
@@ -75,7 +75,7 @@ class ODBuilderImplementation extends base_1.ODManagerData {
|
|
|
75
75
|
return this;
|
|
76
76
|
}
|
|
77
77
|
/**Execute all workers & return the result. */
|
|
78
|
-
async build(
|
|
78
|
+
async build(origin, params) {
|
|
79
79
|
throw new base_1.ODSystemError("Tried to build an unimplemented ODBuilderImplementation");
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -91,7 +91,7 @@ exports.ODBuilderImplementation = ODBuilderImplementation;
|
|
|
91
91
|
* - independent workers (with priority)
|
|
92
92
|
* - fail-safe design using try-catch
|
|
93
93
|
* - cache frequently used objects
|
|
94
|
-
* - get to know the
|
|
94
|
+
* - get to know the origin of the build request for a specific message, button, etc
|
|
95
95
|
* - And so much more!
|
|
96
96
|
*/
|
|
97
97
|
class ODBuilderManager {
|
|
@@ -127,7 +127,7 @@ exports.ODBuilderManager = ODBuilderManager;
|
|
|
127
127
|
class ODButtonManager extends base_1.ODManagerWithSafety {
|
|
128
128
|
constructor(debug) {
|
|
129
129
|
super(() => {
|
|
130
|
-
return new ODButton("opendiscord:unknown-button", (instance, params,
|
|
130
|
+
return new ODButton("opendiscord:unknown-button", (instance, params, origin, cancel) => {
|
|
131
131
|
instance.setCustomId("od:unknown-button");
|
|
132
132
|
instance.setMode("button");
|
|
133
133
|
instance.setColor("red");
|
|
@@ -222,14 +222,14 @@ exports.ODButtonInstance = ODButtonInstance;
|
|
|
222
222
|
*/
|
|
223
223
|
class ODButton extends ODBuilderImplementation {
|
|
224
224
|
/**Build this button & compile it for discord.js */
|
|
225
|
-
async build(
|
|
225
|
+
async build(origin, params) {
|
|
226
226
|
if (this.didCache && this.cache && this.allowCache)
|
|
227
227
|
return this.cache;
|
|
228
228
|
try {
|
|
229
229
|
//create instance
|
|
230
230
|
const instance = new ODButtonInstance();
|
|
231
231
|
//wait for workers to finish
|
|
232
|
-
await this.workers.executeWorkers(instance,
|
|
232
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
233
233
|
//create the discord.js button
|
|
234
234
|
const button = new discord.ButtonBuilder();
|
|
235
235
|
if (instance.data.mode == "button")
|
|
@@ -332,7 +332,7 @@ exports.ODQuickButton = ODQuickButton;
|
|
|
332
332
|
class ODDropdownManager extends base_1.ODManagerWithSafety {
|
|
333
333
|
constructor(debug) {
|
|
334
334
|
super(() => {
|
|
335
|
-
return new ODDropdown("opendiscord:unknown-dropdown", (instance, params,
|
|
335
|
+
return new ODDropdown("opendiscord:unknown-dropdown", (instance, params, origin, cancel) => {
|
|
336
336
|
instance.setCustomId("od:unknown-dropdown");
|
|
337
337
|
instance.setType("string");
|
|
338
338
|
instance.setPlaceholder("❌ <ODError:Unknown Dropdown>");
|
|
@@ -458,14 +458,14 @@ exports.ODDropdownInstance = ODDropdownInstance;
|
|
|
458
458
|
*/
|
|
459
459
|
class ODDropdown extends ODBuilderImplementation {
|
|
460
460
|
/**Build this dropdown & compile it for discord.js */
|
|
461
|
-
async build(
|
|
461
|
+
async build(origin, params) {
|
|
462
462
|
if (this.didCache && this.cache && this.allowCache)
|
|
463
463
|
return this.cache;
|
|
464
464
|
try {
|
|
465
465
|
//create instance
|
|
466
466
|
const instance = new ODDropdownInstance();
|
|
467
467
|
//wait for workers to finish
|
|
468
|
-
await this.workers.executeWorkers(instance,
|
|
468
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
469
469
|
//create the discord.js dropdown
|
|
470
470
|
if (instance.data.type == "string") {
|
|
471
471
|
const dropdown = new discord.StringSelectMenuBuilder();
|
|
@@ -708,7 +708,7 @@ exports.ODQuickDropdown = ODQuickDropdown;
|
|
|
708
708
|
class ODFileManager extends base_1.ODManagerWithSafety {
|
|
709
709
|
constructor(debug) {
|
|
710
710
|
super(() => {
|
|
711
|
-
return new ODFile("opendiscord:unknown-file", (instance, params,
|
|
711
|
+
return new ODFile("opendiscord:unknown-file", (instance, params, origin, cancel) => {
|
|
712
712
|
instance.setName("opendiscord_unknown-file.txt");
|
|
713
713
|
instance.setDescription("❌ <ODError:Unknown File>");
|
|
714
714
|
instance.setContents("Couldn't find file in registery `opendiscord.builders.files`");
|
|
@@ -780,14 +780,14 @@ exports.ODFileInstance = ODFileInstance;
|
|
|
780
780
|
*/
|
|
781
781
|
class ODFile extends ODBuilderImplementation {
|
|
782
782
|
/**Build this attachment & compile it for discord.js */
|
|
783
|
-
async build(
|
|
783
|
+
async build(origin, params) {
|
|
784
784
|
if (this.didCache && this.cache && this.allowCache)
|
|
785
785
|
return this.cache;
|
|
786
786
|
try {
|
|
787
787
|
//create instance
|
|
788
788
|
const instance = new ODFileInstance();
|
|
789
789
|
//wait for workers to finish
|
|
790
|
-
await this.workers.executeWorkers(instance,
|
|
790
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
791
791
|
//create the discord.js attachment
|
|
792
792
|
const file = new discord.AttachmentBuilder(instance.data.file);
|
|
793
793
|
file.setName(instance.data.name ? instance.data.name : "file.txt");
|
|
@@ -854,7 +854,7 @@ exports.ODQuickFile = ODQuickFile;
|
|
|
854
854
|
class ODEmbedManager extends base_1.ODManagerWithSafety {
|
|
855
855
|
constructor(debug) {
|
|
856
856
|
super(() => {
|
|
857
|
-
return new ODEmbed("opendiscord:unknown-embed", (instance, params,
|
|
857
|
+
return new ODEmbed("opendiscord:unknown-embed", (instance, params, origin, cancel) => {
|
|
858
858
|
instance.setFooter("opendiscord:unknown-embed");
|
|
859
859
|
instance.setColor("#ff0000");
|
|
860
860
|
instance.setTitle("❌ <ODError:Unknown Embed>");
|
|
@@ -988,14 +988,14 @@ exports.ODEmbedInstance = ODEmbedInstance;
|
|
|
988
988
|
*/
|
|
989
989
|
class ODEmbed extends ODBuilderImplementation {
|
|
990
990
|
/**Build this embed & compile it for discord.js */
|
|
991
|
-
async build(
|
|
991
|
+
async build(origin, params) {
|
|
992
992
|
if (this.didCache && this.cache && this.allowCache)
|
|
993
993
|
return this.cache;
|
|
994
994
|
try {
|
|
995
995
|
//create instance
|
|
996
996
|
const instance = new ODEmbedInstance();
|
|
997
997
|
//wait for workers to finish
|
|
998
|
-
await this.workers.executeWorkers(instance,
|
|
998
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
999
999
|
//create the discord.js embed
|
|
1000
1000
|
const embed = new discord.EmbedBuilder();
|
|
1001
1001
|
if (instance.data.title)
|
|
@@ -1106,7 +1106,7 @@ exports.ODQuickEmbed = ODQuickEmbed;
|
|
|
1106
1106
|
class ODMessageManager extends base_1.ODManagerWithSafety {
|
|
1107
1107
|
constructor(debug) {
|
|
1108
1108
|
super(() => {
|
|
1109
|
-
return new ODMessage("opendiscord:unknown-message", (instance, params,
|
|
1109
|
+
return new ODMessage("opendiscord:unknown-message", (instance, params, origin, cancel) => {
|
|
1110
1110
|
instance.setContent("**❌ <ODError:Unknown Message>**\nCouldn't find message in registery `opendiscord.builders.messages`");
|
|
1111
1111
|
cancel();
|
|
1112
1112
|
});
|
|
@@ -1244,13 +1244,13 @@ exports.ODMessageInstance = ODMessageInstance;
|
|
|
1244
1244
|
*/
|
|
1245
1245
|
class ODMessage extends ODBuilderImplementation {
|
|
1246
1246
|
/**Build this message & compile it for discord.js */
|
|
1247
|
-
async build(
|
|
1247
|
+
async build(origin, params) {
|
|
1248
1248
|
if (this.didCache && this.cache && this.allowCache)
|
|
1249
1249
|
return this.cache;
|
|
1250
1250
|
//create instance
|
|
1251
1251
|
const instance = new ODMessageInstance();
|
|
1252
1252
|
//wait for workers to finish
|
|
1253
|
-
await this.workers.executeWorkers(instance,
|
|
1253
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
1254
1254
|
//create the discord.js message
|
|
1255
1255
|
const componentArray = [];
|
|
1256
1256
|
let currentRow = new discord.ActionRowBuilder();
|
|
@@ -1388,7 +1388,7 @@ exports.ODQuickMessage = ODQuickMessage;
|
|
|
1388
1388
|
class ODModalManager extends base_1.ODManagerWithSafety {
|
|
1389
1389
|
constructor(debug) {
|
|
1390
1390
|
super(() => {
|
|
1391
|
-
return new ODModal("opendiscord:unknown-modal", (instance, params,
|
|
1391
|
+
return new ODModal("opendiscord:unknown-modal", (instance, params, origin, cancel) => {
|
|
1392
1392
|
instance.setCustomId("od:unknown-modal");
|
|
1393
1393
|
instance.setTitle("❌ <ODError:Unknown Modal>");
|
|
1394
1394
|
instance.setQuestions({
|
|
@@ -1474,13 +1474,13 @@ exports.ODModalInstance = ODModalInstance;
|
|
|
1474
1474
|
*/
|
|
1475
1475
|
class ODModal extends ODBuilderImplementation {
|
|
1476
1476
|
/**Build this modal & compile it for discord.js */
|
|
1477
|
-
async build(
|
|
1477
|
+
async build(origin, params) {
|
|
1478
1478
|
if (this.didCache && this.cache && this.allowCache)
|
|
1479
1479
|
return this.cache;
|
|
1480
1480
|
//create instance
|
|
1481
1481
|
const instance = new ODModalInstance();
|
|
1482
1482
|
//wait for workers to finish
|
|
1483
|
-
await this.workers.executeWorkers(instance,
|
|
1483
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
1484
1484
|
//create the discord.js modal
|
|
1485
1485
|
const modal = new discord.ModalBuilder();
|
|
1486
1486
|
modal.setCustomId(instance.data.customId);
|
|
@@ -349,7 +349,7 @@ export interface ODCheckerObjectStructureOptions extends ODCheckerStructureOptio
|
|
|
349
349
|
export declare class ODCheckerObjectStructure extends ODCheckerStructure {
|
|
350
350
|
options: ODCheckerObjectStructureOptions;
|
|
351
351
|
constructor(id: ODValidId, options: ODCheckerObjectStructureOptions);
|
|
352
|
-
check(checker: ODChecker, value:
|
|
352
|
+
check(checker: ODChecker, value: Record<string, any>, locationTrace: ODCheckerLocationTrace): boolean;
|
|
353
353
|
}
|
|
354
354
|
/**## ODCheckerStringStructureOptions `interface`
|
|
355
355
|
* This interface has the options for `ODCheckerStringStructure`!
|
|
@@ -581,7 +581,7 @@ export interface ODCheckerObjectSwitchStructureOptions extends ODCheckerStructur
|
|
|
581
581
|
export declare class ODCheckerObjectSwitchStructure extends ODCheckerStructure {
|
|
582
582
|
options: ODCheckerObjectSwitchStructureOptions;
|
|
583
583
|
constructor(id: ODValidId, options: ODCheckerObjectSwitchStructureOptions);
|
|
584
|
-
check(checker: ODChecker, value:
|
|
584
|
+
check(checker: ODChecker, value: Record<string, any>, locationTrace: ODCheckerLocationTrace): boolean;
|
|
585
585
|
}
|
|
586
586
|
/**## ODCheckerEnabledObjectStructureOptions `interface`
|
|
587
587
|
* This interface has the options for `ODCheckerEnabledObjectStructure`!
|
|
@@ -602,7 +602,7 @@ export interface ODCheckerEnabledObjectStructureOptions extends ODCheckerStructu
|
|
|
602
602
|
export declare class ODCheckerEnabledObjectStructure extends ODCheckerStructure {
|
|
603
603
|
options: ODCheckerEnabledObjectStructureOptions;
|
|
604
604
|
constructor(id: ODValidId, options: ODCheckerEnabledObjectStructureOptions);
|
|
605
|
-
check(checker: ODChecker, value:
|
|
605
|
+
check(checker: ODChecker, value: Record<string, any>, locationTrace: ODCheckerLocationTrace): boolean;
|
|
606
606
|
}
|
|
607
607
|
/**## ODCheckerCustomStructure_DiscordId `class`
|
|
608
608
|
* This is an Open Discord custom checker structure.
|
|
@@ -879,7 +879,7 @@ class ODSlashCommandManager extends base_1.ODManager {
|
|
|
879
879
|
callback
|
|
880
880
|
});
|
|
881
881
|
if (this.#interactionListeners.length > this.listenerLimit) {
|
|
882
|
-
this.#debug.console.log(new console_1.
|
|
882
|
+
this.#debug.console.log(new console_1.ODWarningConsoleMessage("Possible slash command interaction memory leak detected!", [
|
|
883
883
|
{ key: "listeners", value: this.#interactionListeners.length.toString() }
|
|
884
884
|
]));
|
|
885
885
|
}
|
|
@@ -1492,7 +1492,7 @@ class ODTextCommandManager extends base_1.ODManager {
|
|
|
1492
1492
|
callback
|
|
1493
1493
|
});
|
|
1494
1494
|
if (this.#interactionListeners.length > this.listenerLimit) {
|
|
1495
|
-
this.#debug.console.log(new console_1.
|
|
1495
|
+
this.#debug.console.log(new console_1.ODWarningConsoleMessage("Possible text command interaction memory leak detected!", [
|
|
1496
1496
|
{ key: "listeners", value: this.#interactionListeners.length.toString() }
|
|
1497
1497
|
]));
|
|
1498
1498
|
}
|