@open-discord-bots/framework 0.0.1 → 0.0.2

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.
Files changed (103) hide show
  1. package/LICENSE.md +713 -0
  2. package/README.md +104 -0
  3. package/dist/api/api.d.ts +26 -0
  4. package/dist/api/api.js +44 -0
  5. package/dist/api/main.d.ts +133 -0
  6. package/dist/api/main.js +87 -0
  7. package/dist/api/modules/action.d.ts +34 -0
  8. package/dist/api/modules/action.js +58 -0
  9. package/dist/api/modules/base.d.ts +329 -0
  10. package/dist/api/modules/base.js +804 -0
  11. package/dist/api/modules/builder.d.ts +647 -0
  12. package/dist/api/modules/builder.js +1441 -0
  13. package/dist/api/modules/checker.d.ts +648 -0
  14. package/dist/api/modules/checker.js +1324 -0
  15. package/dist/api/modules/client.d.ts +768 -0
  16. package/dist/api/modules/client.js +1859 -0
  17. package/dist/api/modules/code.d.ts +33 -0
  18. package/dist/api/modules/code.js +57 -0
  19. package/dist/api/modules/config.d.ts +70 -0
  20. package/dist/api/modules/config.js +206 -0
  21. package/dist/api/modules/console.d.ts +305 -0
  22. package/dist/api/modules/console.js +598 -0
  23. package/dist/api/modules/cooldown.d.ts +138 -0
  24. package/dist/api/modules/cooldown.js +359 -0
  25. package/dist/api/modules/database.d.ts +135 -0
  26. package/dist/api/modules/database.js +271 -0
  27. package/dist/api/modules/event.d.ts +43 -0
  28. package/dist/api/modules/event.js +100 -0
  29. package/dist/api/modules/flag.d.ts +40 -0
  30. package/dist/api/modules/flag.js +72 -0
  31. package/dist/api/modules/fuse.d.ts +218 -0
  32. package/dist/api/modules/fuse.js +123 -0
  33. package/dist/api/modules/helpmenu.d.ts +106 -0
  34. package/dist/api/modules/helpmenu.js +167 -0
  35. package/dist/api/modules/language.d.ts +85 -0
  36. package/dist/api/modules/language.js +195 -0
  37. package/dist/api/modules/permission.d.ts +121 -0
  38. package/dist/api/modules/permission.js +314 -0
  39. package/dist/api/modules/plugin.d.ts +128 -0
  40. package/dist/api/modules/plugin.js +168 -0
  41. package/dist/api/modules/post.d.ts +44 -0
  42. package/dist/api/modules/post.js +92 -0
  43. package/dist/api/modules/progressbar.d.ts +108 -0
  44. package/dist/api/modules/progressbar.js +233 -0
  45. package/dist/api/modules/responder.d.ts +506 -0
  46. package/dist/api/modules/responder.js +1468 -0
  47. package/dist/api/modules/session.d.ts +58 -0
  48. package/dist/api/modules/session.js +171 -0
  49. package/dist/api/modules/startscreen.d.ts +165 -0
  50. package/dist/api/modules/startscreen.js +293 -0
  51. package/dist/api/modules/stat.d.ts +142 -0
  52. package/dist/api/modules/stat.js +293 -0
  53. package/dist/api/modules/verifybar.d.ts +54 -0
  54. package/dist/api/modules/verifybar.js +60 -0
  55. package/dist/api/modules/worker.d.ts +41 -0
  56. package/dist/api/modules/worker.js +93 -0
  57. package/dist/api/utils.d.ts +61 -0
  58. package/dist/api/utils.js +254 -0
  59. package/dist/index.d.ts +4 -1
  60. package/dist/index.js +40 -0
  61. package/dist/startup/dump.d.ts +14 -0
  62. package/dist/startup/dump.js +79 -0
  63. package/dist/startup/errorHandling.d.ts +2 -0
  64. package/dist/startup/errorHandling.js +43 -0
  65. package/dist/startup/pluginLauncher.d.ts +2 -0
  66. package/dist/startup/pluginLauncher.js +202 -0
  67. package/package.json +9 -3
  68. package/src/api/api.ts +29 -0
  69. package/src/api/main.ts +189 -0
  70. package/src/api/modules/action.ts +58 -0
  71. package/src/api/modules/base.ts +811 -0
  72. package/src/api/modules/builder.ts +1554 -0
  73. package/src/api/modules/checker.ts +1549 -0
  74. package/src/api/modules/client.ts +2247 -0
  75. package/src/api/modules/code.ts +58 -0
  76. package/src/api/modules/config.ts +159 -0
  77. package/src/api/modules/console.ts +665 -0
  78. package/src/api/modules/cooldown.ts +348 -0
  79. package/src/api/modules/database.ts +278 -0
  80. package/src/api/modules/event.ts +99 -0
  81. package/src/api/modules/flag.ts +73 -0
  82. package/src/api/modules/fuse.ts +348 -0
  83. package/src/api/modules/helpmenu.ts +216 -0
  84. package/src/api/modules/language.ts +201 -0
  85. package/src/api/modules/permission.ts +340 -0
  86. package/src/api/modules/plugin.ts +242 -0
  87. package/src/api/modules/post.ts +90 -0
  88. package/src/api/modules/progressbar.ts +232 -0
  89. package/src/api/modules/responder.ts +1420 -0
  90. package/src/api/modules/session.ts +155 -0
  91. package/src/api/modules/startscreen.ts +320 -0
  92. package/src/api/modules/stat.ts +313 -0
  93. package/src/api/modules/verifybar.ts +61 -0
  94. package/src/api/modules/worker.ts +93 -0
  95. package/src/api/utils.ts +206 -0
  96. package/src/cli/cli.ts +151 -0
  97. package/src/cli/editConfig.ts +943 -0
  98. package/src/index.ts +6 -1
  99. package/src/startup/compilation.ts +186 -0
  100. package/src/startup/dump.ts +45 -0
  101. package/src/startup/errorHandling.ts +38 -0
  102. package/src/startup/pluginLauncher.ts +261 -0
  103. package/LICENSE +0 -21
