@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,49 +1,10 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ODJsonConfig = exports.ODConfig = exports.ODConfigManager = void 0;
|
|
40
1
|
///////////////////////////////////////
|
|
41
2
|
//CONFIG MODULE
|
|
42
3
|
///////////////////////////////////////
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
4
|
+
import { ODManager, ODManagerData, ODSystemError } from "./base.js";
|
|
5
|
+
import nodepath from "path";
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import * as fjs from "formatted-json-stringify";
|
|
47
8
|
/**## ODConfigManager `class`
|
|
48
9
|
* This is an Open Discord config manager.
|
|
49
10
|
*
|
|
@@ -51,7 +12,7 @@ const fjs = __importStar(require("formatted-json-stringify"));
|
|
|
51
12
|
*
|
|
52
13
|
* You can use this class to get/change/add a config file (`ODConfig`) in your plugin!
|
|
53
14
|
*/
|
|
54
|
-
class ODConfigManager extends
|
|
15
|
+
export class ODConfigManager extends ODManager {
|
|
55
16
|
/**Alias to Open Discord debugger. */
|
|
56
17
|
#debug;
|
|
57
18
|
constructor(debug) {
|
|
@@ -72,7 +33,7 @@ class ODConfigManager extends base_1.ODManager {
|
|
|
72
33
|
await config.init();
|
|
73
34
|
}
|
|
74
35
|
catch (err) {
|
|
75
|
-
process.emit("uncaughtException", new
|
|
36
|
+
process.emit("uncaughtException", new ODSystemError(err));
|
|
76
37
|
}
|
|
77
38
|
}
|
|
78
39
|
}
|
|
@@ -86,14 +47,13 @@ class ODConfigManager extends base_1.ODManager {
|
|
|
86
47
|
return super.exists(id);
|
|
87
48
|
}
|
|
88
49
|
}
|
|
89
|
-
exports.ODConfigManager = ODConfigManager;
|
|
90
50
|
/**## ODConfig `class`
|
|
91
51
|
* This is an Open Discord config helper.
|
|
92
52
|
* This class doesn't do anything at all, it just gives a template & basic methods for a config. Use `ODJsonConfig` instead!
|
|
93
53
|
*
|
|
94
54
|
* You can use this class if you want to create your own config implementation (e.g. `yml`, `xml`,...)!
|
|
95
55
|
*/
|
|
96
|
-
class ODConfig extends
|
|
56
|
+
export class ODConfig extends ODManagerData {
|
|
97
57
|
/**The name of the file with extension. */
|
|
98
58
|
file = "";
|
|
99
59
|
/**The path to the file relative to the main directory. */
|
|
@@ -142,7 +102,6 @@ class ODConfig extends base_1.ODManagerData {
|
|
|
142
102
|
this.reloadListeners = [];
|
|
143
103
|
}
|
|
144
104
|
}
|
|
145
|
-
exports.ODConfig = ODConfig;
|
|
146
105
|
/**## ODJsonConfig `class`
|
|
147
106
|
* This is an Open Discord JSON config.
|
|
148
107
|
* You can use this class to get & edit variables from the config files or to create your own JSON config!
|
|
@@ -153,35 +112,35 @@ exports.ODConfig = ODConfig;
|
|
|
153
112
|
* //create a config with custom dir: ./plugins/testplugin/test.json
|
|
154
113
|
* const config = new api.ODJsonConfig("plugin-config","test.json","./plugins/testplugin/")
|
|
155
114
|
*/
|
|
156
|
-
class ODJsonConfig extends ODConfig {
|
|
115
|
+
export class ODJsonConfig extends ODConfig {
|
|
157
116
|
formatter;
|
|
158
117
|
constructor(id, file, customPath, formatter) {
|
|
159
118
|
super(id, {});
|
|
160
119
|
this.file = (file.endsWith(".json")) ? file : file + ".json";
|
|
161
|
-
this.path = customPath ?
|
|
120
|
+
this.path = customPath ? nodepath.join("./", customPath, this.file) : nodepath.join("./config/", this.file);
|
|
162
121
|
this.formatter = formatter ?? new fjs.DefaultFormatter(null, true, " ");
|
|
163
122
|
}
|
|
164
123
|
/**Init the config. */
|
|
165
124
|
init() {
|
|
166
|
-
if (!
|
|
167
|
-
throw new
|
|
125
|
+
if (!fs.existsSync(this.path))
|
|
126
|
+
throw new ODSystemError("Unable to parse config \"" + nodepath.join("./", this.path) + "\", the file doesn't exist!");
|
|
168
127
|
try {
|
|
169
|
-
this.data = JSON.parse(
|
|
128
|
+
this.data = JSON.parse(fs.readFileSync(this.path).toString());
|
|
170
129
|
super.init();
|
|
171
130
|
}
|
|
172
131
|
catch (err) {
|
|
173
132
|
process.emit("uncaughtException", err);
|
|
174
|
-
throw new
|
|
133
|
+
throw new ODSystemError("Unable to parse config \"" + nodepath.join("./", this.path) + "\"!");
|
|
175
134
|
}
|
|
176
135
|
}
|
|
177
136
|
/**Reload the config. Be aware that this doesn't update the config data everywhere in the bot! */
|
|
178
137
|
reload() {
|
|
179
138
|
if (!this.initiated)
|
|
180
|
-
throw new
|
|
181
|
-
if (!
|
|
182
|
-
throw new
|
|
139
|
+
throw new ODSystemError("Unable to reload config \"" + nodepath.join("./", this.path) + "\", the file hasn't been initiated yet!");
|
|
140
|
+
if (!fs.existsSync(this.path))
|
|
141
|
+
throw new ODSystemError("Unable to reload config \"" + nodepath.join("./", this.path) + "\", the file doesn't exist!");
|
|
183
142
|
try {
|
|
184
|
-
this.data = JSON.parse(
|
|
143
|
+
this.data = JSON.parse(fs.readFileSync(this.path).toString());
|
|
185
144
|
super.reload();
|
|
186
145
|
this.reloadListeners.forEach((cb) => {
|
|
187
146
|
try {
|
|
@@ -194,22 +153,21 @@ class ODJsonConfig extends ODConfig {
|
|
|
194
153
|
}
|
|
195
154
|
catch (err) {
|
|
196
155
|
process.emit("uncaughtException", err);
|
|
197
|
-
throw new
|
|
156
|
+
throw new ODSystemError("Unable to reload config \"" + nodepath.join("./", this.path) + "\"!");
|
|
198
157
|
}
|
|
199
158
|
}
|
|
200
159
|
/**Save the edited config to the filesystem. This is used by the Interactive Setup CLI. It's not recommended to use this while the bot is running. */
|
|
201
160
|
save() {
|
|
202
161
|
if (!this.initiated)
|
|
203
|
-
throw new
|
|
162
|
+
throw new ODSystemError("Unable to save config \"" + nodepath.join("./", this.path) + "\", the file hasn't been initiated yet!");
|
|
204
163
|
try {
|
|
205
164
|
const contents = this.formatter.stringify(this.data);
|
|
206
|
-
|
|
165
|
+
fs.writeFileSync(this.path, contents);
|
|
207
166
|
super.save();
|
|
208
167
|
}
|
|
209
168
|
catch (err) {
|
|
210
169
|
process.emit("uncaughtException", err);
|
|
211
|
-
throw new
|
|
170
|
+
throw new ODSystemError("Unable to save config \"" + nodepath.join("./", this.path) + "\"!");
|
|
212
171
|
}
|
|
213
172
|
}
|
|
214
173
|
}
|
|
215
|
-
exports.ODJsonConfig = ODJsonConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ODHTTPGetRequest, ODVersion,
|
|
2
|
-
import { ODMain } from "../main";
|
|
1
|
+
import { ODHTTPGetRequest, ODVersion, ODManager, ODManagerData, ODValidId, ODNoGeneric } from "./base.js";
|
|
2
|
+
import { ODMain } from "../main.js";
|
|
3
3
|
/**## ODValidConsoleColor `type`
|
|
4
4
|
* This is a collection of all the supported console colors within Open Discord.
|
|
5
5
|
*/
|
|
@@ -46,52 +46,52 @@ export declare class ODConsoleMessage {
|
|
|
46
46
|
/**Set the prefix color */
|
|
47
47
|
setColor(color: ODValidConsoleColor): this;
|
|
48
48
|
}
|
|
49
|
-
/**##
|
|
49
|
+
/**## ODInfoConsoleMessage `class`
|
|
50
50
|
* This is an Open Discord console info message.
|
|
51
51
|
*
|
|
52
52
|
* It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "INFO" messages!
|
|
53
53
|
*/
|
|
54
|
-
export declare class
|
|
54
|
+
export declare class ODInfoConsoleMessage extends ODConsoleMessage {
|
|
55
55
|
constructor(message: string, params?: ODConsoleMessageParam[]);
|
|
56
56
|
}
|
|
57
|
-
/**##
|
|
57
|
+
/**## ODSystemConsoleMessage `class`
|
|
58
58
|
* This is an Open Discord console system message.
|
|
59
59
|
*
|
|
60
60
|
* It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "SYSTEM" messages!
|
|
61
61
|
*/
|
|
62
|
-
export declare class
|
|
62
|
+
export declare class ODSystemConsoleMessage extends ODConsoleMessage {
|
|
63
63
|
constructor(message: string, params?: ODConsoleMessageParam[]);
|
|
64
64
|
}
|
|
65
|
-
/**##
|
|
65
|
+
/**## ODPluginConsoleMessage `class`
|
|
66
66
|
* This is an Open Discord console plugin message.
|
|
67
67
|
*
|
|
68
68
|
* It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "PLUGIN" messages!
|
|
69
69
|
*/
|
|
70
|
-
export declare class
|
|
70
|
+
export declare class ODPluginConsoleMessage extends ODConsoleMessage {
|
|
71
71
|
constructor(message: string, params?: ODConsoleMessageParam[]);
|
|
72
72
|
}
|
|
73
|
-
/**##
|
|
73
|
+
/**## ODDebugConsoleMessage `class`
|
|
74
74
|
* This is an Open Discord console debug message.
|
|
75
75
|
*
|
|
76
76
|
* It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "DEBUG" messages!
|
|
77
77
|
*/
|
|
78
|
-
export declare class
|
|
78
|
+
export declare class ODDebugConsoleMessage extends ODConsoleMessage {
|
|
79
79
|
constructor(message: string, params?: ODConsoleMessageParam[]);
|
|
80
80
|
}
|
|
81
|
-
/**##
|
|
81
|
+
/**## ODWarningConsoleMessage `class`
|
|
82
82
|
* This is an Open Discord console warning message.
|
|
83
83
|
*
|
|
84
84
|
* It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "WARNING" messages!
|
|
85
85
|
*/
|
|
86
|
-
export declare class
|
|
86
|
+
export declare class ODWarningConsoleMessage extends ODConsoleMessage {
|
|
87
87
|
constructor(message: string, params?: ODConsoleMessageParam[]);
|
|
88
88
|
}
|
|
89
|
-
/**##
|
|
89
|
+
/**## ODErrorConsoleMessage `class`
|
|
90
90
|
* This is an Open Discord console error message.
|
|
91
91
|
*
|
|
92
92
|
* It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "ERROR" messages!
|
|
93
93
|
*/
|
|
94
|
-
export declare class
|
|
94
|
+
export declare class ODErrorConsoleMessage extends ODConsoleMessage {
|
|
95
95
|
constructor(message: string, params?: ODConsoleMessageParam[]);
|
|
96
96
|
}
|
|
97
97
|
/**## ODError `class`
|
|
@@ -101,10 +101,10 @@ export declare class ODConsoleErrorMessage extends ODConsoleMessage {
|
|
|
101
101
|
*/
|
|
102
102
|
export declare class ODError {
|
|
103
103
|
/**The original error that this class wraps around */
|
|
104
|
-
error:
|
|
104
|
+
error: any;
|
|
105
105
|
/**The origin of the original error */
|
|
106
106
|
origin: NodeJS.UncaughtExceptionOrigin;
|
|
107
|
-
constructor(error:
|
|
107
|
+
constructor(error: any, origin: NodeJS.UncaughtExceptionOrigin);
|
|
108
108
|
/**Render this error to the console using `console.log`! Returns `false` when something went wrong. */
|
|
109
109
|
render(): boolean;
|
|
110
110
|
/**Create a more-detailed, non-colored version of this error to store it in the `debug.txt` file! */
|