@open-discord-bots/framework 0.2.12 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.ts +26 -26
- package/dist/api/index.js +26 -42
- package/dist/api/main.d.ts +24 -24
- package/dist/api/main.js +7 -11
- package/dist/api/modules/action.d.ts +3 -3
- package/dist/api/modules/action.js +8 -14
- package/dist/api/modules/base.d.ts +2 -2
- package/dist/api/modules/base.js +14 -63
- package/dist/api/modules/builder.d.ts +3 -3
- package/dist/api/modules/builder.js +61 -122
- package/dist/api/modules/checker.d.ts +4 -4
- package/dist/api/modules/checker.js +55 -87
- package/dist/api/modules/client.d.ts +4 -4
- package/dist/api/modules/client.js +71 -118
- package/dist/api/modules/code.d.ts +2 -2
- package/dist/api/modules/code.js +3 -8
- package/dist/api/modules/config.d.ts +2 -2
- package/dist/api/modules/config.js +21 -63
- package/dist/api/modules/console.d.ts +2 -2
- package/dist/api/modules/console.js +45 -67
- package/dist/api/modules/cooldown.d.ts +2 -2
- package/dist/api/modules/cooldown.js +13 -23
- package/dist/api/modules/database.d.ts +2 -2
- package/dist/api/modules/database.js +19 -29
- package/dist/api/modules/event.d.ts +2 -2
- package/dist/api/modules/event.js +6 -11
- package/dist/api/modules/flag.d.ts +2 -2
- package/dist/api/modules/flag.js +3 -8
- package/dist/api/modules/fuse.js +2 -7
- package/dist/api/modules/helpmenu.d.ts +2 -2
- package/dist/api/modules/helpmenu.js +8 -16
- package/dist/api/modules/language.d.ts +2 -2
- package/dist/api/modules/language.js +12 -21
- package/dist/api/modules/permission.d.ts +3 -3
- package/dist/api/modules/permission.js +9 -47
- package/dist/api/modules/plugin.d.ts +2 -2
- package/dist/api/modules/plugin.js +10 -19
- package/dist/api/modules/post.d.ts +3 -3
- package/dist/api/modules/post.js +3 -8
- package/dist/api/modules/progressbar.d.ts +2 -2
- package/dist/api/modules/progressbar.js +13 -26
- package/dist/api/modules/responder.d.ts +5 -5
- package/dist/api/modules/responder.js +66 -125
- package/dist/api/modules/session.d.ts +2 -2
- package/dist/api/modules/session.js +4 -42
- package/dist/api/modules/startscreen.d.ts +4 -4
- package/dist/api/modules/startscreen.js +28 -44
- package/dist/api/modules/statistic.d.ts +3 -3
- package/dist/api/modules/statistic.js +11 -20
- package/dist/api/modules/verifybar.d.ts +5 -5
- package/dist/api/modules/verifybar.js +6 -11
- package/dist/api/modules/worker.d.ts +1 -1
- package/dist/api/modules/worker.js +6 -11
- package/dist/cli/editConfig.d.ts +2 -2
- package/dist/cli/editConfig.js +189 -229
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +37 -62
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -13
- package/dist/startup/compilation.d.ts +1 -1
- package/dist/startup/compilation.js +36 -43
- package/dist/startup/dump.d.ts +1 -1
- package/dist/startup/dump.js +4 -41
- package/dist/startup/errorHandling.d.ts +1 -1
- package/dist/startup/errorHandling.js +2 -38
- package/dist/startup/pluginLauncher.d.ts +1 -1
- package/dist/startup/pluginLauncher.js +9 -49
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +21 -72
- package/package.json +2 -1
- package/src/api/index.ts +26 -26
- package/src/api/main.ts +25 -25
- package/src/api/modules/action.ts +3 -3
- package/src/api/modules/base.ts +2 -2
- package/src/api/modules/builder.ts +3 -3
- package/src/api/modules/checker.ts +4 -4
- package/src/api/modules/client.ts +4 -4
- package/src/api/modules/code.ts +2 -2
- package/src/api/modules/component.txt +3 -3
- package/src/api/modules/config.ts +2 -2
- package/src/api/modules/console.ts +2 -2
- package/src/api/modules/cooldown.ts +2 -2
- package/src/api/modules/database.ts +2 -2
- package/src/api/modules/event.ts +2 -2
- package/src/api/modules/flag.ts +2 -2
- package/src/api/modules/helpmenu.ts +2 -2
- package/src/api/modules/language.ts +2 -2
- package/src/api/modules/permission.ts +3 -3
- package/src/api/modules/plugin.ts +4 -4
- package/src/api/modules/post.ts +3 -3
- package/src/api/modules/progressbar.ts +2 -2
- package/src/api/modules/responder.ts +5 -5
- package/src/api/modules/session.ts +2 -2
- package/src/api/modules/startscreen.ts +4 -4
- package/src/api/modules/statistic.ts +3 -3
- package/src/api/modules/verifybar.ts +5 -5
- package/src/api/modules/worker.ts +1 -1
- package/src/cli/editConfig.ts +3 -3
- package/src/cli/index.ts +3 -3
- package/src/index.ts +5 -5
- package/src/startup/compilation.ts +2 -2
- package/src/startup/dump.ts +2 -2
- package/src/startup/errorHandling.ts +2 -2
- package/src/startup/pluginLauncher.ts +2 -2
- package/src/utilities/index.ts +2 -2
- package/tools/cleanup.js +1 -1
- package/tsconfig.json +1 -1
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ODIncrementalTimeoutCooldown = exports.ODTimeoutCooldown = exports.ODIncrementalCounterCooldown = exports.ODCounterCooldown = exports.ODCooldown = exports.ODCooldownData = exports.ODCooldownManager = void 0;
|
|
4
1
|
///////////////////////////////////////
|
|
5
2
|
//COOLDOWN MODULE
|
|
6
3
|
///////////////////////////////////////
|
|
7
|
-
|
|
4
|
+
import { ODManager, ODSystemError, ODManagerData } from "./base.js";
|
|
8
5
|
/**## ODCooldownManager `class`
|
|
9
6
|
* This is an Open Discord cooldown manager.
|
|
10
7
|
*
|
|
@@ -12,7 +9,7 @@ const base_1 = require("./base");
|
|
|
12
9
|
*
|
|
13
10
|
* There are many types of cooldowns available, but you can also create your own!
|
|
14
11
|
*/
|
|
15
|
-
class ODCooldownManager extends
|
|
12
|
+
export class ODCooldownManager extends ODManager {
|
|
16
13
|
constructor(debug) {
|
|
17
14
|
super(debug, "cooldown");
|
|
18
15
|
}
|
|
@@ -32,13 +29,12 @@ class ODCooldownManager extends base_1.ODManager {
|
|
|
32
29
|
return super.exists(id);
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
|
-
exports.ODCooldownManager = ODCooldownManager;
|
|
36
32
|
/**## ODCooldownData `class`
|
|
37
33
|
* This is Open Discord cooldown data.
|
|
38
34
|
*
|
|
39
35
|
* It contains the instance of an active cooldown (e.g. for a user). It is handled by the cooldown itself.
|
|
40
36
|
*/
|
|
41
|
-
class ODCooldownData extends
|
|
37
|
+
export class ODCooldownData extends ODManagerData {
|
|
42
38
|
/**Is this cooldown active? */
|
|
43
39
|
active;
|
|
44
40
|
/**Additional data of this cooldown instance. (different for each cooldown type) */
|
|
@@ -49,7 +45,6 @@ class ODCooldownData extends base_1.ODManagerData {
|
|
|
49
45
|
this.data = data;
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
|
-
exports.ODCooldownData = ODCooldownData;
|
|
53
48
|
/**## ODCooldown `class`
|
|
54
49
|
* This is an Open Discord cooldown.
|
|
55
50
|
*
|
|
@@ -58,8 +53,8 @@ exports.ODCooldownData = ODCooldownData;
|
|
|
58
53
|
*
|
|
59
54
|
* There are also premade cooldowns available in the bot!
|
|
60
55
|
*/
|
|
61
|
-
class ODCooldown extends
|
|
62
|
-
data = new
|
|
56
|
+
export class ODCooldown extends ODManagerData {
|
|
57
|
+
data = new ODManager();
|
|
63
58
|
/**Is this cooldown already initialized? */
|
|
64
59
|
ready = false;
|
|
65
60
|
constructor(id) {
|
|
@@ -67,29 +62,28 @@ class ODCooldown extends base_1.ODManagerData {
|
|
|
67
62
|
}
|
|
68
63
|
/**Check this id and start cooldown when it exeeds the limit! Returns `true` when on cooldown! */
|
|
69
64
|
use(id) {
|
|
70
|
-
throw new
|
|
65
|
+
throw new ODSystemError("Tried to use an unimplemented ODCooldown!");
|
|
71
66
|
}
|
|
72
67
|
/**Check this id without starting or updating the cooldown. Returns `true` when on cooldown! */
|
|
73
68
|
check(id) {
|
|
74
|
-
throw new
|
|
69
|
+
throw new ODSystemError("Tried to use an unimplemented ODCooldown!");
|
|
75
70
|
}
|
|
76
71
|
/**Remove the cooldown for an id when available.*/
|
|
77
72
|
delete(id) {
|
|
78
|
-
throw new
|
|
73
|
+
throw new ODSystemError("Tried to use an unimplemented ODCooldown!");
|
|
79
74
|
}
|
|
80
75
|
/**Initialize the internal systems of this cooldown. */
|
|
81
76
|
async init() {
|
|
82
|
-
throw new
|
|
77
|
+
throw new ODSystemError("Tried to use an unimplemented ODCooldown!");
|
|
83
78
|
}
|
|
84
79
|
}
|
|
85
|
-
exports.ODCooldown = ODCooldown;
|
|
86
80
|
/**## ODCounterCooldown `class`
|
|
87
81
|
* This is an Open Discord counter cooldown.
|
|
88
82
|
*
|
|
89
83
|
* It is is a cooldown based on a counter. When the number exceeds the limit, the cooldown is activated.
|
|
90
84
|
* The number will automatically be decreased with a set amount & interval.
|
|
91
85
|
*/
|
|
92
|
-
class ODCounterCooldown extends ODCooldown {
|
|
86
|
+
export class ODCounterCooldown extends ODCooldown {
|
|
93
87
|
/**The cooldown will activate when exceeding this limit. */
|
|
94
88
|
activeLimit;
|
|
95
89
|
/**The cooldown will deactivate when below this limit. */
|
|
@@ -161,14 +155,13 @@ class ODCounterCooldown extends ODCooldown {
|
|
|
161
155
|
this.ready = true;
|
|
162
156
|
}
|
|
163
157
|
}
|
|
164
|
-
exports.ODCounterCooldown = ODCounterCooldown;
|
|
165
158
|
/**## ODIncrementalCounterCooldown `class`
|
|
166
159
|
* This is an Open Discord incremental counter cooldown.
|
|
167
160
|
*
|
|
168
161
|
* It is is a cooldown based on an incremental counter. It is exactly the same as the normal counter,
|
|
169
162
|
* with the only difference being that it still increments when the limit is already exeeded.
|
|
170
163
|
*/
|
|
171
|
-
class ODIncrementalCounterCooldown extends ODCooldown {
|
|
164
|
+
export class ODIncrementalCounterCooldown extends ODCooldown {
|
|
172
165
|
/**The cooldown will activate when exceeding this limit. */
|
|
173
166
|
activeLimit;
|
|
174
167
|
/**The cooldown will deactivate when below this limit. */
|
|
@@ -241,14 +234,13 @@ class ODIncrementalCounterCooldown extends ODCooldown {
|
|
|
241
234
|
this.ready = true;
|
|
242
235
|
}
|
|
243
236
|
}
|
|
244
|
-
exports.ODIncrementalCounterCooldown = ODIncrementalCounterCooldown;
|
|
245
237
|
/**## ODTimeoutCooldown `class`
|
|
246
238
|
* This is an Open Discord timeout cooldown.
|
|
247
239
|
*
|
|
248
240
|
* It is a cooldown based on a timer. When triggered/updated, the cooldown is activated for the set amount of time.
|
|
249
241
|
* After the timer has timed out, the cooldown will be deleted.
|
|
250
242
|
*/
|
|
251
|
-
class ODTimeoutCooldown extends ODCooldown {
|
|
243
|
+
export class ODTimeoutCooldown extends ODCooldown {
|
|
252
244
|
/**The amount of milliseconds before the cooldown times-out */
|
|
253
245
|
timeoutMs;
|
|
254
246
|
constructor(id, timeoutMs) {
|
|
@@ -301,14 +293,13 @@ class ODTimeoutCooldown extends ODCooldown {
|
|
|
301
293
|
this.ready = true;
|
|
302
294
|
}
|
|
303
295
|
}
|
|
304
|
-
exports.ODTimeoutCooldown = ODTimeoutCooldown;
|
|
305
296
|
/**## ODIncrementalTimeoutCooldown `class`
|
|
306
297
|
* This is an Open Discord incremental timeout cooldown.
|
|
307
298
|
*
|
|
308
299
|
* It is is a cooldown based on an incremental timer. It is exactly the same as the normal timer,
|
|
309
300
|
* with the only difference being that it adds additional time when triggered/updated while the cooldown is already active.
|
|
310
301
|
*/
|
|
311
|
-
class ODIncrementalTimeoutCooldown extends ODCooldown {
|
|
302
|
+
export class ODIncrementalTimeoutCooldown extends ODCooldown {
|
|
312
303
|
/**The amount of milliseconds before the cooldown times-out */
|
|
313
304
|
timeoutMs;
|
|
314
305
|
/**The amount of milliseconds to add when triggered/updated while the cooldown is already active. */
|
|
@@ -365,4 +356,3 @@ class ODIncrementalTimeoutCooldown extends ODCooldown {
|
|
|
365
356
|
this.ready = true;
|
|
366
357
|
}
|
|
367
358
|
}
|
|
368
|
-
exports.ODIncrementalTimeoutCooldown = ODIncrementalTimeoutCooldown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODNoGeneric, ODOptionalPromise, ODPromiseVoid, ODValidId, ODValidJsonType } from "./base";
|
|
2
|
-
import { ODDebugger } from "./console";
|
|
1
|
+
import { ODManager, ODManagerData, ODNoGeneric, ODOptionalPromise, ODPromiseVoid, ODValidId, ODValidJsonType } from "./base.js";
|
|
2
|
+
import { ODDebugger } from "./console.js";
|
|
3
3
|
import * as fjs from "formatted-json-stringify";
|
|
4
4
|
/**## ODDatabaseManagerIdConstraint `type`
|
|
5
5
|
* The constraint/layout for id mappings/interfaces of the `ODDatabaseManager` class.
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ODFormattedJsonDatabase = exports.ODJsonDatabase = exports.ODDatabase = exports.ODDatabaseManager = void 0;
|
|
7
1
|
///////////////////////////////////////
|
|
8
2
|
//DATABASE MODULE
|
|
9
3
|
///////////////////////////////////////
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { ODManager, ODManagerData, ODSystemError } from "./base.js";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import nodepath from "path";
|
|
13
7
|
/**## ODDatabaseManager `class`
|
|
14
8
|
* This is an Open Discord database manager.
|
|
15
9
|
*
|
|
@@ -17,7 +11,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
17
11
|
*
|
|
18
12
|
* You can use this class to get/add a database (`ODDatabase`) in your plugin!
|
|
19
13
|
*/
|
|
20
|
-
class ODDatabaseManager extends
|
|
14
|
+
export class ODDatabaseManager extends ODManager {
|
|
21
15
|
constructor(debug) {
|
|
22
16
|
super(debug, "database");
|
|
23
17
|
}
|
|
@@ -28,7 +22,7 @@ class ODDatabaseManager extends base_1.ODManager {
|
|
|
28
22
|
await database.init();
|
|
29
23
|
}
|
|
30
24
|
catch (err) {
|
|
31
|
-
process.emit("uncaughtException", new
|
|
25
|
+
process.emit("uncaughtException", new ODSystemError(err));
|
|
32
26
|
}
|
|
33
27
|
}
|
|
34
28
|
}
|
|
@@ -42,14 +36,13 @@ class ODDatabaseManager extends base_1.ODManager {
|
|
|
42
36
|
return super.exists(id);
|
|
43
37
|
}
|
|
44
38
|
}
|
|
45
|
-
exports.ODDatabaseManager = ODDatabaseManager;
|
|
46
39
|
/**## ODDatabase `class`
|
|
47
40
|
* This is an Open Discord database template.
|
|
48
41
|
* This class doesn't do anything at all, it just gives a template & basic methods for a database. Use `ODJsonDatabase` instead!
|
|
49
42
|
*
|
|
50
43
|
* You can use this class if you want to create your own database implementation (e.g. `mongodb`, `mysql`,...)!
|
|
51
44
|
*/
|
|
52
|
-
class ODDatabase extends
|
|
45
|
+
export class ODDatabase extends ODManagerData {
|
|
53
46
|
/**The name of the file with extension. */
|
|
54
47
|
file = "";
|
|
55
48
|
/**The path to the file relative to the main directory. */
|
|
@@ -78,7 +71,6 @@ class ODDatabase extends base_1.ODManagerData {
|
|
|
78
71
|
return [];
|
|
79
72
|
}
|
|
80
73
|
}
|
|
81
|
-
exports.ODDatabase = ODDatabase;
|
|
82
74
|
/**## ODJsonDatabase `class`
|
|
83
75
|
* This is an Open Discord JSON database.
|
|
84
76
|
* It stores data in a `json` file as a large `Array` using the `category`, `key`, `value` strategy.
|
|
@@ -86,11 +78,11 @@ exports.ODDatabase = ODDatabase;
|
|
|
86
78
|
*
|
|
87
79
|
* You can use this class if you want to add your own database or to use an existing one!
|
|
88
80
|
*/
|
|
89
|
-
class ODJsonDatabase extends ODDatabase {
|
|
81
|
+
export class ODJsonDatabase extends ODDatabase {
|
|
90
82
|
constructor(id, file, customPath) {
|
|
91
83
|
super(id);
|
|
92
84
|
this.file = (file.endsWith(".json")) ? file : file + ".json";
|
|
93
|
-
this.path = customPath ?
|
|
85
|
+
this.path = customPath ? nodepath.join("./", customPath, this.file) : nodepath.join("./database/", this.file);
|
|
94
86
|
}
|
|
95
87
|
/**Init the database. */
|
|
96
88
|
init() {
|
|
@@ -150,27 +142,26 @@ class ODJsonDatabase extends ODDatabase {
|
|
|
150
142
|
#system = {
|
|
151
143
|
/**Read parsed data from the json file */
|
|
152
144
|
getData: () => {
|
|
153
|
-
if (
|
|
145
|
+
if (fs.existsSync(this.path)) {
|
|
154
146
|
try {
|
|
155
|
-
return JSON.parse(
|
|
147
|
+
return JSON.parse(fs.readFileSync(this.path).toString());
|
|
156
148
|
}
|
|
157
149
|
catch (err) {
|
|
158
150
|
process.emit("uncaughtException", err);
|
|
159
|
-
throw new
|
|
151
|
+
throw new ODSystemError("Unable to read database " + this.path + "! getData() read error. (see error above)");
|
|
160
152
|
}
|
|
161
153
|
}
|
|
162
154
|
else {
|
|
163
|
-
|
|
155
|
+
fs.writeFileSync(this.path, "[]");
|
|
164
156
|
return [];
|
|
165
157
|
}
|
|
166
158
|
},
|
|
167
159
|
/**Write parsed data to the json file */
|
|
168
160
|
setData: (data) => {
|
|
169
|
-
|
|
161
|
+
fs.writeFileSync(this.path, JSON.stringify(data, null, "\t"));
|
|
170
162
|
}
|
|
171
163
|
};
|
|
172
164
|
}
|
|
173
|
-
exports.ODJsonDatabase = ODJsonDatabase;
|
|
174
165
|
/**## ODFormattedJsonDatabase `class`
|
|
175
166
|
* This is an Open Discord Formatted JSON database.
|
|
176
167
|
* It stores data in a `json` file as a large `Array` using the `category`, `key`, `value` strategy.
|
|
@@ -179,13 +170,13 @@ exports.ODJsonDatabase = ODJsonDatabase;
|
|
|
179
170
|
* This one is exactly the same as `ODJsonDatabase`, but it has a formatter from the `formatted-json-stringify` package.
|
|
180
171
|
* This can help you organise it a little bit better!
|
|
181
172
|
*/
|
|
182
|
-
class ODFormattedJsonDatabase extends ODDatabase {
|
|
173
|
+
export class ODFormattedJsonDatabase extends ODDatabase {
|
|
183
174
|
/**The formatter to use on the database array */
|
|
184
175
|
formatter;
|
|
185
176
|
constructor(id, file, formatter, customPath) {
|
|
186
177
|
super(id);
|
|
187
178
|
this.file = (file.endsWith(".json")) ? file : file + ".json";
|
|
188
|
-
this.path = customPath ?
|
|
179
|
+
this.path = customPath ? nodepath.join("./", customPath, this.file) : nodepath.join("./database/", this.file);
|
|
189
180
|
this.formatter = formatter;
|
|
190
181
|
}
|
|
191
182
|
/**Init the database. */
|
|
@@ -246,18 +237,17 @@ class ODFormattedJsonDatabase extends ODDatabase {
|
|
|
246
237
|
#system = {
|
|
247
238
|
/**Read parsed data from the json file */
|
|
248
239
|
getData: () => {
|
|
249
|
-
if (
|
|
250
|
-
return JSON.parse(
|
|
240
|
+
if (fs.existsSync(this.path)) {
|
|
241
|
+
return JSON.parse(fs.readFileSync(this.path).toString());
|
|
251
242
|
}
|
|
252
243
|
else {
|
|
253
|
-
|
|
244
|
+
fs.writeFileSync(this.path, "[]");
|
|
254
245
|
return [];
|
|
255
246
|
}
|
|
256
247
|
},
|
|
257
248
|
/**Write parsed data to the json file */
|
|
258
249
|
setData: (data) => {
|
|
259
|
-
|
|
250
|
+
fs.writeFileSync(this.path, this.formatter.stringify(data));
|
|
260
251
|
}
|
|
261
252
|
};
|
|
262
253
|
}
|
|
263
|
-
exports.ODFormattedJsonDatabase = ODFormattedJsonDatabase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ODManagerData, ODManager, ODValidId, ODPromiseVoid, ODNoGeneric } from "./base";
|
|
2
|
-
import { ODDebugger } from "./console";
|
|
1
|
+
import { ODManagerData, ODManager, ODValidId, ODPromiseVoid, ODNoGeneric } from "./base.js";
|
|
2
|
+
import { ODDebugger } from "./console.js";
|
|
3
3
|
/**## ODEventCallback `type`
|
|
4
4
|
* The base callback function for events.
|
|
5
5
|
*/
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ODEventManager = exports.ODEvent = void 0;
|
|
4
1
|
///////////////////////////////////////
|
|
5
2
|
//EVENT MODULE
|
|
6
3
|
///////////////////////////////////////
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { ODManagerData, ODManager, ODSystemError } from "./base.js";
|
|
5
|
+
import { ODWarningConsoleMessage } from "./console.js";
|
|
9
6
|
/**## ODEvent `class`
|
|
10
7
|
* This is an Open Discord event.
|
|
11
8
|
*
|
|
12
9
|
* This class is made to work with the `ODEventManager` to handle events.
|
|
13
10
|
* The function of this specific class is to manage all listeners for a specifc event!
|
|
14
11
|
*/
|
|
15
|
-
class ODEvent extends
|
|
12
|
+
export class ODEvent extends ODManagerData {
|
|
16
13
|
/**Alias to Open Discord debugger. */
|
|
17
14
|
#debug;
|
|
18
15
|
/**The list of permanent listeners. */
|
|
@@ -42,7 +39,7 @@ class ODEvent extends base_1.ODManagerData {
|
|
|
42
39
|
this.listeners.push(callback);
|
|
43
40
|
if (this.listeners.length > this.listenerLimit) {
|
|
44
41
|
if (this.#debug)
|
|
45
|
-
this.#debug.console.log(new
|
|
42
|
+
this.#debug.console.log(new ODWarningConsoleMessage("Possible event memory leak detected!", [
|
|
46
43
|
{ key: "event", value: this.id.value },
|
|
47
44
|
{ key: "listeners", value: this.listeners.length.toString() }
|
|
48
45
|
]));
|
|
@@ -65,12 +62,11 @@ class ODEvent extends base_1.ODManagerData {
|
|
|
65
62
|
await listener(...params);
|
|
66
63
|
}
|
|
67
64
|
catch (err) {
|
|
68
|
-
process.emit("uncaughtException", new
|
|
65
|
+
process.emit("uncaughtException", new ODSystemError(err));
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
|
-
exports.ODEvent = ODEvent;
|
|
74
70
|
/**## ODEventManager `class`
|
|
75
71
|
* This is an Open Discord event manager.
|
|
76
72
|
*
|
|
@@ -79,7 +75,7 @@ exports.ODEvent = ODEvent;
|
|
|
79
75
|
* It's not recommended to create this class yourself. Plugin events should be registered in their `plugin.json` file instead.
|
|
80
76
|
* All events are available in the `opendiscord.events` global!
|
|
81
77
|
*/
|
|
82
|
-
class ODEventManager extends
|
|
78
|
+
export class ODEventManager extends ODManager {
|
|
83
79
|
/**Reference to the Open Discord debugger */
|
|
84
80
|
#debug;
|
|
85
81
|
constructor(debug) {
|
|
@@ -103,4 +99,3 @@ class ODEventManager extends base_1.ODManager {
|
|
|
103
99
|
return super.exists(id);
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
|
-
exports.ODEventManager = ODEventManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ODValidId, ODManager, ODManagerData, ODNoGeneric } from "./base";
|
|
2
|
-
import { ODDebugger } from "./console";
|
|
1
|
+
import { ODValidId, ODManager, ODManagerData, ODNoGeneric } from "./base.js";
|
|
2
|
+
import { ODDebugger } from "./console.js";
|
|
3
3
|
/**## ODFlag `class`
|
|
4
4
|
* This is an Open Discord flag.
|
|
5
5
|
*
|
package/dist/api/modules/flag.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ODFlagManager = exports.ODFlag = void 0;
|
|
4
1
|
///////////////////////////////////////
|
|
5
2
|
//FLAG MODULE
|
|
6
3
|
///////////////////////////////////////
|
|
7
|
-
|
|
4
|
+
import { ODManager, ODManagerData } from "./base.js";
|
|
8
5
|
/**## ODFlag `class`
|
|
9
6
|
* This is an Open Discord flag.
|
|
10
7
|
*
|
|
@@ -13,7 +10,7 @@ const base_1 = require("./base");
|
|
|
13
10
|
*
|
|
14
11
|
* Flags can also be enabled manually by plugins!
|
|
15
12
|
*/
|
|
16
|
-
class ODFlag extends
|
|
13
|
+
export class ODFlag extends ODManagerData {
|
|
17
14
|
/**The method that has been used to set the value of this flag. (`null` when not set) */
|
|
18
15
|
method = null;
|
|
19
16
|
/**The name of this flag. Visible to the user. */
|
|
@@ -51,14 +48,13 @@ class ODFlag extends base_1.ODManagerData {
|
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
|
-
exports.ODFlag = ODFlag;
|
|
55
51
|
/**## ODFlagManager `class`
|
|
56
52
|
* This is an Open Discord flag manager.
|
|
57
53
|
*
|
|
58
54
|
* This class is responsible for managing & initiating all flags of the bot.
|
|
59
55
|
* It also contains a shortcut for initiating all flags.
|
|
60
56
|
*/
|
|
61
|
-
class ODFlagManager extends
|
|
57
|
+
export class ODFlagManager extends ODManager {
|
|
62
58
|
constructor(debug) {
|
|
63
59
|
super(debug, "flag");
|
|
64
60
|
}
|
|
@@ -78,4 +74,3 @@ class ODFlagManager extends base_1.ODManager {
|
|
|
78
74
|
return super.exists(id);
|
|
79
75
|
}
|
|
80
76
|
}
|
|
81
|
-
exports.ODFlagManager = ODFlagManager;
|
package/dist/api/modules/fuse.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
///////////////////////////////////////
|
|
3
2
|
//FUSE MODULE
|
|
4
3
|
///////////////////////////////////////
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ODSharedFuseManager = exports.ODFuseManager = void 0;
|
|
7
4
|
/**## ODFuseManager `class`
|
|
8
5
|
* This is an Open Discord fuse manager.
|
|
9
6
|
*
|
|
@@ -12,7 +9,7 @@ exports.ODSharedFuseManager = exports.ODFuseManager = void 0;
|
|
|
12
9
|
*
|
|
13
10
|
* You can think of them like real fuses, they disable an entire branch of the bot!
|
|
14
11
|
*/
|
|
15
|
-
class ODFuseManager {
|
|
12
|
+
export class ODFuseManager {
|
|
16
13
|
/**A list of all the defaults */
|
|
17
14
|
fuses;
|
|
18
15
|
constructor(fuses) {
|
|
@@ -27,7 +24,6 @@ class ODFuseManager {
|
|
|
27
24
|
return this.fuses[key];
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
exports.ODFuseManager = ODFuseManager;
|
|
31
27
|
/**## ODFuseManager `class`
|
|
32
28
|
* This is an Open Discord fuse manager.
|
|
33
29
|
*
|
|
@@ -36,7 +32,7 @@ exports.ODFuseManager = ODFuseManager;
|
|
|
36
32
|
*
|
|
37
33
|
* You can think of them like real fuses, they disable an entire branch of the bot!
|
|
38
34
|
*/
|
|
39
|
-
class ODSharedFuseManager extends ODFuseManager {
|
|
35
|
+
export class ODSharedFuseManager extends ODFuseManager {
|
|
40
36
|
constructor() {
|
|
41
37
|
super({
|
|
42
38
|
errorHandling: true,
|
|
@@ -120,4 +116,3 @@ class ODSharedFuseManager extends ODFuseManager {
|
|
|
120
116
|
});
|
|
121
117
|
}
|
|
122
118
|
}
|
|
123
|
-
exports.ODSharedFuseManager = ODSharedFuseManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base";
|
|
2
|
-
import { ODDebugger } from "./console";
|
|
1
|
+
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
|
|
2
|
+
import { ODDebugger } from "./console.js";
|
|
3
3
|
/**## ODHelpMenuComponentRenderer `type`
|
|
4
4
|
* This is the callback of the help menu component renderer. It also contains information about how & where it is rendered.
|
|
5
5
|
*/
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ODHelpMenuManager = exports.ODHelpMenuCategory = exports.ODHelpMenuCommandComponent = exports.ODHelpMenuTextComponent = exports.ODHelpMenuComponent = void 0;
|
|
4
1
|
///////////////////////////////////////
|
|
5
2
|
//HELP MODULE
|
|
6
3
|
///////////////////////////////////////
|
|
7
|
-
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODSystemError } from "./base.js";
|
|
8
5
|
/**## ODHelpMenuComponent `class`
|
|
9
6
|
* This is an Open Discord help menu component.
|
|
10
7
|
*
|
|
11
8
|
* It can render something on the Open Discord help menu.
|
|
12
9
|
*/
|
|
13
|
-
class ODHelpMenuComponent extends
|
|
10
|
+
export class ODHelpMenuComponent extends ODManagerData {
|
|
14
11
|
/**The priority of this component. The higher, the earlier it will appear in the help menu. */
|
|
15
12
|
priority;
|
|
16
13
|
/**The render function for this component. */
|
|
@@ -21,26 +18,24 @@ class ODHelpMenuComponent extends base_1.ODManagerData {
|
|
|
21
18
|
this.render = render;
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
exports.ODHelpMenuComponent = ODHelpMenuComponent;
|
|
25
21
|
/**## ODHelpMenuTextComponent `class`
|
|
26
22
|
* This is an Open Discord help menu text component.
|
|
27
23
|
*
|
|
28
24
|
* It can render a static piece of text on the Open Discord help menu.
|
|
29
25
|
*/
|
|
30
|
-
class ODHelpMenuTextComponent extends ODHelpMenuComponent {
|
|
26
|
+
export class ODHelpMenuTextComponent extends ODHelpMenuComponent {
|
|
31
27
|
constructor(id, priority, text) {
|
|
32
28
|
super(id, priority, () => {
|
|
33
29
|
return text;
|
|
34
30
|
});
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
|
-
exports.ODHelpMenuTextComponent = ODHelpMenuTextComponent;
|
|
38
33
|
/**## ODHelpMenuCommandComponent `class`
|
|
39
34
|
* This is an Open Discord help menu command component.
|
|
40
35
|
*
|
|
41
36
|
* It contains a useful helper to render a command in the Open Discord help menu.
|
|
42
37
|
*/
|
|
43
|
-
class ODHelpMenuCommandComponent extends ODHelpMenuComponent {
|
|
38
|
+
export class ODHelpMenuCommandComponent extends ODHelpMenuComponent {
|
|
44
39
|
constructor(id, priority, settings) {
|
|
45
40
|
super(id, priority, (page, category, location, mode) => {
|
|
46
41
|
if (mode == "slash" && settings.slashName) {
|
|
@@ -58,14 +53,13 @@ class ODHelpMenuCommandComponent extends ODHelpMenuComponent {
|
|
|
58
53
|
return " " + options.map((opt) => (opt.optional) ? `[${opt.name}]` : `<${opt.name}>`).join(" ");
|
|
59
54
|
}
|
|
60
55
|
}
|
|
61
|
-
exports.ODHelpMenuCommandComponent = ODHelpMenuCommandComponent;
|
|
62
56
|
/**## ODHelpMenuCategory `class`
|
|
63
57
|
* This is an Open Discord help menu category.
|
|
64
58
|
*
|
|
65
59
|
* Every category in the help menu is an embed field by default.
|
|
66
60
|
* Try to limit the amount of components per category.
|
|
67
61
|
*/
|
|
68
|
-
class ODHelpMenuCategory extends
|
|
62
|
+
export class ODHelpMenuCategory extends ODManager {
|
|
69
63
|
/**The id of this category. */
|
|
70
64
|
id;
|
|
71
65
|
/**The priority of this category. The higher, the earlier it will appear in the menu. */
|
|
@@ -76,7 +70,7 @@ class ODHelpMenuCategory extends base_1.ODManager {
|
|
|
76
70
|
newPage;
|
|
77
71
|
constructor(id, priority, name, newPage) {
|
|
78
72
|
super();
|
|
79
|
-
this.id = new
|
|
73
|
+
this.id = new ODId(id);
|
|
80
74
|
this.priority = priority;
|
|
81
75
|
this.name = name;
|
|
82
76
|
this.newPage = newPage ?? false;
|
|
@@ -95,7 +89,7 @@ class ODHelpMenuCategory extends base_1.ODManager {
|
|
|
95
89
|
result.push(await component.render(page, category, i, mode));
|
|
96
90
|
}
|
|
97
91
|
catch (err) {
|
|
98
|
-
process.emit("uncaughtException", new
|
|
92
|
+
process.emit("uncaughtException", new ODSystemError(err));
|
|
99
93
|
}
|
|
100
94
|
i++;
|
|
101
95
|
}
|
|
@@ -112,7 +106,6 @@ class ODHelpMenuCategory extends base_1.ODManager {
|
|
|
112
106
|
return super.exists(id);
|
|
113
107
|
}
|
|
114
108
|
}
|
|
115
|
-
exports.ODHelpMenuCategory = ODHelpMenuCategory;
|
|
116
109
|
/**## ODHelpMenuManager `class`
|
|
117
110
|
* This is an Open Discord help menu manager.
|
|
118
111
|
*
|
|
@@ -121,7 +114,7 @@ exports.ODHelpMenuCategory = ODHelpMenuCategory;
|
|
|
121
114
|
*
|
|
122
115
|
* Fewer Categories == More Clean Menu
|
|
123
116
|
*/
|
|
124
|
-
class ODHelpMenuManager extends
|
|
117
|
+
export class ODHelpMenuManager extends ODManager {
|
|
125
118
|
/**Alias to Open Discord debugger. */
|
|
126
119
|
#debug;
|
|
127
120
|
/**The amount of categories per-page. */
|
|
@@ -182,4 +175,3 @@ class ODHelpMenuManager extends base_1.ODManager {
|
|
|
182
175
|
return super.exists(id);
|
|
183
176
|
}
|
|
184
177
|
}
|
|
185
|
-
exports.ODHelpMenuManager = ODHelpMenuManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODNoGeneric, ODPromiseVoid, ODValidId } from "./base";
|
|
2
|
-
import { ODDebugger } from "./console";
|
|
1
|
+
import { ODManager, ODManagerData, ODNoGeneric, ODPromiseVoid, ODValidId } from "./base.js";
|
|
2
|
+
import { ODDebugger } from "./console.js";
|
|
3
3
|
/**## ODLanguageMetadata `interface`
|
|
4
4
|
* This interface contains all metadata available in the language files.
|
|
5
5
|
*/
|