@open-discord-bots/framework 0.2.11 → 0.2.13
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 +12 -12
- package/dist/api/modules/action.js +11 -17
- package/dist/api/modules/base.d.ts +7 -5
- package/dist/api/modules/base.js +22 -67
- package/dist/api/modules/builder.d.ts +44 -44
- package/dist/api/modules/builder.js +81 -142
- package/dist/api/modules/checker.d.ts +7 -7
- 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 +16 -16
- package/dist/api/modules/console.js +61 -83
- 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 +9 -18
- 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 +14 -26
- package/dist/api/modules/responder.d.ts +42 -42
- package/dist/api/modules/responder.js +79 -138
- 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 -22
- package/dist/api/modules/verifybar.d.ts +5 -5
- package/dist/api/modules/verifybar.js +6 -11
- package/dist/api/modules/worker.d.ts +15 -15
- package/dist/api/modules/worker.js +12 -17
- package/dist/cli/editConfig.d.ts +2 -2
- package/dist/cli/editConfig.js +194 -248
- 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 +35 -42
- 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 +14 -52
- package/dist/utilities/index.d.ts +3 -3
- package/dist/utilities/index.js +20 -71
- package/package.json +5 -4
- package/src/api/index.ts +26 -26
- package/src/api/main.ts +25 -25
- package/src/api/modules/action.ts +13 -13
- package/src/api/modules/base.ts +14 -10
- package/src/api/modules/builder.ts +56 -56
- package/src/api/modules/checker.ts +7 -7
- package/src/api/modules/client.ts +18 -18
- package/src/api/modules/code.ts +2 -2
- package/src/api/modules/component.txt +350 -0
- package/src/api/modules/config.ts +3 -3
- package/src/api/modules/console.ts +28 -28
- package/src/api/modules/cooldown.ts +2 -2
- package/src/api/modules/database.ts +3 -3
- package/src/api/modules/event.ts +5 -5
- package/src/api/modules/flag.ts +2 -2
- package/src/api/modules/helpmenu.ts +4 -4
- package/src/api/modules/language.ts +3 -3
- 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 +5 -3
- package/src/api/modules/responder.ts +48 -48
- package/src/api/modules/session.ts +2 -2
- package/src/api/modules/startscreen.ts +4 -4
- package/src/api/modules/statistic.ts +3 -4
- package/src/api/modules/verifybar.ts +5 -5
- package/src/api/modules/worker.ts +25 -25
- package/src/cli/editConfig.ts +23 -37
- 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 +11 -8
- package/src/utilities/index.ts +4 -4
- package/tools/cleanup.js +1 -1
- package/tsconfig.json +2 -1
|
@@ -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", err);
|
|
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", err);
|
|
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
|
*/
|
|
@@ -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.ODJsonLanguage = exports.ODLanguage = exports.ODLanguageManager = void 0;
|
|
7
1
|
///////////////////////////////////////
|
|
8
2
|
//LANGUAGE MODULE
|
|
9
3
|
///////////////////////////////////////
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { ODManager, ODManagerData, ODSystemError } from "./base.js";
|
|
5
|
+
import nodepath from "path";
|
|
6
|
+
import fs from "fs";
|
|
13
7
|
/**## ODLanguageManager `class`
|
|
14
8
|
* This is an Open Discord language manager.
|
|
15
9
|
*
|
|
@@ -18,7 +12,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
18
12
|
*
|
|
19
13
|
* Add new languages using the `ODlanguage` class in your plugin!
|
|
20
14
|
*/
|
|
21
|
-
class ODLanguageManager extends
|
|
15
|
+
export class ODLanguageManager extends ODManager {
|
|
22
16
|
/**The currently selected language. */
|
|
23
17
|
current = null;
|
|
24
18
|
/**The currently selected backup language. (used when translation missing in current language) */
|
|
@@ -126,7 +120,7 @@ class ODLanguageManager extends base_1.ODManager {
|
|
|
126
120
|
await language.init();
|
|
127
121
|
}
|
|
128
122
|
catch (err) {
|
|
129
|
-
process.emit("uncaughtException", new
|
|
123
|
+
process.emit("uncaughtException", new ODSystemError(err));
|
|
130
124
|
}
|
|
131
125
|
}
|
|
132
126
|
}
|
|
@@ -140,7 +134,6 @@ class ODLanguageManager extends base_1.ODManager {
|
|
|
140
134
|
return super.exists(id);
|
|
141
135
|
}
|
|
142
136
|
}
|
|
143
|
-
exports.ODLanguageManager = ODLanguageManager;
|
|
144
137
|
/**## ODLanguage `class`
|
|
145
138
|
* This is an Open Discord language file.
|
|
146
139
|
*
|
|
@@ -149,7 +142,7 @@ exports.ODLanguageManager = ODLanguageManager;
|
|
|
149
142
|
*
|
|
150
143
|
* JSON languages should be created using the `ODJsonLanguage` class instead!
|
|
151
144
|
*/
|
|
152
|
-
class ODLanguage extends
|
|
145
|
+
export class ODLanguage extends ODManagerData {
|
|
153
146
|
/**The name of the file with extension. */
|
|
154
147
|
file = "";
|
|
155
148
|
/**The path to the file relative to the main directory. */
|
|
@@ -167,7 +160,6 @@ class ODLanguage extends base_1.ODManagerData {
|
|
|
167
160
|
//nothing
|
|
168
161
|
}
|
|
169
162
|
}
|
|
170
|
-
exports.ODLanguage = ODLanguage;
|
|
171
163
|
/**## ODJsonLanguage `class`
|
|
172
164
|
* This is an Open Discord JSON language file.
|
|
173
165
|
*
|
|
@@ -176,25 +168,24 @@ exports.ODLanguage = ODLanguage;
|
|
|
176
168
|
*
|
|
177
169
|
* Use the `ODLanguage` class to use translations from non-JSON files!
|
|
178
170
|
*/
|
|
179
|
-
class ODJsonLanguage extends ODLanguage {
|
|
171
|
+
export class ODJsonLanguage extends ODLanguage {
|
|
180
172
|
constructor(id, file, customPath) {
|
|
181
173
|
super(id, {});
|
|
182
174
|
this.file = (file.endsWith(".json")) ? file : file + ".json";
|
|
183
|
-
this.path = customPath ?
|
|
175
|
+
this.path = customPath ? nodepath.join("./", customPath, this.file) : nodepath.join("./languages/", this.file);
|
|
184
176
|
}
|
|
185
177
|
/**Init the langauge. */
|
|
186
178
|
init() {
|
|
187
|
-
if (!
|
|
188
|
-
throw new
|
|
179
|
+
if (!fs.existsSync(this.path))
|
|
180
|
+
throw new ODSystemError("Unable to parse language \"" + nodepath.join("./", this.path) + "\", the file doesn't exist!");
|
|
189
181
|
try {
|
|
190
|
-
this.data = JSON.parse(
|
|
182
|
+
this.data = JSON.parse(fs.readFileSync(this.path).toString());
|
|
191
183
|
}
|
|
192
184
|
catch (err) {
|
|
193
185
|
process.emit("uncaughtException", err);
|
|
194
|
-
throw new
|
|
186
|
+
throw new ODSystemError("Unable to parse language \"" + nodepath.join("./", this.path) + "\"!");
|
|
195
187
|
}
|
|
196
188
|
if (this.data["_TRANSLATION"])
|
|
197
189
|
this.metadata = this.data["_TRANSLATION"];
|
|
198
190
|
}
|
|
199
191
|
}
|
|
200
|
-
exports.ODJsonLanguage = ODJsonLanguage;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ODValidId, ODManager, ODManagerData, ODNoGeneric } from "./base";
|
|
1
|
+
import { ODValidId, ODManager, ODManagerData, ODNoGeneric } from "./base.js";
|
|
2
2
|
import * as discord from "discord.js";
|
|
3
|
-
import { ODDebugger } from "./console";
|
|
4
|
-
import { ODClientManager } from "./client";
|
|
3
|
+
import { ODDebugger } from "./console.js";
|
|
4
|
+
import { ODClientManager } from "./client.js";
|
|
5
5
|
/**## ODPermissionType `type`
|
|
6
6
|
* All available permission types/levels. Can be used in the `ODPermission` class.
|
|
7
7
|
*/
|
|
@@ -1,48 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ODPermissionManager = exports.ODPermission = exports.ODPermissionLevel = void 0;
|
|
37
1
|
///////////////////////////////////////
|
|
38
2
|
//PERMISSION MODULE
|
|
39
3
|
///////////////////////////////////////
|
|
40
|
-
|
|
41
|
-
|
|
4
|
+
import { ODManager, ODSystemError, ODManagerData } from "./base.js";
|
|
5
|
+
import * as discord from "discord.js";
|
|
42
6
|
/**## ODPermissionLevel `enum`
|
|
43
7
|
* All available permission types/levels. But as `enum` instead of `type`. Used to calculate the level.
|
|
44
8
|
*/
|
|
45
|
-
var ODPermissionLevel;
|
|
9
|
+
export var ODPermissionLevel;
|
|
46
10
|
(function (ODPermissionLevel) {
|
|
47
11
|
/**A normal member. (Default for everyone) */
|
|
48
12
|
ODPermissionLevel[ODPermissionLevel["member"] = 0] = "member";
|
|
@@ -56,7 +20,7 @@ var ODPermissionLevel;
|
|
|
56
20
|
ODPermissionLevel[ODPermissionLevel["owner"] = 4] = "owner";
|
|
57
21
|
/**Bot owner or all users from dev team. (Able to use all commands including `/stats reset`) */
|
|
58
22
|
ODPermissionLevel[ODPermissionLevel["developer"] = 5] = "developer";
|
|
59
|
-
})(ODPermissionLevel || (
|
|
23
|
+
})(ODPermissionLevel || (ODPermissionLevel = {}));
|
|
60
24
|
/**## ODPermission `class`
|
|
61
25
|
* This is an Open Discord permission.
|
|
62
26
|
*
|
|
@@ -66,7 +30,7 @@ var ODPermissionLevel;
|
|
|
66
30
|
*
|
|
67
31
|
* Register this class to an `ODPermissionManager` to use it!
|
|
68
32
|
*/
|
|
69
|
-
class ODPermission extends
|
|
33
|
+
export class ODPermission extends ODManagerData {
|
|
70
34
|
/**The scope of this permission. */
|
|
71
35
|
scope;
|
|
72
36
|
/**The type/level of this permission. */
|
|
@@ -83,7 +47,6 @@ class ODPermission extends base_1.ODManagerData {
|
|
|
83
47
|
this.channel = channel ?? null;
|
|
84
48
|
}
|
|
85
49
|
}
|
|
86
|
-
exports.ODPermission = ODPermission;
|
|
87
50
|
/**## ODPermissionManager `class`
|
|
88
51
|
* This is an Open Discord permission manager.
|
|
89
52
|
*
|
|
@@ -92,7 +55,7 @@ exports.ODPermission = ODPermission;
|
|
|
92
55
|
*
|
|
93
56
|
* Add new permissions using the `ODPermission` class in your plugin!
|
|
94
57
|
*/
|
|
95
|
-
class ODPermissionManager extends
|
|
58
|
+
export class ODPermissionManager extends ODManager {
|
|
96
59
|
/**Alias for Open Discord debugger. */
|
|
97
60
|
#debug;
|
|
98
61
|
/**The function for calculating permissions in this manager. */
|
|
@@ -124,12 +87,12 @@ class ODPermissionManager extends base_1.ODManager {
|
|
|
124
87
|
getPermissions(user, channel, guild, settings) {
|
|
125
88
|
try {
|
|
126
89
|
if (!this.#calculation)
|
|
127
|
-
throw new
|
|
90
|
+
throw new ODSystemError("ODPermissionManager:getPermissions() => missing perms calculation");
|
|
128
91
|
return this.#calculation(user, channel, guild, settings);
|
|
129
92
|
}
|
|
130
93
|
catch (err) {
|
|
131
94
|
process.emit("uncaughtException", err);
|
|
132
|
-
throw new
|
|
95
|
+
throw new ODSystemError("ODPermissionManager:getPermissions() => failed perms calculation");
|
|
133
96
|
}
|
|
134
97
|
}
|
|
135
98
|
/**Simplifies the `ODPermissionResult` returned from `getPermissions()` and returns a boolean to check if the user matches the required permissions. */
|
|
@@ -147,7 +110,7 @@ class ODPermissionManager extends base_1.ODManager {
|
|
|
147
110
|
else if (minimum == "developer")
|
|
148
111
|
return (data.level >= ODPermissionLevel["developer"]);
|
|
149
112
|
else
|
|
150
|
-
throw new
|
|
113
|
+
throw new ODSystemError("Invalid minimum permission type at ODPermissionManager.hasPermissions()");
|
|
151
114
|
}
|
|
152
115
|
/**Check for permissions. (default calculation) */
|
|
153
116
|
async #defaultCalculation(user, channel, guild, settings) {
|
|
@@ -320,4 +283,3 @@ class ODPermissionManager extends base_1.ODManager {
|
|
|
320
283
|
return super.exists(id);
|
|
321
284
|
}
|
|
322
285
|
}
|
|
323
|
-
exports.ODPermissionManager = ODPermissionManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODNoGeneric, ODValidId, ODVersion } from "./base";
|
|
2
|
-
import { ODDebugger } from "./console";
|
|
1
|
+
import { ODManager, ODManagerData, ODNoGeneric, ODValidId, ODVersion } from "./base.js";
|
|
2
|
+
import { ODDebugger } from "./console.js";
|
|
3
3
|
/**## ODUnknownCrashedPlugin `interface`
|
|
4
4
|
* Basic details for a plugin that crashed while loading the `plugin.json` file.
|
|
5
5
|
*/
|