@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,5 +1,5 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base";
|
|
2
|
-
import { ODDebugger } from "./console";
|
|
1
|
+
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
|
|
2
|
+
import { ODDebugger } from "./console.js";
|
|
3
3
|
/**## ODSessionManagerIdConstraint `type`
|
|
4
4
|
* The constraint/layout for id mappings/interfaces of the `ODSessionManager` class.
|
|
5
5
|
*/
|
|
@@ -1,44 +1,8 @@
|
|
|
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.ODSession = exports.ODSessionManager = void 0;
|
|
37
1
|
///////////////////////////////////////
|
|
38
2
|
//SESSION MODULE
|
|
39
3
|
///////////////////////////////////////
|
|
40
|
-
|
|
41
|
-
|
|
4
|
+
import { ODManager, ODManagerData } from "./base.js";
|
|
5
|
+
import * as crypto from "crypto";
|
|
42
6
|
/**## ODSessionManager `class`
|
|
43
7
|
* This is an Open Discord session manager.
|
|
44
8
|
*
|
|
@@ -47,7 +11,7 @@ const crypto = __importStar(require("crypto"));
|
|
|
47
11
|
*
|
|
48
12
|
* Visit the `ODSession` class for more info
|
|
49
13
|
*/
|
|
50
|
-
class ODSessionManager extends
|
|
14
|
+
export class ODSessionManager extends ODManager {
|
|
51
15
|
constructor(debug) {
|
|
52
16
|
super(debug, "session");
|
|
53
17
|
}
|
|
@@ -61,14 +25,13 @@ class ODSessionManager extends base_1.ODManager {
|
|
|
61
25
|
return super.exists(id);
|
|
62
26
|
}
|
|
63
27
|
}
|
|
64
|
-
exports.ODSessionManager = ODSessionManager;
|
|
65
28
|
/**## ODSession `class`
|
|
66
29
|
* This is an Open Discord session.
|
|
67
30
|
*
|
|
68
31
|
* It can be used to create 100% unique id's for usage in the bot. An id can also store additional data which isn't saved to the filesystem.
|
|
69
32
|
* You can almost compare it to the PHP session system.
|
|
70
33
|
*/
|
|
71
|
-
class ODSession extends
|
|
34
|
+
export class ODSession extends ODManagerData {
|
|
72
35
|
/**The history of previously generated instance ids. Used to reduce the risk of generating the same id twice. */
|
|
73
36
|
#idHistory = [];
|
|
74
37
|
/**The max length of the instance id history. */
|
|
@@ -177,4 +140,3 @@ class ODSession extends base_1.ODManagerData {
|
|
|
177
140
|
this.#timeoutListeners.push(callback);
|
|
178
141
|
}
|
|
179
142
|
}
|
|
180
|
-
exports.ODSession = ODSession;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base";
|
|
2
|
-
import { ODDebugger, ODLiveStatusManager, ODLiveStatusManagerIdConstraint } from "./console";
|
|
3
|
-
import { ODFlag } from "./flag";
|
|
4
|
-
import { ODPlugin, ODUnknownCrashedPlugin } from "./plugin";
|
|
1
|
+
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
|
|
2
|
+
import { ODDebugger, ODLiveStatusManager, ODLiveStatusManagerIdConstraint } from "./console.js";
|
|
3
|
+
import { ODFlag } from "./flag.js";
|
|
4
|
+
import { ODPlugin, ODUnknownCrashedPlugin } from "./plugin.js";
|
|
5
5
|
/**## ODStartScreenComponentRenderCallback `type`
|
|
6
6
|
* This is the render function of a startscreen component. It also sends the location of where the component is rendered.
|
|
7
7
|
*/
|
|
@@ -1,22 +1,16 @@
|
|
|
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.ODStartScreenLogCategoryComponent = exports.ODStartScreenLiveStatusCategoryComponent = exports.ODStartScreenPluginsCategoryComponent = exports.ODStartScreenFlagsCategoryComponent = exports.ODStartScreenPropertiesCategoryComponent = exports.ODStartScreenCategoryComponent = exports.ODStartScreenHeaderComponent = exports.ODStartScreenLogoComponent = exports.ODStartScreenComponent = exports.ODStartScreenManager = void 0;
|
|
7
1
|
///////////////////////////////////////
|
|
8
2
|
//STARTSCREEN MODULE
|
|
9
3
|
///////////////////////////////////////
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { ODManager, ODManagerData } from "./base.js";
|
|
5
|
+
import { ODError } from "./console.js";
|
|
6
|
+
import ansis from "ansis";
|
|
13
7
|
/**## ODStartScreenManager `class`
|
|
14
8
|
* This is an Open Discord startscreen manager.
|
|
15
9
|
*
|
|
16
10
|
* This class is responsible for managing & rendering the startscreen of the bot.
|
|
17
11
|
* The startscreen is the part you see when the bot has started up successfully. (e.g. the Open Discord logo, logs, livestatus, flags, ...)
|
|
18
12
|
*/
|
|
19
|
-
class ODStartScreenManager extends
|
|
13
|
+
export class ODStartScreenManager extends ODManager {
|
|
20
14
|
/**Alias to the Open Discord debugger. */
|
|
21
15
|
#debug;
|
|
22
16
|
/**Alias to the livestatus manager. */
|
|
@@ -43,11 +37,11 @@ class ODStartScreenManager extends base_1.ODManager {
|
|
|
43
37
|
try {
|
|
44
38
|
const renderedText = await component.renderAll(location);
|
|
45
39
|
console.log(renderedText);
|
|
46
|
-
this.#debug.console.debugfile.writeText("[STARTSCREEN] Component: \"" + component.id + "\"\n" +
|
|
40
|
+
this.#debug.console.debugfile.writeText("[STARTSCREEN] Component: \"" + component.id + "\"\n" + ansis.strip(renderedText));
|
|
47
41
|
}
|
|
48
42
|
catch (e) {
|
|
49
43
|
this.#debug.console.log("Unable to render \"" + component.id + "\" startscreen component!", "error");
|
|
50
|
-
this.#debug.console.debugfile.writeErrorMessage(new
|
|
44
|
+
this.#debug.console.debugfile.writeErrorMessage(new ODError(e, "uncaughtException"));
|
|
51
45
|
}
|
|
52
46
|
location++;
|
|
53
47
|
}
|
|
@@ -62,7 +56,6 @@ class ODStartScreenManager extends base_1.ODManager {
|
|
|
62
56
|
return super.exists(id);
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
|
-
exports.ODStartScreenManager = ODStartScreenManager;
|
|
66
59
|
/**## ODStartScreenComponent `class`
|
|
67
60
|
* This is an Open Discord startscreen component.
|
|
68
61
|
*
|
|
@@ -71,7 +64,7 @@ exports.ODStartScreenManager = ODStartScreenManager;
|
|
|
71
64
|
*
|
|
72
65
|
* It's recommended to use pre-built components except if you really need a custom one.
|
|
73
66
|
*/
|
|
74
|
-
class ODStartScreenComponent extends
|
|
67
|
+
export class ODStartScreenComponent extends ODManagerData {
|
|
75
68
|
/**The priority of this component. */
|
|
76
69
|
priority;
|
|
77
70
|
/**An optional render function which will be inserted before the default renderer. */
|
|
@@ -93,14 +86,13 @@ class ODStartScreenComponent extends base_1.ODManagerData {
|
|
|
93
86
|
return (textBefore ? textBefore + "\n" : "") + text + (textAfter ? "\n" + textAfter : "");
|
|
94
87
|
}
|
|
95
88
|
}
|
|
96
|
-
exports.ODStartScreenComponent = ODStartScreenComponent;
|
|
97
89
|
/**## ODStartScreenLogoComponent `class`
|
|
98
90
|
* This is an Open Discord startscreen logo component.
|
|
99
91
|
*
|
|
100
92
|
* This component will render an ASCII art logo (from an array) to the startscreen. Every property in the array is another row.
|
|
101
93
|
* An optional priority can be specified to choose the location of the component.
|
|
102
94
|
*/
|
|
103
|
-
class ODStartScreenLogoComponent extends ODStartScreenComponent {
|
|
95
|
+
export class ODStartScreenLogoComponent extends ODStartScreenComponent {
|
|
104
96
|
/**The ASCII logo contents. */
|
|
105
97
|
logo;
|
|
106
98
|
/**When enabled, the component will add a new line above the logo. */
|
|
@@ -114,7 +106,7 @@ class ODStartScreenLogoComponent extends ODStartScreenComponent {
|
|
|
114
106
|
const renderedTop = (this.topPadding ? "\n" : "");
|
|
115
107
|
const renderedLogo = this.logo.join("\n");
|
|
116
108
|
const renderedBottom = (this.bottomPadding ? "\n" : "");
|
|
117
|
-
return
|
|
109
|
+
return ansis.hex(this.logoHexColor)(renderedTop + renderedLogo + renderedBottom);
|
|
118
110
|
});
|
|
119
111
|
this.logo = logo;
|
|
120
112
|
this.topPadding = topPadding ?? false;
|
|
@@ -122,14 +114,13 @@ class ODStartScreenLogoComponent extends ODStartScreenComponent {
|
|
|
122
114
|
this.logoHexColor = logoHexColor ?? "#f8ba00";
|
|
123
115
|
}
|
|
124
116
|
}
|
|
125
|
-
exports.ODStartScreenLogoComponent = ODStartScreenLogoComponent;
|
|
126
117
|
/**## ODStartScreenHeaderComponent `class`
|
|
127
118
|
* This is an Open Discord startscreen header component.
|
|
128
119
|
*
|
|
129
120
|
* This component will render a header to the startscreen. Properties can be aligned left, right or centered.
|
|
130
121
|
* An optional priority can be specified to choose the location of the component.
|
|
131
122
|
*/
|
|
132
|
-
class ODStartScreenHeaderComponent extends ODStartScreenComponent {
|
|
123
|
+
export class ODStartScreenHeaderComponent extends ODStartScreenComponent {
|
|
133
124
|
/**All properties of this header component. */
|
|
134
125
|
properties;
|
|
135
126
|
/**The spacer used between properties. */
|
|
@@ -138,18 +129,18 @@ class ODStartScreenHeaderComponent extends ODStartScreenComponent {
|
|
|
138
129
|
align;
|
|
139
130
|
constructor(id, priority, properties, spacer, align) {
|
|
140
131
|
super(id, priority, async () => {
|
|
141
|
-
const renderedProperties =
|
|
132
|
+
const renderedProperties = ansis.bold(this.properties.map((prop) => prop.key + ": " + prop.value).join(this.spacer));
|
|
142
133
|
if (!this.align || this.align.align == "left") {
|
|
143
134
|
return renderedProperties;
|
|
144
135
|
}
|
|
145
136
|
else if (this.align.align == "right") {
|
|
146
|
-
const width = (typeof this.align.width == "number") ? this.align.width : (
|
|
137
|
+
const width = (typeof this.align.width == "number") ? this.align.width : (ansis.strip(await this.align.width.renderAll(0)).split("\n").map((row) => row.length).reduce((prev, curr) => {
|
|
147
138
|
if (prev < curr)
|
|
148
139
|
return curr;
|
|
149
140
|
else
|
|
150
141
|
return prev;
|
|
151
142
|
}, 0));
|
|
152
|
-
const offset = width -
|
|
143
|
+
const offset = width - ansis.strip(renderedProperties).length;
|
|
153
144
|
if (offset < 0)
|
|
154
145
|
return renderedProperties;
|
|
155
146
|
else {
|
|
@@ -157,13 +148,13 @@ class ODStartScreenHeaderComponent extends ODStartScreenComponent {
|
|
|
157
148
|
}
|
|
158
149
|
}
|
|
159
150
|
else if (this.align.align == "center") {
|
|
160
|
-
const width = (typeof this.align.width == "number") ? this.align.width : (
|
|
151
|
+
const width = (typeof this.align.width == "number") ? this.align.width : (ansis.strip(await this.align.width.renderAll(0)).split("\n").map((row) => row.length).reduce((prev, curr) => {
|
|
161
152
|
if (prev < curr)
|
|
162
153
|
return curr;
|
|
163
154
|
else
|
|
164
155
|
return prev;
|
|
165
156
|
}));
|
|
166
|
-
const offset = Math.round((width -
|
|
157
|
+
const offset = Math.round((width - ansis.strip(renderedProperties).length) / 2);
|
|
167
158
|
if (offset < 0)
|
|
168
159
|
return renderedProperties;
|
|
169
160
|
else {
|
|
@@ -177,14 +168,13 @@ class ODStartScreenHeaderComponent extends ODStartScreenComponent {
|
|
|
177
168
|
this.align = align ?? null;
|
|
178
169
|
}
|
|
179
170
|
}
|
|
180
|
-
exports.ODStartScreenHeaderComponent = ODStartScreenHeaderComponent;
|
|
181
171
|
/**## ODStartScreenCategoryComponent `class`
|
|
182
172
|
* This is an Open Discord startscreen category component.
|
|
183
173
|
*
|
|
184
174
|
* This component will render a category to the startscreen. This will only render the category name. You'll need to provide your own renderer for the contents.
|
|
185
175
|
* An optional priority can be specified to choose the location of the component.
|
|
186
176
|
*/
|
|
187
|
-
class ODStartScreenCategoryComponent extends ODStartScreenComponent {
|
|
177
|
+
export class ODStartScreenCategoryComponent extends ODStartScreenComponent {
|
|
188
178
|
/**The name of this category. */
|
|
189
179
|
name;
|
|
190
180
|
/**When enabled, this category will still be rendered when the contents are empty. (enabled by default) */
|
|
@@ -193,7 +183,7 @@ class ODStartScreenCategoryComponent extends ODStartScreenComponent {
|
|
|
193
183
|
super(id, priority, async (location) => {
|
|
194
184
|
const contents = await render(location);
|
|
195
185
|
if (contents != "" || this.renderIfEmpty) {
|
|
196
|
-
return
|
|
186
|
+
return ansis.bold.underline("\n" + name.toUpperCase() + (contents != "" ? ":\n" : ":")) + contents;
|
|
197
187
|
}
|
|
198
188
|
else
|
|
199
189
|
return "";
|
|
@@ -202,51 +192,48 @@ class ODStartScreenCategoryComponent extends ODStartScreenComponent {
|
|
|
202
192
|
this.renderIfEmpty = renderIfEmpty ?? true;
|
|
203
193
|
}
|
|
204
194
|
}
|
|
205
|
-
exports.ODStartScreenCategoryComponent = ODStartScreenCategoryComponent;
|
|
206
195
|
/**## ODStartScreenPropertiesCategoryComponent `class`
|
|
207
196
|
* This is an Open Discord startscreen properties category component.
|
|
208
197
|
*
|
|
209
198
|
* This component will render a properties category to the startscreen. This will list the properties in the category.
|
|
210
199
|
* An optional priority can be specified to choose the location of the component.
|
|
211
200
|
*/
|
|
212
|
-
class ODStartScreenPropertiesCategoryComponent extends ODStartScreenCategoryComponent {
|
|
201
|
+
export class ODStartScreenPropertiesCategoryComponent extends ODStartScreenCategoryComponent {
|
|
213
202
|
/**The properties of this category component. */
|
|
214
203
|
properties;
|
|
215
204
|
/**The hex color for the key/name of all the properties. */
|
|
216
205
|
propertyHexColor;
|
|
217
206
|
constructor(id, priority, name, properties, propertyHexColor, renderIfEmpty) {
|
|
218
207
|
super(id, priority, name, () => {
|
|
219
|
-
return this.properties.map((prop) =>
|
|
208
|
+
return this.properties.map((prop) => ansis.hex(this.propertyHexColor)(prop.key + ": ") + prop.value).join("\n");
|
|
220
209
|
}, renderIfEmpty);
|
|
221
210
|
this.properties = properties;
|
|
222
211
|
this.propertyHexColor = propertyHexColor ?? "#f8ba00";
|
|
223
212
|
}
|
|
224
213
|
}
|
|
225
|
-
exports.ODStartScreenPropertiesCategoryComponent = ODStartScreenPropertiesCategoryComponent;
|
|
226
214
|
/**## ODStartScreenFlagsCategoryComponent `class`
|
|
227
215
|
* This is an Open Discord startscreen flags category component.
|
|
228
216
|
*
|
|
229
217
|
* This component will render a flags category to the startscreen. This will list the enabled flags in the category.
|
|
230
218
|
* An optional priority can be specified to choose the location of the component.
|
|
231
219
|
*/
|
|
232
|
-
class ODStartScreenFlagsCategoryComponent extends ODStartScreenCategoryComponent {
|
|
220
|
+
export class ODStartScreenFlagsCategoryComponent extends ODStartScreenCategoryComponent {
|
|
233
221
|
/**A list of all flags to render. */
|
|
234
222
|
flags;
|
|
235
223
|
constructor(id, priority, flags) {
|
|
236
224
|
super(id, priority, "flags", () => {
|
|
237
|
-
return this.flags.filter((flag) => (flag.value == true)).map((flag) =>
|
|
225
|
+
return this.flags.filter((flag) => (flag.value == true)).map((flag) => ansis.blue("[" + flag.name + "] " + flag.description)).join("\n");
|
|
238
226
|
}, false);
|
|
239
227
|
this.flags = flags;
|
|
240
228
|
}
|
|
241
229
|
}
|
|
242
|
-
exports.ODStartScreenFlagsCategoryComponent = ODStartScreenFlagsCategoryComponent;
|
|
243
230
|
/**## ODStartScreenPluginsCategoryComponent `class`
|
|
244
231
|
* This is an Open Discord startscreen plugins category component.
|
|
245
232
|
*
|
|
246
233
|
* This component will render a plugins category to the startscreen. This will list the enabled, disabled & crashed plugins in the category.
|
|
247
234
|
* An optional priority can be specified to choose the location of the component.
|
|
248
235
|
*/
|
|
249
|
-
class ODStartScreenPluginsCategoryComponent extends ODStartScreenCategoryComponent {
|
|
236
|
+
export class ODStartScreenPluginsCategoryComponent extends ODStartScreenCategoryComponent {
|
|
250
237
|
/**A list of all plugins to render. */
|
|
251
238
|
plugins;
|
|
252
239
|
/**A list of all crashed plugins to render. */
|
|
@@ -254,10 +241,10 @@ class ODStartScreenPluginsCategoryComponent extends ODStartScreenCategoryCompone
|
|
|
254
241
|
constructor(id, priority, plugins, unknownCrashedPlugins) {
|
|
255
242
|
super(id, priority, "plugins", () => {
|
|
256
243
|
const disabledPlugins = this.plugins.filter((plugin) => !plugin.enabled);
|
|
257
|
-
const renderedActivePlugins = this.plugins.filter((plugin) => plugin.enabled && plugin.executed).sort((a, b) => b.priority - a.priority).map((plugin) =>
|
|
258
|
-
const renderedCrashedPlugins = this.plugins.filter((plugin) => plugin.enabled && plugin.crashed).sort((a, b) => b.priority - a.priority).map((plugin) =>
|
|
259
|
-
const renderedDisabledPlugins = (disabledPlugins.length > 4) ? [
|
|
260
|
-
const renderedUnknownPlugins = unknownCrashedPlugins.map((plugin) =>
|
|
244
|
+
const renderedActivePlugins = this.plugins.filter((plugin) => plugin.enabled && plugin.executed).sort((a, b) => b.priority - a.priority).map((plugin) => ansis.green("✅ [" + plugin.name + "] " + plugin.details.shortDescription));
|
|
245
|
+
const renderedCrashedPlugins = this.plugins.filter((plugin) => plugin.enabled && plugin.crashed).sort((a, b) => b.priority - a.priority).map((plugin) => ansis.red("❌ [" + plugin.name + "] " + plugin.details.shortDescription));
|
|
246
|
+
const renderedDisabledPlugins = (disabledPlugins.length > 4) ? [ansis.gray("💤 (+" + disabledPlugins.length + " disabled plugins)")] : disabledPlugins.sort((a, b) => b.priority - a.priority).map((plugin) => ansis.gray("💤 [" + plugin.name + "] " + plugin.details.shortDescription));
|
|
247
|
+
const renderedUnknownPlugins = unknownCrashedPlugins.map((plugin) => ansis.red("❌ [" + plugin.name + "] " + plugin.description));
|
|
261
248
|
return [
|
|
262
249
|
...renderedActivePlugins,
|
|
263
250
|
...renderedDisabledPlugins,
|
|
@@ -269,14 +256,13 @@ class ODStartScreenPluginsCategoryComponent extends ODStartScreenCategoryCompone
|
|
|
269
256
|
this.unknownCrashedPlugins = unknownCrashedPlugins;
|
|
270
257
|
}
|
|
271
258
|
}
|
|
272
|
-
exports.ODStartScreenPluginsCategoryComponent = ODStartScreenPluginsCategoryComponent;
|
|
273
259
|
/**## ODStartScreenLiveStatusCategoryComponent `class`
|
|
274
260
|
* This is an Open Discord startscreen livestatus category component.
|
|
275
261
|
*
|
|
276
262
|
* This component will render a livestatus category to the startscreen. This will list the livestatus messages in the category.
|
|
277
263
|
* An optional priority can be specified to choose the location of the component.
|
|
278
264
|
*/
|
|
279
|
-
class ODStartScreenLiveStatusCategoryComponent extends ODStartScreenCategoryComponent {
|
|
265
|
+
export class ODStartScreenLiveStatusCategoryComponent extends ODStartScreenCategoryComponent {
|
|
280
266
|
/**A reference to the Open Discord livestatus manager. */
|
|
281
267
|
livestatus;
|
|
282
268
|
constructor(id, priority, livestatus) {
|
|
@@ -287,16 +273,14 @@ class ODStartScreenLiveStatusCategoryComponent extends ODStartScreenCategoryComp
|
|
|
287
273
|
this.livestatus = livestatus;
|
|
288
274
|
}
|
|
289
275
|
}
|
|
290
|
-
exports.ODStartScreenLiveStatusCategoryComponent = ODStartScreenLiveStatusCategoryComponent;
|
|
291
276
|
/**## ODStartScreenLogsCategoryComponent `class`
|
|
292
277
|
* This is an Open Discord startscreen logs category component.
|
|
293
278
|
*
|
|
294
279
|
* This component will render a logs category to the startscreen. This will only render the logs category name.
|
|
295
280
|
* An optional priority can be specified to choose the location of the component.
|
|
296
281
|
*/
|
|
297
|
-
class ODStartScreenLogCategoryComponent extends ODStartScreenCategoryComponent {
|
|
282
|
+
export class ODStartScreenLogCategoryComponent extends ODStartScreenCategoryComponent {
|
|
298
283
|
constructor(id, priority) {
|
|
299
284
|
super(id, priority, "logs", () => "", true);
|
|
300
285
|
}
|
|
301
286
|
}
|
|
302
|
-
exports.ODStartScreenLogCategoryComponent = ODStartScreenLogCategoryComponent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base";
|
|
2
|
-
import { ODDebugger } from "./console";
|
|
3
|
-
import { ODDatabase, ODDatabaseIdConstraint, ODJsonDatabaseStructure } from "./database";
|
|
1
|
+
import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
|
|
2
|
+
import { ODDebugger } from "./console.js";
|
|
3
|
+
import { ODDatabase, ODDatabaseIdConstraint, ODJsonDatabaseStructure } from "./database.js";
|
|
4
4
|
import * as discord from "discord.js";
|
|
5
5
|
/**## ODValidStatisticValue `type`
|
|
6
6
|
* These are the only allowed types for a statistic value to improve compatibility with different database systems.
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ODDynamicStatistic = exports.ODBaseStatistic = exports.ODStatistic = exports.ODStatisticGlobalScope = exports.ODStatisticScope = exports.ODStatisticManager = void 0;
|
|
4
1
|
///////////////////////////////////////
|
|
5
2
|
//STATISTIC MODULE
|
|
6
3
|
///////////////////////////////////////
|
|
7
|
-
|
|
4
|
+
import { ODId, ODManager, ODManagerData, ODSystemError } from "./base.js";
|
|
8
5
|
/**## ODStatisticManager `class`
|
|
9
6
|
* This is an Open Discord statistics manager.
|
|
10
7
|
*
|
|
@@ -13,7 +10,7 @@ const base_1 = require("./base");
|
|
|
13
10
|
*
|
|
14
11
|
* Statistic can be accessed in the individual scopes.
|
|
15
12
|
*/
|
|
16
|
-
class ODStatisticManager extends
|
|
13
|
+
export class ODStatisticManager extends ODManager {
|
|
17
14
|
/**Alias to Open Discord debugger. */
|
|
18
15
|
#debug;
|
|
19
16
|
/**Alias to Open Discord statistics database. */
|
|
@@ -37,7 +34,7 @@ class ODStatisticManager extends base_1.ODManager {
|
|
|
37
34
|
/**Init all statistics and run `onInit()` listeners. */
|
|
38
35
|
async init() {
|
|
39
36
|
if (!this.database)
|
|
40
|
-
throw new
|
|
37
|
+
throw new ODSystemError("Unable to initialize statistics scopes due to missing database!");
|
|
41
38
|
//get all valid categories
|
|
42
39
|
const validCategories = [];
|
|
43
40
|
for (const scope of this.getAll()) {
|
|
@@ -84,7 +81,6 @@ class ODStatisticManager extends base_1.ODManager {
|
|
|
84
81
|
return super.exists(id);
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
|
-
exports.ODStatisticManager = ODStatisticManager;
|
|
88
84
|
/**## ODStatisticScope `class`
|
|
89
85
|
* This is an Open Discord statistic scope.
|
|
90
86
|
*
|
|
@@ -93,7 +89,7 @@ exports.ODStatisticManager = ODStatisticManager;
|
|
|
93
89
|
*
|
|
94
90
|
* The built-in Open Discord scopes are: `global`, `user`, `ticket`
|
|
95
91
|
*/
|
|
96
|
-
class ODStatisticScope extends
|
|
92
|
+
export class ODStatisticScope extends ODManager {
|
|
97
93
|
/**The id of this statistics scope. */
|
|
98
94
|
id;
|
|
99
95
|
/**Is this scope already initialized? */
|
|
@@ -104,7 +100,7 @@ class ODStatisticScope extends base_1.ODManager {
|
|
|
104
100
|
name;
|
|
105
101
|
constructor(id, name) {
|
|
106
102
|
super();
|
|
107
|
-
this.id = new
|
|
103
|
+
this.id = new ODId(id);
|
|
108
104
|
this.name = name;
|
|
109
105
|
}
|
|
110
106
|
/**Select the database to use to read/write all statistics from/to. (Automatically assigned when used in `ODStatisticManager`) */
|
|
@@ -114,7 +110,7 @@ class ODStatisticScope extends base_1.ODManager {
|
|
|
114
110
|
async getStat(id, scopeId) {
|
|
115
111
|
if (!this.database)
|
|
116
112
|
return null;
|
|
117
|
-
const newId = new
|
|
113
|
+
const newId = new ODId(id);
|
|
118
114
|
const data = await this.database.get(this.id.value + "_" + newId.value, scopeId);
|
|
119
115
|
if (typeof data == "undefined") {
|
|
120
116
|
//set statistics to default value & return
|
|
@@ -130,7 +126,7 @@ class ODStatisticScope extends base_1.ODManager {
|
|
|
130
126
|
async getAllStats(id) {
|
|
131
127
|
if (!this.database)
|
|
132
128
|
return [];
|
|
133
|
-
const newId = new
|
|
129
|
+
const newId = new ODId(id);
|
|
134
130
|
const data = await this.database.getCategory(this.id.value + "_" + newId.value) ?? [];
|
|
135
131
|
const output = [];
|
|
136
132
|
for (const stat of data) {
|
|
@@ -220,7 +216,6 @@ class ODStatisticScope extends base_1.ODManager {
|
|
|
220
216
|
return super.exists(id);
|
|
221
217
|
}
|
|
222
218
|
}
|
|
223
|
-
exports.ODStatisticScope = ODStatisticScope;
|
|
224
219
|
/**## ODStatisticGlobalScope `class`
|
|
225
220
|
* This is an Open Discord statistic global scope.
|
|
226
221
|
*
|
|
@@ -229,7 +224,7 @@ exports.ODStatisticScope = ODStatisticScope;
|
|
|
229
224
|
*
|
|
230
225
|
* This scope is made specifically for the global statistics of Open Discord.
|
|
231
226
|
*/
|
|
232
|
-
class ODStatisticGlobalScope extends ODStatisticScope {
|
|
227
|
+
export class ODStatisticGlobalScope extends ODStatisticScope {
|
|
233
228
|
getStat(id) {
|
|
234
229
|
return super.getStat(id, "GLOBAL");
|
|
235
230
|
}
|
|
@@ -246,7 +241,6 @@ class ODStatisticGlobalScope extends ODStatisticScope {
|
|
|
246
241
|
return super.render("GLOBAL", guild, channel, user);
|
|
247
242
|
}
|
|
248
243
|
}
|
|
249
|
-
exports.ODStatisticGlobalScope = ODStatisticGlobalScope;
|
|
250
244
|
/**## ODStatistic `class`
|
|
251
245
|
* This is an Open Discord statistic.
|
|
252
246
|
*
|
|
@@ -255,7 +249,7 @@ exports.ODStatisticGlobalScope = ODStatisticGlobalScope;
|
|
|
255
249
|
*
|
|
256
250
|
* It's recommended to use the `ODBaseStatistic` & `ODDynamicStatistic` classes instead of this one!
|
|
257
251
|
*/
|
|
258
|
-
class ODStatistic extends
|
|
252
|
+
export class ODStatistic extends ODManagerData {
|
|
259
253
|
/**The priority of this statistic. */
|
|
260
254
|
priority;
|
|
261
255
|
/**The render function of this statistic. */
|
|
@@ -269,14 +263,13 @@ class ODStatistic extends base_1.ODManagerData {
|
|
|
269
263
|
this.value = value ?? null;
|
|
270
264
|
}
|
|
271
265
|
}
|
|
272
|
-
exports.ODStatistic = ODStatistic;
|
|
273
266
|
/**## ODBaseStatistic `class`
|
|
274
267
|
* This is an Open Discord basic statistic.
|
|
275
268
|
*
|
|
276
269
|
* This single statistic will store a number, boolean or string in the database.
|
|
277
270
|
* Use it to create a simple statistic for any statistics scope.
|
|
278
271
|
*/
|
|
279
|
-
class ODBaseStatistic extends ODStatistic {
|
|
272
|
+
export class ODBaseStatistic extends ODStatistic {
|
|
280
273
|
/**The name of this statistic. Rendered in discord embeds/messages. */
|
|
281
274
|
name;
|
|
282
275
|
constructor(id, priority, name, value) {
|
|
@@ -286,7 +279,6 @@ class ODBaseStatistic extends ODStatistic {
|
|
|
286
279
|
this.name = name;
|
|
287
280
|
}
|
|
288
281
|
}
|
|
289
|
-
exports.ODBaseStatistic = ODBaseStatistic;
|
|
290
282
|
/**## ODDynamicStatistic `class`
|
|
291
283
|
* This is an Open Discord dynamic statistic.
|
|
292
284
|
*
|
|
@@ -295,11 +287,10 @@ exports.ODBaseStatistic = ODBaseStatistic;
|
|
|
295
287
|
*
|
|
296
288
|
* This is used in Open Discord for the live ticket status, participants & system status.
|
|
297
289
|
*/
|
|
298
|
-
class ODDynamicStatistic extends ODStatistic {
|
|
290
|
+
export class ODDynamicStatistic extends ODStatistic {
|
|
299
291
|
constructor(id, priority, render) {
|
|
300
292
|
super(id, priority, (value, scopeId, guild, channel, user) => {
|
|
301
293
|
return render(scopeId, guild, channel, user);
|
|
302
294
|
});
|
|
303
295
|
}
|
|
304
296
|
}
|
|
305
|
-
exports.ODDynamicStatistic = ODDynamicStatistic;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base";
|
|
2
|
-
import { ODMessage } from "./builder";
|
|
3
|
-
import { ODDebugger } from "./console";
|
|
4
|
-
import { ODButtonResponderInstance } from "./responder";
|
|
1
|
+
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
|
|
2
|
+
import { ODMessage } from "./builder.js";
|
|
3
|
+
import { ODDebugger } from "./console.js";
|
|
4
|
+
import { ODButtonResponderInstance } from "./responder.js";
|
|
5
5
|
import * as discord from "discord.js";
|
|
6
|
-
import { ODWorkerManager } from "./worker";
|
|
6
|
+
import { ODWorkerManager } from "./worker.js";
|
|
7
7
|
/**## ODVerifyBar `class`
|
|
8
8
|
* This is an Open Discord verifybar.
|
|
9
9
|
*
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ODVerifyBarManager = exports.ODVerifyBar = void 0;
|
|
4
1
|
///////////////////////////////////////
|
|
5
2
|
//VERIFYBAR MODULE
|
|
6
3
|
///////////////////////////////////////
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { ODManager, ODManagerData } from "./base.js";
|
|
5
|
+
import { ODWorkerManager } from "./worker.js";
|
|
9
6
|
/**## ODVerifyBar `class`
|
|
10
7
|
* This is an Open Discord verifybar.
|
|
11
8
|
*
|
|
@@ -13,7 +10,7 @@ const worker_1 = require("./worker");
|
|
|
13
10
|
*
|
|
14
11
|
* It doesn't contain the code which activates or spawns the verifybars!
|
|
15
12
|
*/
|
|
16
|
-
class ODVerifyBar extends
|
|
13
|
+
export class ODVerifyBar extends ODManagerData {
|
|
17
14
|
/**All workers that will run when the verifybar is accepted. */
|
|
18
15
|
success;
|
|
19
16
|
/**All workers that will run when the verifybar is stopped. */
|
|
@@ -24,8 +21,8 @@ class ODVerifyBar extends base_1.ODManagerData {
|
|
|
24
21
|
enabled;
|
|
25
22
|
constructor(id, message, enabled) {
|
|
26
23
|
super(id);
|
|
27
|
-
this.success = new
|
|
28
|
-
this.failure = new
|
|
24
|
+
this.success = new ODWorkerManager("descending");
|
|
25
|
+
this.failure = new ODWorkerManager("descending");
|
|
29
26
|
this.message = message;
|
|
30
27
|
this.enabled = enabled ?? true;
|
|
31
28
|
}
|
|
@@ -43,7 +40,6 @@ class ODVerifyBar extends base_1.ODManagerData {
|
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
|
-
exports.ODVerifyBar = ODVerifyBar;
|
|
47
43
|
/**## ODVerifyBarManager `class`
|
|
48
44
|
* This is an Open Discord verifybar manager.
|
|
49
45
|
*
|
|
@@ -52,7 +48,7 @@ exports.ODVerifyBar = ODVerifyBar;
|
|
|
52
48
|
*
|
|
53
49
|
* It doesn't contain the code which activates the verifybars! This should be implemented by your own.
|
|
54
50
|
*/
|
|
55
|
-
class ODVerifyBarManager extends
|
|
51
|
+
export class ODVerifyBarManager extends ODManager {
|
|
56
52
|
constructor(debug) {
|
|
57
53
|
super(debug, "verifybar");
|
|
58
54
|
}
|
|
@@ -66,4 +62,3 @@ class ODVerifyBarManager extends base_1.ODManager {
|
|
|
66
62
|
return super.exists(id);
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
|
-
exports.ODVerifyBarManager = ODVerifyBarManager;
|