@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,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
|
*/
|
|
@@ -1,14 +1,8 @@
|
|
|
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.ODPluginClassManager = exports.ODPlugin = exports.ODPluginManager = void 0;
|
|
7
1
|
///////////////////////////////////////
|
|
8
2
|
//PLUGIN MODULE
|
|
9
3
|
///////////////////////////////////////
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODVersion } from "./base.js";
|
|
5
|
+
import nodepath from "path";
|
|
12
6
|
/**## ODPluginManager `class`
|
|
13
7
|
* This is an Open Discord plugin manager.
|
|
14
8
|
*
|
|
@@ -18,7 +12,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
18
12
|
*
|
|
19
13
|
* Use `isPluginLoaded()` to check if a plugin has been loaded.
|
|
20
14
|
*/
|
|
21
|
-
class ODPluginManager extends
|
|
15
|
+
export class ODPluginManager extends ODManager {
|
|
22
16
|
/**A manager for all custom managers registered by plugins. */
|
|
23
17
|
classes;
|
|
24
18
|
/**A list of basic details from all plugins that crashed while loading the `plugin.json` file. */
|
|
@@ -29,7 +23,7 @@ class ODPluginManager extends base_1.ODManager {
|
|
|
29
23
|
}
|
|
30
24
|
/**Check if a plugin has been loaded successfully and is available for usage.*/
|
|
31
25
|
isPluginLoaded(id) {
|
|
32
|
-
const newId = new
|
|
26
|
+
const newId = new ODId(id);
|
|
33
27
|
const plugin = this.get(newId);
|
|
34
28
|
return (plugin !== null && plugin.executed);
|
|
35
29
|
}
|
|
@@ -43,7 +37,6 @@ class ODPluginManager extends base_1.ODManager {
|
|
|
43
37
|
return super.exists(id);
|
|
44
38
|
}
|
|
45
39
|
}
|
|
46
|
-
exports.ODPluginManager = ODPluginManager;
|
|
47
40
|
/**## ODPlugin `class`
|
|
48
41
|
* This is an Open Discord plugin.
|
|
49
42
|
*
|
|
@@ -52,7 +45,7 @@ exports.ODPluginManager = ODPluginManager;
|
|
|
52
45
|
*
|
|
53
46
|
* Don't re-execute plugins which are already enabled! It might break the bot or plugin.
|
|
54
47
|
*/
|
|
55
|
-
class ODPlugin extends
|
|
48
|
+
export class ODPlugin extends ODManagerData {
|
|
56
49
|
/**The name of the directory of this plugin. (same as id) */
|
|
57
50
|
dir;
|
|
58
51
|
/**All plugin data found in the `plugin.json` file. */
|
|
@@ -79,7 +72,7 @@ class ODPlugin extends base_1.ODManagerData {
|
|
|
79
72
|
this.data = jsondata;
|
|
80
73
|
this.name = jsondata.name;
|
|
81
74
|
this.priority = jsondata.priority;
|
|
82
|
-
this.version =
|
|
75
|
+
this.version = ODVersion.fromString("plugin", jsondata.version);
|
|
83
76
|
this.details = jsondata.details;
|
|
84
77
|
this.enabled = jsondata.enabled;
|
|
85
78
|
this.executed = false;
|
|
@@ -88,14 +81,14 @@ class ODPlugin extends base_1.ODManagerData {
|
|
|
88
81
|
/**Get the startfile location relative to the `./plugins/` directory. (`./dist/plugins/`) when compiled) */
|
|
89
82
|
getStartFile() {
|
|
90
83
|
const newFile = this.data.startFile.replace(/\.ts$/, ".js");
|
|
91
|
-
return
|
|
84
|
+
return nodepath.join(this.dir, newFile);
|
|
92
85
|
}
|
|
93
86
|
/**Execute this plugin. Returns `false` on crash. */
|
|
94
87
|
async execute(debug, force) {
|
|
95
88
|
if ((this.enabled && !this.crashed) || force) {
|
|
96
89
|
try {
|
|
97
90
|
//import relative plugin directory path (works on windows & unix based systems)
|
|
98
|
-
const pluginPath =
|
|
91
|
+
const pluginPath = nodepath.join(process.cwd(), "./dist/plugins/", this.getStartFile()).replaceAll("\\", "/");
|
|
99
92
|
await import(pluginPath);
|
|
100
93
|
debug.console.log("Plugin \"" + this.id.value + "\" loaded successfully!", "plugin");
|
|
101
94
|
this.executed = true;
|
|
@@ -118,7 +111,7 @@ class ODPlugin extends base_1.ODManagerData {
|
|
|
118
111
|
/**Check if a npm dependency exists. */
|
|
119
112
|
#checkDependency(id) {
|
|
120
113
|
try {
|
|
121
|
-
|
|
114
|
+
import.meta.resolve(id);
|
|
122
115
|
return true;
|
|
123
116
|
}
|
|
124
117
|
catch {
|
|
@@ -162,7 +155,6 @@ class ODPlugin extends base_1.ODManagerData {
|
|
|
162
155
|
return [this.details.author, ...(this.details.contributors ?? [])];
|
|
163
156
|
}
|
|
164
157
|
}
|
|
165
|
-
exports.ODPlugin = ODPlugin;
|
|
166
158
|
/**## ODPluginClassManager `class`
|
|
167
159
|
* This is an Open Discord plugin class manager.
|
|
168
160
|
*
|
|
@@ -173,7 +165,7 @@ exports.ODPlugin = ODPlugin;
|
|
|
173
165
|
*
|
|
174
166
|
* Use `isPluginLoaded()` to check if a plugin has been loaded before trying to access the manager.
|
|
175
167
|
*/
|
|
176
|
-
class ODPluginClassManager extends
|
|
168
|
+
export class ODPluginClassManager extends ODManager {
|
|
177
169
|
constructor(debug) {
|
|
178
170
|
super(debug, "plugin class");
|
|
179
171
|
}
|
|
@@ -187,4 +179,3 @@ class ODPluginClassManager extends base_1.ODManager {
|
|
|
187
179
|
return super.exists(id);
|
|
188
180
|
}
|
|
189
181
|
}
|
|
190
|
-
exports.ODPluginClassManager = ODPluginClassManager;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base";
|
|
2
|
-
import { ODMessageBuildResult, ODMessageBuildSentResult } from "./builder";
|
|
3
|
-
import { ODDebugger } from "./console";
|
|
1
|
+
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
|
|
2
|
+
import { ODMessageBuildResult, ODMessageBuildSentResult } from "./builder.js";
|
|
3
|
+
import { ODDebugger } from "./console.js";
|
|
4
4
|
import * as discord from "discord.js";
|
|
5
5
|
/**## ODPostManagerIdConstraint `type`
|
|
6
6
|
* The constraint/layout for id mappings/interfaces of the `ODPostManager` class.
|
package/dist/api/modules/post.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ODPost = exports.ODPostManager = void 0;
|
|
4
1
|
///////////////////////////////////////
|
|
5
2
|
//POST MODULE
|
|
6
3
|
///////////////////////////////////////
|
|
7
|
-
|
|
4
|
+
import { ODManager, ODManagerData } from "./base.js";
|
|
8
5
|
/**## ODPostManager `class`
|
|
9
6
|
* This is an Open Discord post manager.
|
|
10
7
|
*
|
|
@@ -12,7 +9,7 @@ const base_1 = require("./base");
|
|
|
12
9
|
*
|
|
13
10
|
* You can use this to get the logs channel of the bot (or some other static channel/category).
|
|
14
11
|
*/
|
|
15
|
-
class ODPostManager extends
|
|
12
|
+
export class ODPostManager extends ODManager {
|
|
16
13
|
/**A reference to the main server of the bot */
|
|
17
14
|
#guild = null;
|
|
18
15
|
constructor(debug) {
|
|
@@ -41,7 +38,6 @@ class ODPostManager extends base_1.ODManager {
|
|
|
41
38
|
return super.exists(id);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
exports.ODPostManager = ODPostManager;
|
|
45
41
|
/**## ODPost `class`
|
|
46
42
|
* This is an Open Discord post class.
|
|
47
43
|
*
|
|
@@ -50,7 +46,7 @@ exports.ODPostManager = ODPostManager;
|
|
|
50
46
|
*
|
|
51
47
|
* This class also contains utilities for sending messages via the Open Discord builders.
|
|
52
48
|
*/
|
|
53
|
-
class ODPost extends
|
|
49
|
+
export class ODPost extends ODManagerData {
|
|
54
50
|
/**A reference to the main server of the bot */
|
|
55
51
|
#guild = null;
|
|
56
52
|
/**Is this post already initialized? */
|
|
@@ -98,4 +94,3 @@ class ODPost extends base_1.ODManagerData {
|
|
|
98
94
|
}
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
|
-
exports.ODPost = ODPost;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODValidId, ODNoGeneric } from "./base";
|
|
2
|
-
import { ODDebugger, ODValidConsoleColor } from "./console";
|
|
1
|
+
import { ODManager, ODManagerData, ODValidId, ODNoGeneric } from "./base.js";
|
|
2
|
+
import { ODDebugger, ODValidConsoleColor } from "./console.js";
|
|
3
3
|
/**## ODProgressBarRendererManagerIdConstraint `type`
|
|
4
4
|
* The constraint/layout for id mappings/interfaces of the `ODProgressBarRendererManager` class.
|
|
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.ODDefaultProgressBarRenderer = exports.ODManualProgressBar = exports.ODTimedProgressBar = exports.ODProgressBar = exports.ODProgressBarRenderer = exports.ODProgressBarManager = exports.ODProgressBarRendererManager = void 0;
|
|
7
1
|
///////////////////////////////////////
|
|
8
2
|
//PROGRESS BAR MODULE
|
|
9
3
|
///////////////////////////////////////
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { ODManager, ODManagerData } from "./base.js";
|
|
5
|
+
import readline from "readline";
|
|
6
|
+
import ansis from "ansis";
|
|
13
7
|
/**## ODProgressBarRendererManager `class`
|
|
14
8
|
* This is an Open Discord progress bar renderer manager.
|
|
15
9
|
*
|
|
@@ -17,7 +11,7 @@ const ansis_1 = __importDefault(require("ansis"));
|
|
|
17
11
|
*
|
|
18
12
|
* A renderer is a function which will try to visualize the progress bar in the console.
|
|
19
13
|
*/
|
|
20
|
-
class ODProgressBarRendererManager extends
|
|
14
|
+
export class ODProgressBarRendererManager extends ODManager {
|
|
21
15
|
constructor(debug) {
|
|
22
16
|
super(debug, "progress bar renderer");
|
|
23
17
|
}
|
|
@@ -31,7 +25,6 @@ class ODProgressBarRendererManager extends base_1.ODManager {
|
|
|
31
25
|
return super.exists(id);
|
|
32
26
|
}
|
|
33
27
|
}
|
|
34
|
-
exports.ODProgressBarRendererManager = ODProgressBarRendererManager;
|
|
35
28
|
/**## ODProgressBarManager `class`
|
|
36
29
|
* This is an Open Discord progress bar manager.
|
|
37
30
|
*
|
|
@@ -39,7 +32,7 @@ exports.ODProgressBarRendererManager = ODProgressBarRendererManager;
|
|
|
39
32
|
*
|
|
40
33
|
* There are many types of progress bars available, but you can also create your own!
|
|
41
34
|
*/
|
|
42
|
-
class ODProgressBarManager extends
|
|
35
|
+
export class ODProgressBarManager extends ODManager {
|
|
43
36
|
/**A collection of render types for progress bars. */
|
|
44
37
|
renderers;
|
|
45
38
|
constructor(debug) {
|
|
@@ -56,7 +49,6 @@ class ODProgressBarManager extends base_1.ODManager {
|
|
|
56
49
|
return super.exists(id);
|
|
57
50
|
}
|
|
58
51
|
}
|
|
59
|
-
exports.ODProgressBarManager = ODProgressBarManager;
|
|
60
52
|
/**## ODProgressBarRenderer `class`
|
|
61
53
|
* This is an Open Discord console progress bar renderer.
|
|
62
54
|
*
|
|
@@ -64,7 +56,7 @@ exports.ODProgressBarManager = ODProgressBarManager;
|
|
|
64
56
|
*
|
|
65
57
|
* There are already a lot of default options available if you just want an easy progress bar!
|
|
66
58
|
*/
|
|
67
|
-
class ODProgressBarRenderer extends
|
|
59
|
+
export class ODProgressBarRenderer extends ODManagerData {
|
|
68
60
|
settings;
|
|
69
61
|
#render;
|
|
70
62
|
constructor(id, render, settings) {
|
|
@@ -92,7 +84,6 @@ class ODProgressBarRenderer extends base_1.ODManagerData {
|
|
|
92
84
|
return new ODProgressBarRenderer(this.id, this.#render, newSettings);
|
|
93
85
|
}
|
|
94
86
|
}
|
|
95
|
-
exports.ODProgressBarRenderer = ODProgressBarRenderer;
|
|
96
87
|
/**## ODProgressBar `class`
|
|
97
88
|
* This is an Open Discord console progress bar.
|
|
98
89
|
*
|
|
@@ -101,7 +92,7 @@ exports.ODProgressBarRenderer = ODProgressBarRenderer;
|
|
|
101
92
|
*
|
|
102
93
|
* Use other classes as existing templates or create your own progress bar from scratch using this class.
|
|
103
94
|
*/
|
|
104
|
-
class ODProgressBar extends
|
|
95
|
+
export class ODProgressBar extends ODManagerData {
|
|
105
96
|
/**The renderer of this progress bar. */
|
|
106
97
|
renderer;
|
|
107
98
|
/**Is this progress bar currently active? */
|
|
@@ -146,8 +137,8 @@ class ODProgressBar extends base_1.ODManagerData {
|
|
|
146
137
|
#renderStdout() {
|
|
147
138
|
if (!this.#active)
|
|
148
139
|
return;
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
readline.clearLine(process.stdout, 0);
|
|
141
|
+
readline.cursorTo(process.stdout, 0);
|
|
151
142
|
process.stdout.write(this.renderer.render(this.min, this.max, this.value, this.prefix, this.suffix));
|
|
152
143
|
}
|
|
153
144
|
/**Start showing this progress bar in the console. */
|
|
@@ -180,14 +171,13 @@ class ODProgressBar extends base_1.ODManagerData {
|
|
|
180
171
|
});
|
|
181
172
|
}
|
|
182
173
|
}
|
|
183
|
-
exports.ODProgressBar = ODProgressBar;
|
|
184
174
|
/**## ODTimedProgressBar `class`
|
|
185
175
|
* This is an Open Discord timed console progress bar.
|
|
186
176
|
*
|
|
187
177
|
* It is used to create a simple timed progress bar in the console.
|
|
188
178
|
* You can set a fixed duration (milliseconds) in the constructor.
|
|
189
179
|
*/
|
|
190
|
-
class ODTimedProgressBar extends ODProgressBar {
|
|
180
|
+
export class ODTimedProgressBar extends ODProgressBar {
|
|
191
181
|
/**The time in milliseconds. */
|
|
192
182
|
time;
|
|
193
183
|
/**The mode of the timer. */
|
|
@@ -223,14 +213,13 @@ class ODTimedProgressBar extends ODProgressBar {
|
|
|
223
213
|
return true;
|
|
224
214
|
}
|
|
225
215
|
}
|
|
226
|
-
exports.ODTimedProgressBar = ODTimedProgressBar;
|
|
227
216
|
/**## ODManualProgressBar `class`
|
|
228
217
|
* This is an Open Discord manual console progress bar.
|
|
229
218
|
*
|
|
230
219
|
* It is used to create a simple manual progress bar in the console.
|
|
231
220
|
* You can update the progress manually using `update()`.
|
|
232
221
|
*/
|
|
233
|
-
class ODManualProgressBar extends ODProgressBar {
|
|
222
|
+
export class ODManualProgressBar extends ODProgressBar {
|
|
234
223
|
constructor(id, renderer, amount, autoStop, prefix, suffix) {
|
|
235
224
|
super(id, renderer, 0, amount, 0, autoStop, prefix, suffix);
|
|
236
225
|
}
|
|
@@ -251,8 +240,7 @@ class ODManualProgressBar extends ODProgressBar {
|
|
|
251
240
|
super.update(this.value - amount, stop);
|
|
252
241
|
}
|
|
253
242
|
}
|
|
254
|
-
|
|
255
|
-
class ODDefaultProgressBarRenderer extends ODProgressBarRenderer {
|
|
243
|
+
export class ODDefaultProgressBarRenderer extends ODProgressBarRenderer {
|
|
256
244
|
constructor(id, settings) {
|
|
257
245
|
super(id, (settings, min, max, value, rawPrefix, rawSuffix) => {
|
|
258
246
|
const percentage = (value - min) / (max - min);
|
|
@@ -289,7 +277,6 @@ class ODDefaultProgressBarRenderer extends ODProgressBarRenderer {
|
|
|
289
277
|
}
|
|
290
278
|
/**Switch between Ansis functions based on the specified color. */
|
|
291
279
|
#switchColorAnsis(c) {
|
|
292
|
-
return (c === "openticket") ?
|
|
280
|
+
return (c === "openticket") ? ansis.hex("#f8ba00") : (c === "openmoderation") ? ansis.hex("#1690ff") : ansis[c];
|
|
293
281
|
}
|
|
294
282
|
}
|
|
295
|
-
exports.ODDefaultProgressBarRenderer = ODDefaultProgressBarRenderer;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ODManager, ODValidId, ODManagerData, ODNoGeneric } from "./base";
|
|
1
|
+
import { ODManager, ODValidId, ODManagerData, ODNoGeneric } from "./base.js";
|
|
2
2
|
import * as discord from "discord.js";
|
|
3
|
-
import { ODWorkerManager, ODWorkerCallback } from "./worker";
|
|
4
|
-
import { ODDebugger } from "./console";
|
|
5
|
-
import { ODClientManager, ODContextMenu, ODSlashCommand, ODTextCommand, ODTextCommandInteractionOption } from "./client";
|
|
6
|
-
import { ODDropdownData, ODMessageBuildResult, ODMessageBuildSentResult, ODModalBuildResult } from "./builder";
|
|
3
|
+
import { ODWorkerManager, ODWorkerCallback } from "./worker.js";
|
|
4
|
+
import { ODDebugger } from "./console.js";
|
|
5
|
+
import { ODClientManager, ODContextMenu, ODSlashCommand, ODTextCommand, ODTextCommandInteractionOption } from "./client.js";
|
|
6
|
+
import { ODDropdownData, ODMessageBuildResult, ODMessageBuildSentResult, ODModalBuildResult } from "./builder.js";
|
|
7
7
|
/**## ODResponderImplementation `class`
|
|
8
8
|
* This is an Open Discord responder implementation.
|
|
9
9
|
*
|