@@ -0,0 +1,33 @@
1
+ import { ODManager, ODManagerData, ODValidId } from "./base";
2
+ import { ODDebugger } from "./console";
3
+ /**## ODCode `class`
4
+ * This is an Open Discord code runner.
5
+ *
6
+ * Using this, you're able to execute a function just before the startup screen. (90% of the code is already loaded)
7
+ * You can also specify a priority to change the execution order.
8
+ * In Open Discord, this is used for the following processes:
9
+ * - Autoclose/delete
10
+ * - Database syncronisation (with tickets, stats & used options)
11
+ * - Panel auto-update
12
+ * - Database Garbage Collection (removing tickets that don't exist anymore)
13
+ * - And more!
14
+ */
15
+ export declare class ODCode extends ODManagerData {
16
+ /**The priority of this code */
17
+ priority: number;
18
+ /**The main function of this code */
19
+ func: () => void | Promise<void>;
20
+ constructor(id: ODValidId, priority: number, func: () => void | Promise<void>);
21
+ }
22
+ /**## ODCodeManager `class`
23
+ * This is an Open Discord code manager.
24
+ *
25
+ * It manages & executes `ODCode`'s in the correct order.
26
+ *
27
+ * Use this to register a function/code which executes just before the startup screen. (90% is already loaded)
28
+ */
29
+ export declare class ODCodeManager extends ODManager<ODCode> {
30
+ constructor(debug: ODDebugger);
31
+ /**Execute all `ODCode` functions in order of their priority (high to low). */
32
+ execute(): Promise<void>;
33
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ODCodeManager = exports.ODCode = void 0;
4
+ ///////////////////////////////////////
5
+ //CODE MODULE
6
+ ///////////////////////////////////////
7
+ const base_1 = require("./base");
8
+ /**## ODCode `class`
9
+ * This is an Open Discord code runner.
10
+ *
11
+ * Using this, you're able to execute a function just before the startup screen. (90% of the code is already loaded)
12
+ * You can also specify a priority to change the execution order.
13
+ * In Open Discord, this is used for the following processes:
14
+ * - Autoclose/delete
15
+ * - Database syncronisation (with tickets, stats & used options)
16
+ * - Panel auto-update
17
+ * - Database Garbage Collection (removing tickets that don't exist anymore)
18
+ * - And more!
19
+ */
20
+ class ODCode extends base_1.ODManagerData {
21
+ /**The priority of this code */
22
+ priority;
23
+ /**The main function of this code */
24
+ func;
25
+ constructor(id, priority, func) {
26
+ super(id);
27
+ this.priority = priority;
28
+ this.func = func;
29
+ }
30
+ }
31
+ exports.ODCode = ODCode;
32
+ /**## ODCodeManager `class`
33
+ * This is an Open Discord code manager.
34
+ *
35
+ * It manages & executes `ODCode`'s in the correct order.
36
+ *
37
+ * Use this to register a function/code which executes just before the startup screen. (90% is already loaded)
38
+ */
39
+ class ODCodeManager extends base_1.ODManager {
40
+ constructor(debug) {
41
+ super(debug, "code");
42
+ }
43
+ /**Execute all `ODCode` functions in order of their priority (high to low). */
44
+ async execute() {
45
+ const derefArray = [...this.getAll()];
46
+ const workers = derefArray.sort((a, b) => b.priority - a.priority);
47
+ for (const worker of workers) {
48
+ try {
49
+ await worker.func();
50
+ }
51
+ catch (err) {
52
+ process.emit("uncaughtException", err);
53
+ }
54
+ }
55
+ }
56
+ }
57
+ exports.ODCodeManager = ODCodeManager;
@@ -0,0 +1,70 @@
1
+ import { ODManager, ODManagerData, ODPromiseVoid, ODValidId } from "./base";
2
+ import { ODDebugger } from "./console";
3
+ import * as fjs from "formatted-json-stringify";
4
+ /**## ODConfigManager `class`
5
+ * This is an Open Discord config manager.
6
+ *
7
+ * It manages all config files in the bot and allows plugins to access config files from Open Discord & other plugins!
8
+ *
9
+ * You can use this class to get/change/add a config file (`ODConfig`) in your plugin!
10
+ */
11
+ export declare class ODConfigManager extends ODManager<ODConfig> {
12
+ #private;
13
+ constructor(debug: ODDebugger);
14
+ add(data: ODConfig | ODConfig[], overwrite?: boolean): boolean;
15
+ /**Init all config files. */
16
+ init(): Promise<void>;
17
+ }
18
+ /**## ODConfig `class`
19
+ * This is an Open Discord config helper.
20
+ * This class doesn't do anything at all, it just gives a template & basic methods for a config. Use `ODJsonConfig` instead!
21
+ *
22
+ * You can use this class if you want to create your own config implementation (e.g. `yml`, `xml`,...)!
23
+ */
24
+ export declare class ODConfig extends ODManagerData {
25
+ /**The name of the file with extension. */
26
+ file: string;
27
+ /**The path to the file relative to the main directory. */
28
+ path: string;
29
+ /**An object/array of the entire config file! Variables inside it can be edited while the bot is running! */
30
+ data: any;
31
+ /**Is this config already initiated? */
32
+ initiated: boolean;
33
+ /**An array of listeners to run when the config gets reloaded. These are not executed on the initial loading. */
34
+ protected reloadListeners: Function[];
35
+ /**Alias to Open Discord debugger. */
36
+ protected debug: ODDebugger | null;
37
+ constructor(id: ODValidId, data: any);
38
+ /**Use the Open Discord debugger for logs. */
39
+ useDebug(debug: ODDebugger | null): void;
40
+ /**Init the config. */
41
+ init(): ODPromiseVoid;
42
+ /**Reload the config. Be aware that this doesn't update the config data everywhere in the bot! */
43
+ reload(): ODPromiseVoid;
44
+ /**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. */
45
+ save(): ODPromiseVoid;
46
+ /**Listen for a reload of this JSON file! */
47
+ onReload(cb: Function): void;
48
+ /**Remove all reload listeners. Not recommended! */
49
+ removeAllReloadListeners(): void;
50
+ }
51
+ /**## ODJsonConfig `class`
52
+ * This is an Open Discord JSON config.
53
+ * You can use this class to get & edit variables from the config files or to create your own JSON config!
54
+ * @example
55
+ * //create a config from: ./config/test.json with the id "some-config"
56
+ * const config = new api.ODJsonConfig("some-config","test.json")
57
+ *
58
+ * //create a config with custom dir: ./plugins/testplugin/test.json
59
+ * const config = new api.ODJsonConfig("plugin-config","test.json","./plugins/testplugin/")
60
+ */
61
+ export declare class ODJsonConfig extends ODConfig {
62
+ formatter: fjs.custom.BaseFormatter;
63
+ constructor(id: ODValidId, file: string, customPath?: string, formatter?: fjs.custom.BaseFormatter);
64
+ /**Init the config. */
65
+ init(): ODPromiseVoid;
66
+ /**Reload the config. Be aware that this doesn't update the config data everywhere in the bot! */
67
+ reload(): void;
68
+ /**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. */
69
+ save(): ODPromiseVoid;
70
+ }
@@ -0,0 +1,206 @@
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
+ ///////////////////////////////////////
41
+ //CONFIG MODULE
42
+ ///////////////////////////////////////
43
+ const base_1 = require("./base");
44
+ const path_1 = __importDefault(require("path"));
45
+ const fs_1 = __importDefault(require("fs"));
46
+ const fjs = __importStar(require("formatted-json-stringify"));
47
+ /**## ODConfigManager `class`
48
+ * This is an Open Discord config manager.
49
+ *
50
+ * It manages all config files in the bot and allows plugins to access config files from Open Discord & other plugins!
51
+ *
52
+ * You can use this class to get/change/add a config file (`ODConfig`) in your plugin!
53
+ */
54
+ class ODConfigManager extends base_1.ODManager {
55
+ /**Alias to Open Discord debugger. */
56
+ #debug;
57
+ constructor(debug) {
58
+ super(debug, "config");
59
+ this.#debug = debug;
60
+ }
61
+ add(data, overwrite) {
62
+ if (Array.isArray(data))
63
+ data.forEach((d) => d.useDebug(this.#debug));
64
+ else
65
+ data.useDebug(this.#debug);
66
+ return super.add(data, overwrite);
67
+ }
68
+ /**Init all config files. */
69
+ async init() {
70
+ for (const config of this.getAll()) {
71
+ try {
72
+ await config.init();
73
+ }
74
+ catch (err) {
75
+ process.emit("uncaughtException", new base_1.ODSystemError(err));
76
+ }
77
+ }
78
+ }
79
+ }
80
+ exports.ODConfigManager = ODConfigManager;
81
+ /**## ODConfig `class`
82
+ * This is an Open Discord config helper.
83
+ * This class doesn't do anything at all, it just gives a template & basic methods for a config. Use `ODJsonConfig` instead!
84
+ *
85
+ * You can use this class if you want to create your own config implementation (e.g. `yml`, `xml`,...)!
86
+ */
87
+ class ODConfig extends base_1.ODManagerData {
88
+ /**The name of the file with extension. */
89
+ file = "";
90
+ /**The path to the file relative to the main directory. */
91
+ path = "";
92
+ /**An object/array of the entire config file! Variables inside it can be edited while the bot is running! */
93
+ data;
94
+ /**Is this config already initiated? */
95
+ initiated = false;
96
+ /**An array of listeners to run when the config gets reloaded. These are not executed on the initial loading. */
97
+ reloadListeners = [];
98
+ /**Alias to Open Discord debugger. */
99
+ debug = null;
100
+ constructor(id, data) {
101
+ super(id);
102
+ this.data = data;
103
+ }
104
+ /**Use the Open Discord debugger for logs. */
105
+ useDebug(debug) {
106
+ this.debug = debug;
107
+ }
108
+ /**Init the config. */
109
+ init() {
110
+ this.initiated = true;
111
+ if (this.debug)
112
+ this.debug.debug("Initiated config '" + this.file + "' in ODConfigManager.", [{ key: "id", value: this.id.value }]);
113
+ //please implement this feature in your own config extension & extend this function.
114
+ }
115
+ /**Reload the config. Be aware that this doesn't update the config data everywhere in the bot! */
116
+ reload() {
117
+ if (this.debug)
118
+ this.debug.debug("Reloaded config '" + this.file + "' in ODConfigManager.", [{ key: "id", value: this.id.value }]);
119
+ //please implement this feature in your own config extension & extend this function.
120
+ }
121
+ /**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. */
122
+ save() {
123
+ if (this.debug)
124
+ this.debug.debug("Saved config '" + this.file + "' in ODConfigManager.", [{ key: "id", value: this.id.value }]);
125
+ //please implement this feature in your own config extension & extend this function.
126
+ }
127
+ /**Listen for a reload of this JSON file! */
128
+ onReload(cb) {
129
+ this.reloadListeners.push(cb);
130
+ }
131
+ /**Remove all reload listeners. Not recommended! */
132
+ removeAllReloadListeners() {
133
+ this.reloadListeners = [];
134
+ }
135
+ }
136
+ exports.ODConfig = ODConfig;
137
+ /**## ODJsonConfig `class`
138
+ * This is an Open Discord JSON config.
139
+ * You can use this class to get & edit variables from the config files or to create your own JSON config!
140
+ * @example
141
+ * //create a config from: ./config/test.json with the id "some-config"
142
+ * const config = new api.ODJsonConfig("some-config","test.json")
143
+ *
144
+ * //create a config with custom dir: ./plugins/testplugin/test.json
145
+ * const config = new api.ODJsonConfig("plugin-config","test.json","./plugins/testplugin/")
146
+ */
147
+ class ODJsonConfig extends ODConfig {
148
+ formatter;
149
+ constructor(id, file, customPath, formatter) {
150
+ super(id, {});
151
+ this.file = (file.endsWith(".json")) ? file : file + ".json";
152
+ this.path = customPath ? path_1.default.join("./", customPath, this.file) : path_1.default.join("./config/", this.file);
153
+ this.formatter = formatter ?? new fjs.DefaultFormatter(null, true, " ");
154
+ }
155
+ /**Init the config. */
156
+ init() {
157
+ if (!fs_1.default.existsSync(this.path))
158
+ throw new base_1.ODSystemError("Unable to parse config \"" + path_1.default.join("./", this.path) + "\", the file doesn't exist!");
159
+ try {
160
+ this.data = JSON.parse(fs_1.default.readFileSync(this.path).toString());
161
+ super.init();
162
+ }
163
+ catch (err) {
164
+ process.emit("uncaughtException", err);
165
+ throw new base_1.ODSystemError("Unable to parse config \"" + path_1.default.join("./", this.path) + "\"!");
166
+ }
167
+ }
168
+ /**Reload the config. Be aware that this doesn't update the config data everywhere in the bot! */
169
+ reload() {
170
+ if (!this.initiated)
171
+ throw new base_1.ODSystemError("Unable to reload config \"" + path_1.default.join("./", this.path) + "\", the file hasn't been initiated yet!");
172
+ if (!fs_1.default.existsSync(this.path))
173
+ throw new base_1.ODSystemError("Unable to reload config \"" + path_1.default.join("./", this.path) + "\", the file doesn't exist!");
174
+ try {
175
+ this.data = JSON.parse(fs_1.default.readFileSync(this.path).toString());
176
+ super.reload();
177
+ this.reloadListeners.forEach((cb) => {
178
+ try {
179
+ cb();
180
+ }
181
+ catch (err) {
182
+ process.emit("uncaughtException", err);
183
+ }
184
+ });
185
+ }
186
+ catch (err) {
187
+ process.emit("uncaughtException", err);
188
+ throw new base_1.ODSystemError("Unable to reload config \"" + path_1.default.join("./", this.path) + "\"!");
189
+ }
190
+ }
191
+ /**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. */
192
+ save() {
193
+ if (!this.initiated)
194
+ throw new base_1.ODSystemError("Unable to save config \"" + path_1.default.join("./", this.path) + "\", the file hasn't been initiated yet!");
195
+ try {
196
+ const contents = this.formatter.stringify(this.data);
197
+ fs_1.default.writeFileSync(this.path, contents);
198
+ super.save();
199
+ }
200
+ catch (err) {
201
+ process.emit("uncaughtException", err);
202
+ throw new base_1.ODSystemError("Unable to save config \"" + path_1.default.join("./", this.path) + "\"!");
203
+ }
204
+ }
205
+ }
206
+ exports.ODJsonConfig = ODJsonConfig;
@@ -0,0 +1,305 @@
1
+ import { ODHTTPGetRequest, ODVersion, ODSystemError, ODPluginError, ODManager, ODManagerData, ODValidId } from "./base";
2
+ import { ODMain } from "../main";
3
+ /**## ODValidConsoleColor `type`
4
+ * This is a collection of all the supported console colors within Open Discord.
5
+ */
6
+ export type ODValidConsoleColor = "white" | "red" | "yellow" | "green" | "blue" | "gray" | "cyan" | "magenta";
7
+ /**## ODConsoleMessageParam `type`
8
+ * This interface contains all data required for a console log parameter within Open Discord.
9
+ */
10
+ export interface ODConsoleMessageParam {
11
+ /**The key of this parameter. */
12
+ key: string;
13
+ /**The value of this parameter. */
14
+ value: string;
15
+ /**When enabled, this parameter will only be shown in the debug file. */
16
+ hidden?: boolean;
17
+ }
18
+ /**## ODConsoleMessage `class`
19
+ * This is an Open Discord console message.
20
+ *
21
+ * It is used to create beautiful & styled logs in the console with a prefix, message & parameters.
22
+ * It also has full color support using `ansis` and parameters are parsed for you!
23
+ */
24
+ export declare class ODConsoleMessage {
25
+ /**The main message sent in the console */
26
+ message: string;
27
+ /**An array of all the parameters in this message */
28
+ params: ODConsoleMessageParam[];
29
+ /**The prefix of this message (!uppercase recommended!) */
30
+ prefix: string;
31
+ /**The color of the prefix of this message */
32
+ color: ODValidConsoleColor;
33
+ constructor(message: string, prefix: string, color: ODValidConsoleColor, params?: ODConsoleMessageParam[]);
34
+ /**Render this message to the console using `console.log`! Returns `false` when something went wrong. */
35
+ render(): boolean;
36
+ /**Create a more-detailed, non-colored version of this message to store it in the `debug.txt` file! */
37
+ toDebugString(): string;
38
+ /**Render the parameters of this message in a specific color. */
39
+ createParamsString(color: ODValidConsoleColor): string;
40
+ /**Set the message */
41
+ setMessage(message: string): this;
42
+ /**Set the params */
43
+ setParams(params: ODConsoleMessageParam[]): this;
44
+ /**Set the prefix */
45
+ setPrefix(prefix: string): this;
46
+ /**Set the prefix color */
47
+ setColor(color: ODValidConsoleColor): this;
48
+ }
49
+ /**## ODConsoleInfoMessage `class`
50
+ * This is an Open Discord console info message.
51
+ *
52
+ * It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "INFO" messages!
53
+ */
54
+ export declare class ODConsoleInfoMessage extends ODConsoleMessage {
55
+ constructor(message: string, params?: ODConsoleMessageParam[]);
56
+ }
57
+ /**## ODConsoleSystemMessage `class`
58
+ * This is an Open Discord console system message.
59
+ *
60
+ * It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "SYSTEM" messages!
61
+ */
62
+ export declare class ODConsoleSystemMessage extends ODConsoleMessage {
63
+ constructor(message: string, params?: ODConsoleMessageParam[]);
64
+ }
65
+ /**## ODConsolePluginMessage `class`
66
+ * This is an Open Discord console plugin message.
67
+ *
68
+ * It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "PLUGIN" messages!
69
+ */
70
+ export declare class ODConsolePluginMessage extends ODConsoleMessage {
71
+ constructor(message: string, params?: ODConsoleMessageParam[]);
72
+ }
73
+ /**## ODConsoleDebugMessage `class`
74
+ * This is an Open Discord console debug message.
75
+ *
76
+ * It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "DEBUG" messages!
77
+ */
78
+ export declare class ODConsoleDebugMessage extends ODConsoleMessage {
79
+ constructor(message: string, params?: ODConsoleMessageParam[]);
80
+ }
81
+ /**## ODConsoleWarningMessage `class`
82
+ * This is an Open Discord console warning message.
83
+ *
84
+ * It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "WARNING" messages!
85
+ */
86
+ export declare class ODConsoleWarningMessage extends ODConsoleMessage {
87
+ constructor(message: string, params?: ODConsoleMessageParam[]);
88
+ }
89
+ /**## ODConsoleErrorMessage `class`
90
+ * This is an Open Discord console error message.
91
+ *
92
+ * It is the same as a normal `ODConsoleMessage`, but it has a predefined prefix & color scheme for the "ERROR" messages!
93
+ */
94
+ export declare class ODConsoleErrorMessage extends ODConsoleMessage {
95
+ constructor(message: string, params?: ODConsoleMessageParam[]);
96
+ }
97
+ /**## ODError `class`
98
+ * This is an Open Discord error.
99
+ *
100
+ * It is used to render and log Node.js errors & crashes in a styled way to the console & `debug.txt` file!
101
+ */
102
+ export declare class ODError {
103
+ /**The original error that this class wraps around */
104
+ error: Error | ODSystemError | ODPluginError;
105
+ /**The origin of the original error */
106
+ origin: NodeJS.UncaughtExceptionOrigin;
107
+ constructor(error: Error | ODSystemError | ODPluginError, origin: NodeJS.UncaughtExceptionOrigin);
108
+ /**Render this error to the console using `console.log`! Returns `false` when something went wrong. */
109
+ render(): boolean;
110
+ /**Create a more-detailed, non-colored version of this error to store it in the `debug.txt` file! */
111
+ toDebugString(): string;
112
+ }
113
+ /**## ODConsoleMessageTypes `type`
114
+ * This is a collection of all the default console message types within Open Discord.
115
+ */
116
+ export type ODConsoleMessageTypes = "info" | "system" | "plugin" | "debug" | "warning" | "error";
117
+ /**## ODConsoleManager `class`
118
+ * This is the Open Discord console manager.
119
+ *
120
+ * It handles the entire console system of Open Discord. It's also the place where you need to log `ODConsoleMessage`'s.
121
+ * This manager keeps a short history of messages sent to the console which is configurable by plugins.
122
+ *
123
+ * The debug file (`debug.txt`) is handled in a sub-manager!
124
+ */
125
+ export declare class ODConsoleManager {
126
+ #private;
127
+ /**The history of `ODConsoleMessage`'s and `ODError`'s since startup */
128
+ history: (ODConsoleMessage | ODError)[];
129
+ /**The max length of the history. The oldest messages will be removed when over the limit */
130
+ historylength: number;
131
+ /**An alias to the debugfile manager. (`debug.txt`) */
132
+ debugfile: ODDebugFileManager;
133
+ /**Is silent mode enabled? */
134
+ silent: boolean;
135
+ constructor(historylength: number, debugfile: ODDebugFileManager);
136
+ /**Log a message to the console ... But in the Open Discord way :) */
137
+ log(message: ODConsoleMessage): void;
138
+ log(message: ODError): void;
139
+ log(message: string, type?: ODConsoleMessageTypes, params?: ODConsoleMessageParam[]): void;
140
+ }
141
+ /**## ODDebugFileManager `class`
142
+ * This is the Open Discord debug file manager.
143
+ *
144
+ * It manages the Open Discord debug file (`debug.txt`) which keeps a history of all system logs.
145
+ * There are even internal logs that aren't logged to the console which are available in this file!
146
+ *
147
+ * Using this class, you can change the max length of this file and some other cool things!
148
+ */
149
+ export declare class ODDebugFileManager {
150
+ #private;
151
+ /**The path to the debugfile (`./debug.txt` by default) */
152
+ path: string;
153
+ /**The filename of the debugfile (`debug.txt` by default) */
154
+ filename: string;
155
+ /**The current version of the bot used in the debug file. */
156
+ version: ODVersion;
157
+ /**The max length of the debug file. */
158
+ maxlines: number;
159
+ constructor(path: string, filename: string, maxlines: number, version: ODVersion);
160
+ /**Write an `ODConsoleMessage` to the debug file */
161
+ writeConsoleMessage(message: ODConsoleMessage): void;
162
+ /**Write an `ODError` to the debug file */
163
+ writeErrorMessage(error: ODError): void;
164
+ /**Write custom text to the debug file */
165
+ writeText(text: string): void;
166
+ /**Write a custom note to the debug file (starting with `[NOTE]:`) */
167
+ writeNote(text: string): void;
168
+ }
169
+ /**## ODDebugger `class`
170
+ * This is the Open Discord debugger.
171
+ *
172
+ * It is a simple wrapper around the `ODConsoleManager` to handle debugging (primarily for `ODManagers`).
173
+ * Messages created using this debugger are only logged to the debug file unless specified otherwise.
174
+ *
175
+ * You will probably notice this class being used in the `ODManager` constructor.
176
+ *
177
+ * Using this system, all additions & removals inside a manager are logged to the debug file. This makes searching for errors a lot easier!
178
+ */
179
+ export declare class ODDebugger {
180
+ /**An alias to the Open Discord console manager. */
181
+ console: ODConsoleManager;
182
+ /**When enabled, debug logs are also shown in the console. */
183
+ visible: boolean;
184
+ constructor(console: ODConsoleManager);
185
+ /**Create a debug message. This will always be logged to `debug.txt` & sometimes to the console (when enabled). Returns `true` when visible */
186
+ debug(message: string, params?: {
187
+ key: string;
188
+ value: string;
189
+ }[]): boolean;
190
+ }
191
+ /**## ODLivestatusColor `type`
192
+ * This is a collection of all the colors available within the LiveStatus system.
193
+ */
194
+ export type ODLiveStatusColor = "normal" | "red" | "green" | "blue" | "yellow" | "white" | "gray" | "magenta" | "cyan";
195
+ /**## ODLiveStatusSourceData `interface`
196
+ * This is an interface containing all raw data received from the LiveStatus system.
197
+ */
198
+ export interface ODLiveStatusSourceData {
199
+ /**The message to display */
200
+ message: {
201
+ /**The title of the message to display */
202
+ title: string;
203
+ /**The title color of the message to display */
204
+ titleColor: ODLiveStatusColor;
205
+ /**The description of the message to display */
206
+ description: string;
207
+ /**The description color of the message to display */
208
+ descriptionColor: ODLiveStatusColor;
209
+ };
210
+ /**The message will only be shown when the bot matches all statements */
211
+ active: {
212
+ /**A list of versions to match */
213
+ versions: string[];
214
+ /**A list of languages to match */
215
+ languages: string[];
216
+ /**All languages should match */
217
+ allLanguages: boolean;
218
+ /**Match when the bot is using plugins */
219
+ usingPlugins: boolean;
220
+ /**Match when the bot is not using plugins */
221
+ notUsingPlugins: boolean;
222
+ /**Match when the bot is using slash commands */
223
+ usingSlashCommands: boolean;
224
+ /**Match when the bot is not using slash commands */
225
+ notUsingSlashCommands: boolean;
226
+ /**Match when the bot is not using transcripts */
227
+ notUsingTranscripts: boolean;
228
+ /**Match when the bot is using text transcripts */
229
+ usingTextTranscripts: boolean;
230
+ /**Match when the bot is using html transcripts */
231
+ usingHtmlTranscripts: boolean;
232
+ };
233
+ }
234
+ /**## ODLiveStatusSource `class`
235
+ * This is the Open Discord livestatus source.
236
+ *
237
+ * It is an empty template for a livestatus source.
238
+ * By default, you should use `ODLiveStatusUrlSource` or `ODLiveStatusFileSource`,
239
+ * unless you want to create one on your own!
240
+ *
241
+ * This class doesn't do anything on it's own! It's just a template!
242
+ */
243
+ export declare class ODLiveStatusSource extends ODManagerData {
244
+ /**The raw data of this source */
245
+ data: ODLiveStatusSourceData[];
246
+ constructor(id: ODValidId, data: ODLiveStatusSourceData[]);
247
+ /**Change the current data using this method! */
248
+ setData(data: ODLiveStatusSourceData[]): void;
249
+ /**Get all messages relevant to the bot based on some parameters. */
250
+ getMessages(main: ODMain): Promise<ODLiveStatusSourceData[]>;
251
+ }
252
+ /**## ODLiveStatusFileSource `class`
253
+ * This is the Open Discord livestatus file source.
254
+ *
255
+ * It is a LiveStatus source that will read the data from a local file.
256
+ *
257
+ * This can be used for testing/extending the LiveStatus system!
258
+ */
259
+ export declare class ODLiveStatusFileSource extends ODLiveStatusSource {
260
+ /**The path to the source file */
261
+ path: string;
262
+ constructor(id: ODValidId, path: string);
263
+ }
264
+ /**## ODLiveStatusUrlSource `class`
265
+ * This is the Open Discord livestatus url source.
266
+ *
267
+ * It is a LiveStatus source that will read the data from a http URL (json file).
268
+ *
269
+ * This is the default way of receiving LiveStatus messages!
270
+ */
271
+ export declare class ODLiveStatusUrlSource extends ODLiveStatusSource {
272
+ /**The url used in the request */
273
+ url: string;
274
+ /**The `ODHTTPGetRequest` helper to fetch the url! */
275
+ request: ODHTTPGetRequest;
276
+ constructor(main: ODMain, id: ODValidId, url: string);
277
+ getMessages(main: ODMain): Promise<ODLiveStatusSourceData[]>;
278
+ }
279
+ /**## ODLiveStatusManager `class`
280
+ * This is the Open Discord livestatus manager.
281
+ *
282
+ * It manages all LiveStatus sources and has the renderer for all LiveStatus messages.
283
+ *
284
+ * You can use this to customise or add stuff to the LiveStatus system.
285
+ * Access it in the global `opendiscord.startscreen.livestatus` variable!
286
+ */
287
+ export declare class ODLiveStatusManager extends ODManager<ODLiveStatusSource> {
288
+ #private;
289
+ /**The class responsible for rendering the livestatus messages. */
290
+ renderer: ODLiveStatusRenderer;
291
+ constructor(debug: ODDebugger, main: ODMain);
292
+ /**Get the messages from all sources combined! */
293
+ getAllMessages(): Promise<ODLiveStatusSourceData[]>;
294
+ }
295
+ /**## ODLiveStatusRenderer `class`
296
+ * This is the Open Discord livestatus renderer.
297
+ *
298
+ * It's responsible for rendering all LiveStatus messages to the console.
299
+ */
300
+ export declare class ODLiveStatusRenderer {
301
+ #private;
302
+ constructor(console: ODConsoleManager);
303
+ /**Render all messages */
304
+ render(messages: ODLiveStatusSourceData[]): string;
305
+ }