@open-discord-bots/framework 0.1.1 → 0.2.0
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/modules/action.d.ts +26 -4
- package/dist/api/modules/action.js +16 -0
- package/dist/api/modules/base.d.ts +12 -2
- package/dist/api/modules/base.js +11 -1
- package/dist/api/modules/builder.d.ts +117 -21
- package/dist/api/modules/builder.js +72 -0
- package/dist/api/modules/checker.d.ts +111 -15
- package/dist/api/modules/checker.js +201 -9
- package/dist/api/modules/client.d.ts +45 -22
- package/dist/api/modules/client.js +58 -34
- package/dist/api/modules/code.d.ts +11 -1
- package/dist/api/modules/code.js +9 -0
- package/dist/api/modules/config.d.ts +15 -5
- package/dist/api/modules/config.js +9 -0
- package/dist/api/modules/console.d.ts +11 -1
- package/dist/api/modules/console.js +9 -0
- package/dist/api/modules/cooldown.d.ts +11 -1
- package/dist/api/modules/cooldown.js +9 -0
- package/dist/api/modules/database.d.ts +36 -4
- package/dist/api/modules/database.js +9 -17
- package/dist/api/modules/event.d.ts +10 -1
- package/dist/api/modules/event.js +6 -0
- package/dist/api/modules/flag.d.ts +11 -1
- package/dist/api/modules/flag.js +9 -0
- package/dist/api/modules/helpmenu.d.ts +22 -2
- package/dist/api/modules/helpmenu.js +18 -0
- package/dist/api/modules/language.d.ts +15 -1
- package/dist/api/modules/language.js +9 -4
- package/dist/api/modules/permission.d.ts +11 -1
- package/dist/api/modules/permission.js +9 -0
- package/dist/api/modules/plugin.d.ts +23 -3
- package/dist/api/modules/plugin.js +18 -0
- package/dist/api/modules/post.d.ts +11 -1
- package/dist/api/modules/post.js +9 -0
- package/dist/api/modules/progressbar.d.ts +24 -3
- package/dist/api/modules/progressbar.js +19 -0
- package/dist/api/modules/responder.d.ts +105 -21
- package/dist/api/modules/responder.js +54 -0
- package/dist/api/modules/session.d.ts +11 -1
- package/dist/api/modules/session.js +9 -0
- package/dist/api/modules/startscreen.d.ts +17 -7
- package/dist/api/modules/startscreen.js +9 -0
- package/dist/api/modules/stat.d.ts +42 -8
- package/dist/api/modules/stat.js +18 -4
- package/dist/api/modules/verifybar.d.ts +18 -4
- package/dist/api/modules/verifybar.js +9 -0
- package/dist/api/modules/worker.d.ts +7 -1
- package/dist/api/modules/worker.js +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/utilities/index.js +1 -0
- package/package.json +1 -1
- package/src/api/main.ts +10 -10
- package/src/api/modules/action.ts +37 -4
- package/src/api/modules/base.ts +30 -3
- package/src/api/modules/builder.ts +226 -21
- package/src/api/modules/checker.ts +292 -17
- package/src/api/modules/client.ts +129 -43
- package/src/api/modules/code.ts +27 -1
- package/src/api/modules/config.ts +33 -7
- package/src/api/modules/console.ts +27 -1
- package/src/api/modules/cooldown.ts +27 -1
- package/src/api/modules/database.ts +55 -4
- package/src/api/modules/event.ts +24 -1
- package/src/api/modules/flag.ts +27 -1
- package/src/api/modules/helpmenu.ts +55 -2
- package/src/api/modules/language.ts +35 -1
- package/src/api/modules/permission.ts +27 -1
- package/src/api/modules/plugin.ts +55 -3
- package/src/api/modules/post.ts +27 -1
- package/src/api/modules/progressbar.ts +56 -3
- package/src/api/modules/responder.ts +184 -21
- package/src/api/modules/session.ts +27 -1
- package/src/api/modules/startscreen.ts +33 -7
- package/src/api/modules/stat.ts +79 -8
- package/src/api/modules/verifybar.ts +31 -5
- package/src/api/modules/worker.ts +22 -1
- package/src/utilities/index.ts +1 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ODValidId, ODManager, ODManagerData } from "./base";
|
|
2
2
|
import { ODDebugger } from "./console";
|
|
3
|
+
/**## ODCooldownManagerIdConstraint `type`
|
|
4
|
+
* The constraint/layout for id mappings/interfaces of the `ODCooldownManager` class.
|
|
5
|
+
*/
|
|
6
|
+
export type ODCooldownManagerIdConstraint = Record<string, ODCooldown<object>>;
|
|
3
7
|
/**## ODCooldownManager `class`
|
|
4
8
|
* This is an Open Discord cooldown manager.
|
|
5
9
|
*
|
|
@@ -7,10 +11,16 @@ import { ODDebugger } from "./console";
|
|
|
7
11
|
*
|
|
8
12
|
* There are many types of cooldowns available, but you can also create your own!
|
|
9
13
|
*/
|
|
10
|
-
export declare class ODCooldownManager extends ODManager<ODCooldown<object>> {
|
|
14
|
+
export declare class ODCooldownManager<IdList extends ODCooldownManagerIdConstraint = ODCooldownManagerIdConstraint> extends ODManager<ODCooldown<object>> {
|
|
11
15
|
constructor(debug: ODDebugger);
|
|
12
16
|
/**Initiate all cooldowns in this manager. */
|
|
13
17
|
init(): Promise<void>;
|
|
18
|
+
get<CooldownId extends keyof IdList>(id: CooldownId): IdList[CooldownId];
|
|
19
|
+
get(id: ODValidId): ODCooldown<object> | null;
|
|
20
|
+
remove<CooldownId extends keyof IdList>(id: CooldownId): IdList[CooldownId];
|
|
21
|
+
remove(id: ODValidId): ODCooldown<object> | null;
|
|
22
|
+
exists(id: keyof IdList): boolean;
|
|
23
|
+
exists(id: ODValidId): boolean;
|
|
14
24
|
}
|
|
15
25
|
/**## ODCooldownData `class`
|
|
16
26
|
* This is Open Discord cooldown data.
|
|
@@ -22,6 +22,15 @@ class ODCooldownManager extends base_1.ODManager {
|
|
|
22
22
|
await cooldown.init();
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
get(id) {
|
|
26
|
+
return super.get(id);
|
|
27
|
+
}
|
|
28
|
+
remove(id) {
|
|
29
|
+
return super.remove(id);
|
|
30
|
+
}
|
|
31
|
+
exists(id) {
|
|
32
|
+
return super.exists(id);
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
35
|
exports.ODCooldownManager = ODCooldownManager;
|
|
27
36
|
/**## ODCooldownData `class`
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ODManager, ODManagerData, ODOptionalPromise, ODPromiseVoid, ODValidId, ODValidJsonType } from "./base";
|
|
2
2
|
import { ODDebugger } from "./console";
|
|
3
3
|
import * as fjs from "formatted-json-stringify";
|
|
4
|
+
/**## ODDatabaseManagerIdConstraint `type`
|
|
5
|
+
* The constraint/layout for id mappings/interfaces of the `ODDatabaseManager` class.
|
|
6
|
+
*/
|
|
7
|
+
export type ODDatabaseManagerIdConstraint = Record<string, ODDatabase<{}>>;
|
|
4
8
|
/**## ODDatabaseManager `class`
|
|
5
9
|
* This is an Open Discord database manager.
|
|
6
10
|
*
|
|
@@ -8,18 +12,28 @@ import * as fjs from "formatted-json-stringify";
|
|
|
8
12
|
*
|
|
9
13
|
* You can use this class to get/add a database (`ODDatabase`) in your plugin!
|
|
10
14
|
*/
|
|
11
|
-
export declare class ODDatabaseManager extends ODManager<ODDatabase
|
|
15
|
+
export declare class ODDatabaseManager<IdList extends ODDatabaseManagerIdConstraint = ODDatabaseManagerIdConstraint> extends ODManager<ODDatabase<{}>> {
|
|
12
16
|
constructor(debug: ODDebugger);
|
|
13
17
|
/**Init all database files. */
|
|
14
18
|
init(): Promise<void>;
|
|
19
|
+
get<DatabaseId extends keyof IdList>(id: DatabaseId): IdList[DatabaseId];
|
|
20
|
+
get(id: ODValidId): ODDatabase<{}> | null;
|
|
21
|
+
remove<DatabaseId extends keyof IdList>(id: DatabaseId): IdList[DatabaseId];
|
|
22
|
+
remove(id: ODValidId): ODDatabase<{}> | null;
|
|
23
|
+
exists(id: keyof IdList): boolean;
|
|
24
|
+
exists(id: ODValidId): boolean;
|
|
15
25
|
}
|
|
26
|
+
/**## ODDatabaseIdConstraint `type`
|
|
27
|
+
* The constraint/layout for id mappings/interfaces of the `ODDatabase` class.
|
|
28
|
+
*/
|
|
29
|
+
export type ODDatabaseIdConstraint = Record<string, ODValidJsonType>;
|
|
16
30
|
/**## ODDatabase `class`
|
|
17
31
|
* This is an Open Discord database template.
|
|
18
32
|
* This class doesn't do anything at all, it just gives a template & basic methods for a database. Use `ODJsonDatabase` instead!
|
|
19
33
|
*
|
|
20
34
|
* You can use this class if you want to create your own database implementation (e.g. `mongodb`, `mysql`,...)!
|
|
21
35
|
*/
|
|
22
|
-
export declare class ODDatabase extends ODManagerData {
|
|
36
|
+
export declare class ODDatabase<IdList extends ODDatabaseIdConstraint = ODDatabaseIdConstraint> extends ODManagerData {
|
|
23
37
|
/**The name of the file with extension. */
|
|
24
38
|
file: string;
|
|
25
39
|
/**The path to the file relative to the main directory. */
|
|
@@ -27,14 +41,22 @@ export declare class ODDatabase extends ODManagerData {
|
|
|
27
41
|
/**Init the database. */
|
|
28
42
|
init(): ODPromiseVoid;
|
|
29
43
|
/**Add/Overwrite a specific category & key in the database. Returns `true` when overwritten. */
|
|
44
|
+
set<CategoryId extends keyof IdList>(category: CategoryId, key: string, value: IdList[CategoryId]): ODOptionalPromise<boolean>;
|
|
30
45
|
set(category: string, key: string, value: ODValidJsonType): ODOptionalPromise<boolean>;
|
|
31
46
|
/**Get a specific category & key in the database */
|
|
47
|
+
get<CategoryId extends keyof IdList>(category: CategoryId, key: string): ODOptionalPromise<IdList[CategoryId] | undefined>;
|
|
32
48
|
get(category: string, key: string): ODOptionalPromise<ODValidJsonType | undefined>;
|
|
33
49
|
/**Delete a specific category & key in the database */
|
|
50
|
+
delete<CategoryId extends keyof IdList>(category: CategoryId, key: string): ODOptionalPromise<boolean>;
|
|
34
51
|
delete(category: string, key: string): ODOptionalPromise<boolean>;
|
|
35
52
|
/**Check if a specific category & key exists in the database */
|
|
53
|
+
exists(category: keyof IdList, key: string): ODOptionalPromise<boolean>;
|
|
36
54
|
exists(category: string, key: string): ODOptionalPromise<boolean>;
|
|
37
55
|
/**Get a specific category in the database */
|
|
56
|
+
getCategory<CategoryId extends keyof IdList>(category: CategoryId): ODOptionalPromise<{
|
|
57
|
+
key: string;
|
|
58
|
+
value: IdList[CategoryId];
|
|
59
|
+
}[] | undefined>;
|
|
38
60
|
getCategory(category: string): ODOptionalPromise<{
|
|
39
61
|
key: string;
|
|
40
62
|
value: ODValidJsonType;
|
|
@@ -57,7 +79,7 @@ export type ODJsonDatabaseStructure = {
|
|
|
57
79
|
*
|
|
58
80
|
* You can use this class if you want to add your own database or to use an existing one!
|
|
59
81
|
*/
|
|
60
|
-
export declare class ODJsonDatabase extends ODDatabase {
|
|
82
|
+
export declare class ODJsonDatabase<IdList extends ODDatabaseIdConstraint = ODDatabaseIdConstraint> extends ODDatabase<IdList> {
|
|
61
83
|
#private;
|
|
62
84
|
constructor(id: ODValidId, file: string, customPath?: string);
|
|
63
85
|
/**Init the database. */
|
|
@@ -73,6 +95,7 @@ export declare class ODJsonDatabase extends ODDatabase {
|
|
|
73
95
|
* const data = database.getData("category","key") //data will be the value
|
|
74
96
|
* //You need an ODJsonDatabase class named "database" for this example to work!
|
|
75
97
|
*/
|
|
98
|
+
get<CategoryId extends keyof IdList>(category: CategoryId, key: string): ODOptionalPromise<IdList[CategoryId] | undefined>;
|
|
76
99
|
get(category: string, key: string): ODOptionalPromise<ODValidJsonType | undefined>;
|
|
77
100
|
/**Remove the value of `category` & `key`. Returns `undefined` when non-existent!
|
|
78
101
|
* @example
|
|
@@ -83,6 +106,10 @@ export declare class ODJsonDatabase extends ODDatabase {
|
|
|
83
106
|
/**Check if a value of `category` & `key` exists. Returns `false` when non-existent! */
|
|
84
107
|
exists(category: string, key: string): ODOptionalPromise<boolean>;
|
|
85
108
|
/**Get all values in `category`. Returns `undefined` when non-existent! */
|
|
109
|
+
getCategory<CategoryId extends keyof IdList>(category: CategoryId): ODOptionalPromise<{
|
|
110
|
+
key: string;
|
|
111
|
+
value: IdList[CategoryId];
|
|
112
|
+
}[] | undefined>;
|
|
86
113
|
getCategory(category: string): ODOptionalPromise<{
|
|
87
114
|
key: string;
|
|
88
115
|
value: ODValidJsonType;
|
|
@@ -98,7 +125,7 @@ export declare class ODJsonDatabase extends ODDatabase {
|
|
|
98
125
|
* This one is exactly the same as `ODJsonDatabase`, but it has a formatter from the `formatted-json-stringify` package.
|
|
99
126
|
* This can help you organise it a little bit better!
|
|
100
127
|
*/
|
|
101
|
-
export declare class ODFormattedJsonDatabase extends ODDatabase {
|
|
128
|
+
export declare class ODFormattedJsonDatabase<IdList extends ODDatabaseIdConstraint = ODDatabaseIdConstraint> extends ODDatabase<IdList> {
|
|
102
129
|
#private;
|
|
103
130
|
/**The formatter to use on the database array */
|
|
104
131
|
formatter: fjs.ArrayFormatter;
|
|
@@ -116,6 +143,7 @@ export declare class ODFormattedJsonDatabase extends ODDatabase {
|
|
|
116
143
|
* const data = database.getData("category","key") //data will be the value
|
|
117
144
|
* //You need an ODFormattedJsonDatabase class named "database" for this example to work!
|
|
118
145
|
*/
|
|
146
|
+
get<CategoryId extends keyof IdList>(category: CategoryId, key: string): ODOptionalPromise<IdList[CategoryId] | undefined>;
|
|
119
147
|
get(category: string, key: string): ODOptionalPromise<ODValidJsonType | undefined>;
|
|
120
148
|
/**Remove the value of `category` & `key`. Returns `undefined` when non-existent!
|
|
121
149
|
* @example
|
|
@@ -126,6 +154,10 @@ export declare class ODFormattedJsonDatabase extends ODDatabase {
|
|
|
126
154
|
/**Check if a value of `category` & `key` exists. Returns `false` when non-existent! */
|
|
127
155
|
exists(category: string, key: string): ODOptionalPromise<boolean>;
|
|
128
156
|
/**Get all values in `category`. Returns `undefined` when non-existent! */
|
|
157
|
+
getCategory<CategoryId extends keyof IdList>(category: CategoryId): ODOptionalPromise<{
|
|
158
|
+
key: string;
|
|
159
|
+
value: IdList[CategoryId];
|
|
160
|
+
}[] | undefined>;
|
|
129
161
|
getCategory(category: string): ODOptionalPromise<{
|
|
130
162
|
key: string;
|
|
131
163
|
value: ODValidJsonType;
|
|
@@ -32,6 +32,15 @@ class ODDatabaseManager extends base_1.ODManager {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
get(id) {
|
|
36
|
+
return super.get(id);
|
|
37
|
+
}
|
|
38
|
+
remove(id) {
|
|
39
|
+
return super.remove(id);
|
|
40
|
+
}
|
|
41
|
+
exists(id) {
|
|
42
|
+
return super.exists(id);
|
|
43
|
+
}
|
|
35
44
|
}
|
|
36
45
|
exports.ODDatabaseManager = ODDatabaseManager;
|
|
37
46
|
/**## ODDatabase `class`
|
|
@@ -49,23 +58,18 @@ class ODDatabase extends base_1.ODManagerData {
|
|
|
49
58
|
init() {
|
|
50
59
|
//nothing
|
|
51
60
|
}
|
|
52
|
-
/**Add/Overwrite a specific category & key in the database. Returns `true` when overwritten. */
|
|
53
61
|
set(category, key, value) {
|
|
54
62
|
return false;
|
|
55
63
|
}
|
|
56
|
-
/**Get a specific category & key in the database */
|
|
57
64
|
get(category, key) {
|
|
58
65
|
return undefined;
|
|
59
66
|
}
|
|
60
|
-
/**Delete a specific category & key in the database */
|
|
61
67
|
delete(category, key) {
|
|
62
68
|
return false;
|
|
63
69
|
}
|
|
64
|
-
/**Check if a specific category & key exists in the database */
|
|
65
70
|
exists(category, key) {
|
|
66
71
|
return false;
|
|
67
72
|
}
|
|
68
|
-
/**Get a specific category in the database */
|
|
69
73
|
getCategory(category) {
|
|
70
74
|
return undefined;
|
|
71
75
|
}
|
|
@@ -110,11 +114,6 @@ class ODJsonDatabase extends ODDatabase {
|
|
|
110
114
|
this.#system.setData(currentList);
|
|
111
115
|
return currentData ? true : false;
|
|
112
116
|
}
|
|
113
|
-
/**Get the value of `category` & `key`. Returns `undefined` when non-existent!
|
|
114
|
-
* @example
|
|
115
|
-
* const data = database.getData("category","key") //data will be the value
|
|
116
|
-
* //You need an ODJsonDatabase class named "database" for this example to work!
|
|
117
|
-
*/
|
|
118
117
|
get(category, key) {
|
|
119
118
|
const currentList = this.#system.getData();
|
|
120
119
|
const tempresult = currentList.find((d) => (d.category === category) && (d.key === key));
|
|
@@ -139,7 +138,6 @@ class ODJsonDatabase extends ODDatabase {
|
|
|
139
138
|
const tempresult = currentList.find((d) => (d.category === category) && (d.key === key));
|
|
140
139
|
return tempresult ? true : false;
|
|
141
140
|
}
|
|
142
|
-
/**Get all values in `category`. Returns `undefined` when non-existent! */
|
|
143
141
|
getCategory(category) {
|
|
144
142
|
const currentList = this.#system.getData();
|
|
145
143
|
const tempresult = currentList.filter((d) => (d.category === category));
|
|
@@ -212,11 +210,6 @@ class ODFormattedJsonDatabase extends ODDatabase {
|
|
|
212
210
|
this.#system.setData(currentList);
|
|
213
211
|
return currentData ? true : false;
|
|
214
212
|
}
|
|
215
|
-
/**Get the value of `category` & `key`. Returns `undefined` when non-existent!
|
|
216
|
-
* @example
|
|
217
|
-
* const data = database.getData("category","key") //data will be the value
|
|
218
|
-
* //You need an ODFormattedJsonDatabase class named "database" for this example to work!
|
|
219
|
-
*/
|
|
220
213
|
get(category, key) {
|
|
221
214
|
const currentList = this.#system.getData();
|
|
222
215
|
const tempresult = currentList.find((d) => (d.category === category) && (d.key === key));
|
|
@@ -241,7 +234,6 @@ class ODFormattedJsonDatabase extends ODDatabase {
|
|
|
241
234
|
const tempresult = currentList.find((d) => (d.category === category) && (d.key === key));
|
|
242
235
|
return tempresult ? true : false;
|
|
243
236
|
}
|
|
244
|
-
/**Get all values in `category`. Returns `undefined` when non-existent! */
|
|
245
237
|
getCategory(category) {
|
|
246
238
|
const currentList = this.#system.getData();
|
|
247
239
|
const tempresult = currentList.filter((d) => (d.category === category));
|
|
@@ -27,6 +27,10 @@ export declare class ODEvent extends ODManagerData {
|
|
|
27
27
|
/**Emit this event to all listeners. You are required to provide all parameters of the event! */
|
|
28
28
|
emit(params: any[]): Promise<void>;
|
|
29
29
|
}
|
|
30
|
+
/**## ODEventManagerIdConstraint `type`
|
|
31
|
+
* The constraint/layout for id mappings/interfaces of the `ODEventManager` class.
|
|
32
|
+
*/
|
|
33
|
+
export type ODEventManagerIdConstraint = Record<string, ODEvent>;
|
|
30
34
|
/**## ODEventManager `class`
|
|
31
35
|
* This is an Open Discord event manager.
|
|
32
36
|
*
|
|
@@ -35,9 +39,14 @@ export declare class ODEvent extends ODManagerData {
|
|
|
35
39
|
* It's not recommended to create this class yourself. Plugin events should be registered in their `plugin.json` file instead.
|
|
36
40
|
* All events are available in the `opendiscord.events` global!
|
|
37
41
|
*/
|
|
38
|
-
export declare class ODEventManager extends ODManager<ODEvent> {
|
|
42
|
+
export declare class ODEventManager<IdList extends ODEventManagerIdConstraint = ODEventManagerIdConstraint> extends ODManager<ODEvent> {
|
|
39
43
|
#private;
|
|
40
44
|
constructor(debug: ODDebugger);
|
|
41
45
|
add(data: ODEvent, overwrite?: boolean): boolean;
|
|
46
|
+
get<EventId extends keyof IdList>(id: EventId): IdList[EventId];
|
|
47
|
+
get(id: ODValidId): ODEvent | null;
|
|
48
|
+
remove<EventId extends keyof IdList>(id: EventId): IdList[EventId];
|
|
42
49
|
remove(id: ODValidId): ODEvent | null;
|
|
50
|
+
exists(id: keyof IdList): boolean;
|
|
51
|
+
exists(id: ODValidId): boolean;
|
|
43
52
|
}
|
|
@@ -90,11 +90,17 @@ class ODEventManager extends base_1.ODManager {
|
|
|
90
90
|
data.useDebug(this.#debug);
|
|
91
91
|
return super.add(data, overwrite);
|
|
92
92
|
}
|
|
93
|
+
get(id) {
|
|
94
|
+
return super.get(id);
|
|
95
|
+
}
|
|
93
96
|
remove(id) {
|
|
94
97
|
const data = super.remove(id);
|
|
95
98
|
if (data)
|
|
96
99
|
data.useDebug(null);
|
|
97
100
|
return data;
|
|
98
101
|
}
|
|
102
|
+
exists(id) {
|
|
103
|
+
return super.exists(id);
|
|
104
|
+
}
|
|
99
105
|
}
|
|
100
106
|
exports.ODEventManager = ODEventManager;
|
|
@@ -27,14 +27,24 @@ export declare class ODFlag extends ODManagerData {
|
|
|
27
27
|
/**Detect if the process contains the param or aliases & set the value. Use `force` to overwrite a manually set value. */
|
|
28
28
|
detectProcessParams(force?: boolean): void;
|
|
29
29
|
}
|
|
30
|
+
/**## ODFlagManagerIdConstraint `type`
|
|
31
|
+
* The constraint/layout for id mappings/interfaces of the `ODFlagManager` class.
|
|
32
|
+
*/
|
|
33
|
+
export type ODFlagManagerIdConstraint = Record<string, ODFlag>;
|
|
30
34
|
/**## ODFlagManager `class`
|
|
31
35
|
* This is an Open Discord flag manager.
|
|
32
36
|
*
|
|
33
37
|
* This class is responsible for managing & initiating all flags of the bot.
|
|
34
38
|
* It also contains a shortcut for initiating all flags.
|
|
35
39
|
*/
|
|
36
|
-
export declare class ODFlagManager extends ODManager<ODFlag> {
|
|
40
|
+
export declare class ODFlagManager<IdList extends ODFlagManagerIdConstraint = ODFlagManagerIdConstraint> extends ODManager<ODFlag> {
|
|
37
41
|
constructor(debug: ODDebugger);
|
|
38
42
|
/**Set all flags to their `process.argv` value. */
|
|
39
43
|
init(): Promise<void>;
|
|
44
|
+
get<FlagId extends keyof IdList>(id: FlagId): IdList[FlagId];
|
|
45
|
+
get(id: ODValidId): ODFlag | null;
|
|
46
|
+
remove<FlagId extends keyof IdList>(id: FlagId): IdList[FlagId];
|
|
47
|
+
remove(id: ODValidId): ODFlag | null;
|
|
48
|
+
exists(id: keyof IdList): boolean;
|
|
49
|
+
exists(id: ODValidId): boolean;
|
|
40
50
|
}
|
package/dist/api/modules/flag.js
CHANGED
|
@@ -68,5 +68,14 @@ class ODFlagManager extends base_1.ODManager {
|
|
|
68
68
|
flag.detectProcessParams(false);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
+
get(id) {
|
|
72
|
+
return super.get(id);
|
|
73
|
+
}
|
|
74
|
+
remove(id) {
|
|
75
|
+
return super.remove(id);
|
|
76
|
+
}
|
|
77
|
+
exists(id) {
|
|
78
|
+
return super.exists(id);
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
81
|
exports.ODFlagManager = ODFlagManager;
|
|
@@ -59,13 +59,17 @@ export declare class ODHelpMenuCommandComponent extends ODHelpMenuComponent {
|
|
|
59
59
|
#private;
|
|
60
60
|
constructor(id: ODValidId, priority: number, settings: ODHelpMenuCommandComponentSettings);
|
|
61
61
|
}
|
|
62
|
+
/**## ODHelpMenuCategoryIdConstraint `type`
|
|
63
|
+
* The constraint/layout for id mappings/interfaces of the `ODHelpMenuCategory` class.
|
|
64
|
+
*/
|
|
65
|
+
export type ODHelpMenuCategoryIdConstraint = Record<string, ODHelpMenuComponent>;
|
|
62
66
|
/**## ODHelpMenuCategory `class`
|
|
63
67
|
* This is an Open Discord help menu category.
|
|
64
68
|
*
|
|
65
69
|
* Every category in the help menu is an embed field by default.
|
|
66
70
|
* Try to limit the amount of components per category.
|
|
67
71
|
*/
|
|
68
|
-
export declare class ODHelpMenuCategory extends ODManager<ODHelpMenuComponent> {
|
|
72
|
+
export declare class ODHelpMenuCategory<IdList extends ODHelpMenuCategoryIdConstraint = ODHelpMenuCategoryIdConstraint> extends ODManager<ODHelpMenuComponent> {
|
|
69
73
|
/**The id of this category. */
|
|
70
74
|
id: ODId;
|
|
71
75
|
/**The priority of this category. The higher, the earlier it will appear in the menu. */
|
|
@@ -77,6 +81,12 @@ export declare class ODHelpMenuCategory extends ODManager<ODHelpMenuComponent> {
|
|
|
77
81
|
constructor(id: ODValidId, priority: number, name: string, newPage?: boolean);
|
|
78
82
|
/**Render this category and it's components. */
|
|
79
83
|
render(page: number, category: number, mode: "slash" | "text"): Promise<string>;
|
|
84
|
+
get<HelpMenuComponentId extends keyof IdList>(id: HelpMenuComponentId): IdList[HelpMenuComponentId];
|
|
85
|
+
get(id: ODValidId): ODHelpMenuComponent | null;
|
|
86
|
+
remove<HelpMenuComponentId extends keyof IdList>(id: HelpMenuComponentId): IdList[HelpMenuComponentId];
|
|
87
|
+
remove(id: ODValidId): ODHelpMenuComponent | null;
|
|
88
|
+
exists(id: keyof IdList): boolean;
|
|
89
|
+
exists(id: ODValidId): boolean;
|
|
80
90
|
}
|
|
81
91
|
/**## ODHelpMenuRenderResult `type`
|
|
82
92
|
* This is the array returned when the help menu has been rendered successfully.
|
|
@@ -87,6 +97,10 @@ export type ODHelpMenuRenderResult = {
|
|
|
87
97
|
name: string;
|
|
88
98
|
value: string;
|
|
89
99
|
}[][];
|
|
100
|
+
/**## ODHelpMenuManagerIdConstraint `type`
|
|
101
|
+
* The constraint/layout for id mappings/interfaces of the `ODHelpMenuManager` class.
|
|
102
|
+
*/
|
|
103
|
+
export type ODHelpMenuManagerIdConstraint = Record<string, ODHelpMenuCategory>;
|
|
90
104
|
/**## ODHelpMenuManager `class`
|
|
91
105
|
* This is an Open Discord help menu manager.
|
|
92
106
|
*
|
|
@@ -95,7 +109,7 @@ export type ODHelpMenuRenderResult = {
|
|
|
95
109
|
*
|
|
96
110
|
* Fewer Categories == More Clean Menu
|
|
97
111
|
*/
|
|
98
|
-
export declare class ODHelpMenuManager extends ODManager<ODHelpMenuCategory> {
|
|
112
|
+
export declare class ODHelpMenuManager<IdList extends ODHelpMenuManagerIdConstraint = ODHelpMenuManagerIdConstraint> extends ODManager<ODHelpMenuCategory> {
|
|
99
113
|
#private;
|
|
100
114
|
/**The amount of categories per-page. */
|
|
101
115
|
categoriesPerPage: number;
|
|
@@ -103,4 +117,10 @@ export declare class ODHelpMenuManager extends ODManager<ODHelpMenuCategory> {
|
|
|
103
117
|
add(data: ODHelpMenuCategory, overwrite?: boolean): boolean;
|
|
104
118
|
/**Render this entire help menu & return a `ODHelpMenuRenderResult`. */
|
|
105
119
|
render(mode: "slash" | "text"): Promise<ODHelpMenuRenderResult>;
|
|
120
|
+
get<HelpMenuCategoryId extends keyof IdList>(id: HelpMenuCategoryId): IdList[HelpMenuCategoryId];
|
|
121
|
+
get(id: ODValidId): ODHelpMenuCategory | null;
|
|
122
|
+
remove<HelpMenuCategoryId extends keyof IdList>(id: HelpMenuCategoryId): IdList[HelpMenuCategoryId];
|
|
123
|
+
remove(id: ODValidId): ODHelpMenuCategory | null;
|
|
124
|
+
exists(id: keyof IdList): boolean;
|
|
125
|
+
exists(id: ODValidId): boolean;
|
|
106
126
|
}
|
|
@@ -102,6 +102,15 @@ class ODHelpMenuCategory extends base_1.ODManager {
|
|
|
102
102
|
//only return the non-empty components
|
|
103
103
|
return result.filter((component) => component !== "").join("\n\n");
|
|
104
104
|
}
|
|
105
|
+
get(id) {
|
|
106
|
+
return super.get(id);
|
|
107
|
+
}
|
|
108
|
+
remove(id) {
|
|
109
|
+
return super.remove(id);
|
|
110
|
+
}
|
|
111
|
+
exists(id) {
|
|
112
|
+
return super.exists(id);
|
|
113
|
+
}
|
|
105
114
|
}
|
|
106
115
|
exports.ODHelpMenuCategory = ODHelpMenuCategory;
|
|
107
116
|
/**## ODHelpMenuManager `class`
|
|
@@ -163,5 +172,14 @@ class ODHelpMenuManager extends base_1.ODManager {
|
|
|
163
172
|
result.push(currentPage);
|
|
164
173
|
return result;
|
|
165
174
|
}
|
|
175
|
+
get(id) {
|
|
176
|
+
return super.get(id);
|
|
177
|
+
}
|
|
178
|
+
remove(id) {
|
|
179
|
+
return super.remove(id);
|
|
180
|
+
}
|
|
181
|
+
exists(id) {
|
|
182
|
+
return super.exists(id);
|
|
183
|
+
}
|
|
166
184
|
}
|
|
167
185
|
exports.ODHelpMenuManager = ODHelpMenuManager;
|
|
@@ -15,6 +15,10 @@ export interface ODLanguageMetadata {
|
|
|
15
15
|
/**When `true`, the translator made use of some sort of automation while creating the translation. (e.g. ChatGPT, Google Translate, DeepL, ...) */
|
|
16
16
|
automated: boolean;
|
|
17
17
|
}
|
|
18
|
+
/**## ODLanguageManagerIdConstraint `type`
|
|
19
|
+
* The constraint/layout for id mappings/interfaces of the `ODLanguageManager` class.
|
|
20
|
+
*/
|
|
21
|
+
export type ODLanguageManagerIdConstraint = Record<string, ODLanguage>;
|
|
18
22
|
/**## ODLanguageManager `class`
|
|
19
23
|
* This is an Open Discord language manager.
|
|
20
24
|
*
|
|
@@ -23,7 +27,7 @@ export interface ODLanguageMetadata {
|
|
|
23
27
|
*
|
|
24
28
|
* Add new languages using the `ODlanguage` class in your plugin!
|
|
25
29
|
*/
|
|
26
|
-
export declare class ODLanguageManager extends ODManager<ODLanguage> {
|
|
30
|
+
export declare class ODLanguageManager<IdList extends ODLanguageManagerIdConstraint = ODLanguageManagerIdConstraint, TranslationIds extends string = string> extends ODManager<ODLanguage> {
|
|
27
31
|
#private;
|
|
28
32
|
/**The currently selected language. */
|
|
29
33
|
current: ODLanguage | null;
|
|
@@ -31,10 +35,12 @@ export declare class ODLanguageManager extends ODManager<ODLanguage> {
|
|
|
31
35
|
backup: ODLanguage | null;
|
|
32
36
|
constructor(debug: ODDebugger, presets: boolean);
|
|
33
37
|
/**Set the current language by providing the ID of a language which is registered in this manager. */
|
|
38
|
+
setCurrentLanguage(id: keyof IdList): void;
|
|
34
39
|
setCurrentLanguage(id: ODValidId): void;
|
|
35
40
|
/**Get the current language (same as `this.current`) */
|
|
36
41
|
getCurrentLanguage(): ODLanguage | null;
|
|
37
42
|
/**Set the backup language by providing the ID of a language which is registered in this manager. */
|
|
43
|
+
setBackupLanguage(id: keyof IdList): void;
|
|
38
44
|
setBackupLanguage(id: ODValidId): void;
|
|
39
45
|
/**Get the backup language (same as `this.backup`) */
|
|
40
46
|
getBackupLanguage(): ODLanguage | null;
|
|
@@ -43,11 +49,19 @@ export declare class ODLanguageManager extends ODManager<ODLanguage> {
|
|
|
43
49
|
/**Get the ID (string) of the current language. (Not backup language) */
|
|
44
50
|
getCurrentLanguageId(): string;
|
|
45
51
|
/**Get a translation string by JSON location. (e.g. `"checker.system.typeError"`) */
|
|
52
|
+
getTranslation(id: TranslationIds): string;
|
|
46
53
|
getTranslation(id: string): string | null;
|
|
47
54
|
/**Get a backup translation string by JSON location and replace `{0}`,`{1}`,`{2}`,... with the provided parameters. */
|
|
55
|
+
getTranslationWithParams(id: TranslationIds, params: string[]): string;
|
|
48
56
|
getTranslationWithParams(id: string, params: string[]): string | null;
|
|
49
57
|
/**Init all language files. */
|
|
50
58
|
init(): Promise<void>;
|
|
59
|
+
get<LanguageId extends keyof IdList>(id: LanguageId): IdList[LanguageId];
|
|
60
|
+
get(id: ODValidId): ODLanguage | null;
|
|
61
|
+
remove<LanguageId extends keyof IdList>(id: LanguageId): IdList[LanguageId];
|
|
62
|
+
remove(id: ODValidId): ODLanguage | null;
|
|
63
|
+
exists(id: keyof IdList): boolean;
|
|
64
|
+
exists(id: ODValidId): boolean;
|
|
51
65
|
}
|
|
52
66
|
/**## ODLanguage `class`
|
|
53
67
|
* This is an Open Discord language file.
|
|
@@ -33,7 +33,6 @@ class ODLanguageManager extends base_1.ODManager {
|
|
|
33
33
|
this.backup = presets ? new ODLanguage("english", "english.json") : null;
|
|
34
34
|
this.#debug = debug;
|
|
35
35
|
}
|
|
36
|
-
/**Set the current language by providing the ID of a language which is registered in this manager. */
|
|
37
36
|
setCurrentLanguage(id) {
|
|
38
37
|
this.current = this.get(id);
|
|
39
38
|
const languageId = this.current?.id.value ?? "<unknown-id>";
|
|
@@ -47,7 +46,6 @@ class ODLanguageManager extends base_1.ODManager {
|
|
|
47
46
|
getCurrentLanguage() {
|
|
48
47
|
return (this.current) ? this.current : null;
|
|
49
48
|
}
|
|
50
|
-
/**Set the backup language by providing the ID of a language which is registered in this manager. */
|
|
51
49
|
setBackupLanguage(id) {
|
|
52
50
|
this.backup = this.get(id);
|
|
53
51
|
const languageId = this.backup?.id.value ?? "<unknown-id>";
|
|
@@ -71,7 +69,6 @@ class ODLanguageManager extends base_1.ODManager {
|
|
|
71
69
|
getCurrentLanguageId() {
|
|
72
70
|
return (this.current) ? this.current.id.value : "";
|
|
73
71
|
}
|
|
74
|
-
/**Get a translation string by JSON location. (e.g. `"checker.system.typeError"`) */
|
|
75
72
|
getTranslation(id) {
|
|
76
73
|
if (!this.current)
|
|
77
74
|
return this.#getBackupTranslation(id);
|
|
@@ -111,7 +108,6 @@ class ODLanguageManager extends base_1.ODManager {
|
|
|
111
108
|
else
|
|
112
109
|
return null;
|
|
113
110
|
}
|
|
114
|
-
/**Get a backup translation string by JSON location and replace `{0}`,`{1}`,`{2}`,... with the provided parameters. */
|
|
115
111
|
getTranslationWithParams(id, params) {
|
|
116
112
|
let translation = this.getTranslation(id);
|
|
117
113
|
if (!translation)
|
|
@@ -134,6 +130,15 @@ class ODLanguageManager extends base_1.ODManager {
|
|
|
134
130
|
}
|
|
135
131
|
}
|
|
136
132
|
}
|
|
133
|
+
get(id) {
|
|
134
|
+
return super.get(id);
|
|
135
|
+
}
|
|
136
|
+
remove(id) {
|
|
137
|
+
return super.remove(id);
|
|
138
|
+
}
|
|
139
|
+
exists(id) {
|
|
140
|
+
return super.exists(id);
|
|
141
|
+
}
|
|
137
142
|
}
|
|
138
143
|
exports.ODLanguageManager = ODLanguageManager;
|
|
139
144
|
/**## ODLanguage `class`
|
|
@@ -95,6 +95,10 @@ export type ODPermissionCommandResult = {
|
|
|
95
95
|
/**Is the user a server admin or a normal member? This does not decide if the user has permissions or not. */
|
|
96
96
|
isAdmin: boolean;
|
|
97
97
|
};
|
|
98
|
+
/**## ODPermissionManagerIdConstraint `type`
|
|
99
|
+
* The constraint/layout for id mappings/interfaces of the `ODPermissionManager` class.
|
|
100
|
+
*/
|
|
101
|
+
export type ODPermissionManagerIdConstraint = Record<string, ODPermission>;
|
|
98
102
|
/**## ODPermissionManager `class`
|
|
99
103
|
* This is an Open Discord permission manager.
|
|
100
104
|
*
|
|
@@ -103,7 +107,7 @@ export type ODPermissionCommandResult = {
|
|
|
103
107
|
*
|
|
104
108
|
* Add new permissions using the `ODPermission` class in your plugin!
|
|
105
109
|
*/
|
|
106
|
-
export declare class ODPermissionManager extends ODManager<ODPermission> {
|
|
110
|
+
export declare class ODPermissionManager<IdList extends ODPermissionManagerIdConstraint = ODPermissionManagerIdConstraint> extends ODManager<ODPermission> {
|
|
107
111
|
#private;
|
|
108
112
|
/**The result which is returned when no other permissions match. (`member` by default) */
|
|
109
113
|
defaultResult: ODPermissionResult;
|
|
@@ -118,4 +122,10 @@ export declare class ODPermissionManager extends ODManager<ODPermission> {
|
|
|
118
122
|
hasPermissions(minimum: ODPermissionType, data: ODPermissionResult): boolean;
|
|
119
123
|
/**Check the permissions for a certain command of the bot. */
|
|
120
124
|
checkCommandPerms(permissionMode: string, requiredLevel: ODPermissionType, user: discord.User, member?: discord.GuildMember | null, channel?: discord.Channel | null, guild?: discord.Guild | null, settings?: ODPermissionSettings): Promise<ODPermissionCommandResult>;
|
|
125
|
+
get<PermissionId extends keyof IdList>(id: PermissionId): IdList[PermissionId];
|
|
126
|
+
get(id: ODValidId): ODPermission | null;
|
|
127
|
+
remove<PermissionId extends keyof IdList>(id: PermissionId): IdList[PermissionId];
|
|
128
|
+
remove(id: ODValidId): ODPermission | null;
|
|
129
|
+
exists(id: keyof IdList): boolean;
|
|
130
|
+
exists(id: ODValidId): boolean;
|
|
121
131
|
}
|
|
@@ -310,5 +310,14 @@ class ODPermissionManager extends base_1.ODManager {
|
|
|
310
310
|
return { hasPerms: true, isAdmin };
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
+
get(id) {
|
|
314
|
+
return super.get(id);
|
|
315
|
+
}
|
|
316
|
+
remove(id) {
|
|
317
|
+
return super.remove(id);
|
|
318
|
+
}
|
|
319
|
+
exists(id) {
|
|
320
|
+
return super.exists(id);
|
|
321
|
+
}
|
|
313
322
|
}
|
|
314
323
|
exports.ODPermissionManager = ODPermissionManager;
|
|
@@ -9,6 +9,10 @@ export interface ODUnknownCrashedPlugin {
|
|
|
9
9
|
/**The description of the plugin. (when found before crashing) */
|
|
10
10
|
description: string;
|
|
11
11
|
}
|
|
12
|
+
/**## ODPluginManagerIdConstraint `type`
|
|
13
|
+
* The constraint/layout for id mappings/interfaces of the `ODPluginManager` class.
|
|
14
|
+
*/
|
|
15
|
+
export type ODPluginManagerIdConstraint = Record<string, ODPlugin>;
|
|
12
16
|
/**## ODPluginManager `class`
|
|
13
17
|
* This is an Open Discord plugin manager.
|
|
14
18
|
*
|
|
@@ -18,14 +22,20 @@ export interface ODUnknownCrashedPlugin {
|
|
|
18
22
|
*
|
|
19
23
|
* Use `isPluginLoaded()` to check if a plugin has been loaded.
|
|
20
24
|
*/
|
|
21
|
-
export declare class ODPluginManager extends ODManager<ODPlugin> {
|
|
25
|
+
export declare class ODPluginManager<IdList extends ODPluginManagerIdConstraint = ODPluginManagerIdConstraint, PluginClassIdList extends ODPluginClassManagerIdConstraint = ODPluginClassManagerIdConstraint> extends ODManager<ODPlugin> {
|
|
22
26
|
/**A manager for all custom managers registered by plugins. */
|
|
23
|
-
classes: ODPluginClassManager
|
|
27
|
+
classes: ODPluginClassManager<PluginClassIdList>;
|
|
24
28
|
/**A list of basic details from all plugins that crashed while loading the `plugin.json` file. */
|
|
25
29
|
unknownCrashedPlugins: ODUnknownCrashedPlugin[];
|
|
26
30
|
constructor(debug: ODDebugger);
|
|
27
31
|
/**Check if a plugin has been loaded successfully and is available for usage.*/
|
|
28
32
|
isPluginLoaded(id: ODValidId): boolean;
|
|
33
|
+
get<PluginId extends keyof IdList>(id: PluginId): IdList[PluginId];
|
|
34
|
+
get(id: ODValidId): ODPlugin | null;
|
|
35
|
+
remove<PluginId extends keyof IdList>(id: PluginId): IdList[PluginId];
|
|
36
|
+
remove(id: ODValidId): ODPlugin | null;
|
|
37
|
+
exists(id: keyof IdList): boolean;
|
|
38
|
+
exists(id: ODValidId): boolean;
|
|
29
39
|
}
|
|
30
40
|
/**## ODPluginData `interface`
|
|
31
41
|
* Parsed data from the `plugin.json` file in a plugin.
|
|
@@ -122,6 +132,10 @@ export declare class ODPlugin extends ODManagerData {
|
|
|
122
132
|
/**Get a list of all authors & contributors of this plugin. */
|
|
123
133
|
getAuthors(): string[];
|
|
124
134
|
}
|
|
135
|
+
/**## ODPluginClassManagerIdConstraint `type`
|
|
136
|
+
* The constraint/layout for id mappings/interfaces of the `ODPluginClassManager` class.
|
|
137
|
+
*/
|
|
138
|
+
export type ODPluginClassManagerIdConstraint = Record<string, ODManagerData>;
|
|
125
139
|
/**## ODPluginClassManager `class`
|
|
126
140
|
* This is an Open Discord plugin class manager.
|
|
127
141
|
*
|
|
@@ -132,6 +146,12 @@ export declare class ODPlugin extends ODManagerData {
|
|
|
132
146
|
*
|
|
133
147
|
* Use `isPluginLoaded()` to check if a plugin has been loaded before trying to access the manager.
|
|
134
148
|
*/
|
|
135
|
-
export declare class ODPluginClassManager extends ODManager<ODManagerData> {
|
|
149
|
+
export declare class ODPluginClassManager<IdList extends ODPluginClassManagerIdConstraint = ODPluginClassManagerIdConstraint> extends ODManager<ODManagerData> {
|
|
136
150
|
constructor(debug: ODDebugger);
|
|
151
|
+
get<PluginClassId extends keyof IdList>(id: PluginClassId): IdList[PluginClassId];
|
|
152
|
+
get(id: ODValidId): ODManagerData | null;
|
|
153
|
+
remove<PluginClassId extends keyof IdList>(id: PluginClassId): IdList[PluginClassId];
|
|
154
|
+
remove(id: ODValidId): ODManagerData | null;
|
|
155
|
+
exists(id: keyof IdList): boolean;
|
|
156
|
+
exists(id: ODValidId): boolean;
|
|
137
157
|
}
|
|
@@ -33,6 +33,15 @@ class ODPluginManager extends base_1.ODManager {
|
|
|
33
33
|
const plugin = this.get(newId);
|
|
34
34
|
return (plugin !== null && plugin.executed);
|
|
35
35
|
}
|
|
36
|
+
get(id) {
|
|
37
|
+
return super.get(id);
|
|
38
|
+
}
|
|
39
|
+
remove(id) {
|
|
40
|
+
return super.remove(id);
|
|
41
|
+
}
|
|
42
|
+
exists(id) {
|
|
43
|
+
return super.exists(id);
|
|
44
|
+
}
|
|
36
45
|
}
|
|
37
46
|
exports.ODPluginManager = ODPluginManager;
|
|
38
47
|
/**## ODPlugin `class`
|
|
@@ -168,5 +177,14 @@ class ODPluginClassManager extends base_1.ODManager {
|
|
|
168
177
|
constructor(debug) {
|
|
169
178
|
super(debug, "plugin class");
|
|
170
179
|
}
|
|
180
|
+
get(id) {
|
|
181
|
+
return super.get(id);
|
|
182
|
+
}
|
|
183
|
+
remove(id) {
|
|
184
|
+
return super.remove(id);
|
|
185
|
+
}
|
|
186
|
+
exists(id) {
|
|
187
|
+
return super.exists(id);
|
|
188
|
+
}
|
|
171
189
|
}
|
|
172
190
|
exports.ODPluginClassManager = ODPluginClassManager;
|