@open-discord-bots/framework 0.1.2 → 0.2.1

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 (77) hide show
  1. package/README.md +21 -19
  2. package/dist/api/modules/action.d.ts +26 -4
  3. package/dist/api/modules/action.js +16 -0
  4. package/dist/api/modules/base.d.ts +12 -2
  5. package/dist/api/modules/base.js +11 -1
  6. package/dist/api/modules/builder.d.ts +117 -21
  7. package/dist/api/modules/builder.js +72 -0
  8. package/dist/api/modules/checker.d.ts +111 -15
  9. package/dist/api/modules/checker.js +201 -9
  10. package/dist/api/modules/client.d.ts +45 -22
  11. package/dist/api/modules/client.js +58 -34
  12. package/dist/api/modules/code.d.ts +11 -1
  13. package/dist/api/modules/code.js +9 -0
  14. package/dist/api/modules/config.d.ts +15 -5
  15. package/dist/api/modules/config.js +9 -0
  16. package/dist/api/modules/console.d.ts +11 -1
  17. package/dist/api/modules/console.js +9 -0
  18. package/dist/api/modules/cooldown.d.ts +11 -1
  19. package/dist/api/modules/cooldown.js +9 -0
  20. package/dist/api/modules/database.d.ts +36 -4
  21. package/dist/api/modules/database.js +9 -17
  22. package/dist/api/modules/event.d.ts +20 -7
  23. package/dist/api/modules/event.js +6 -0
  24. package/dist/api/modules/flag.d.ts +11 -1
  25. package/dist/api/modules/flag.js +9 -0
  26. package/dist/api/modules/helpmenu.d.ts +22 -2
  27. package/dist/api/modules/helpmenu.js +18 -0
  28. package/dist/api/modules/language.d.ts +15 -1
  29. package/dist/api/modules/language.js +9 -4
  30. package/dist/api/modules/permission.d.ts +11 -1
  31. package/dist/api/modules/permission.js +9 -0
  32. package/dist/api/modules/plugin.d.ts +23 -3
  33. package/dist/api/modules/plugin.js +18 -0
  34. package/dist/api/modules/post.d.ts +11 -1
  35. package/dist/api/modules/post.js +9 -0
  36. package/dist/api/modules/progressbar.d.ts +24 -3
  37. package/dist/api/modules/progressbar.js +19 -0
  38. package/dist/api/modules/responder.d.ts +105 -21
  39. package/dist/api/modules/responder.js +54 -0
  40. package/dist/api/modules/session.d.ts +11 -1
  41. package/dist/api/modules/session.js +9 -0
  42. package/dist/api/modules/startscreen.d.ts +17 -7
  43. package/dist/api/modules/startscreen.js +9 -0
  44. package/dist/api/modules/stat.d.ts +42 -8
  45. package/dist/api/modules/stat.js +18 -4
  46. package/dist/api/modules/verifybar.d.ts +18 -4
  47. package/dist/api/modules/verifybar.js +9 -0
  48. package/dist/api/modules/worker.d.ts +7 -1
  49. package/dist/api/modules/worker.js +9 -0
  50. package/dist/utilities/index.js +1 -0
  51. package/package.json +1 -1
  52. package/src/api/main.ts +10 -10
  53. package/src/api/modules/action.ts +37 -4
  54. package/src/api/modules/base.ts +30 -3
  55. package/src/api/modules/builder.ts +226 -21
  56. package/src/api/modules/checker.ts +292 -17
  57. package/src/api/modules/client.ts +129 -43
  58. package/src/api/modules/code.ts +27 -1
  59. package/src/api/modules/config.ts +33 -7
  60. package/src/api/modules/console.ts +27 -1
  61. package/src/api/modules/cooldown.ts +27 -1
  62. package/src/api/modules/database.ts +55 -4
  63. package/src/api/modules/event.ts +35 -7
  64. package/src/api/modules/flag.ts +27 -1
  65. package/src/api/modules/helpmenu.ts +55 -2
  66. package/src/api/modules/language.ts +35 -1
  67. package/src/api/modules/permission.ts +27 -1
  68. package/src/api/modules/plugin.ts +55 -3
  69. package/src/api/modules/post.ts +27 -1
  70. package/src/api/modules/progressbar.ts +56 -3
  71. package/src/api/modules/responder.ts +184 -21
  72. package/src/api/modules/session.ts +27 -1
  73. package/src/api/modules/startscreen.ts +33 -7
  74. package/src/api/modules/stat.ts +79 -8
  75. package/src/api/modules/verifybar.ts +31 -5
  76. package/src/api/modules/worker.ts +22 -1
  77. package/src/utilities/index.ts +1 -0
@@ -9,6 +9,10 @@ export interface ODCheckerResult {
9
9
  valid: boolean;
10
10
  messages: ODCheckerMessage[];
11
11
  }
12
+ /**## ODCheckerManagerIdConstraint `type`
13
+ * The constraint/layout for id mappings/interfaces of the `ODCheckerManager` class.
14
+ */
15
+ export type ODCheckerManagerIdConstraint = Record<string, ODChecker>;
12
16
  /**## ODCheckerManager `class`
13
17
  * This is an Open Discord checker manager.
14
18
  *
@@ -16,22 +20,28 @@ export interface ODCheckerResult {
16
20
  *
17
21
  * You can use this class to get/add a config checker (`ODChecker`) in your plugin!
18
22
  */
19
- export declare class ODCheckerManager extends ODManager<ODChecker> {
23
+ export declare class ODCheckerManager<IdList extends ODCheckerManagerIdConstraint = ODCheckerManagerIdConstraint, FunctionIdList extends ODCheckerFunctionManagerIdConstraint = ODCheckerFunctionManagerIdConstraint, Renderer extends ODCheckerRenderer = ODCheckerRenderer, TranslationMessageIds extends string = string, TranslationOtherIds extends string = string> extends ODManager<ODChecker> {
20
24
  /**The global temporary storage shared between all config checkers. */
21
25
  storage: ODCheckerStorage;
22
26
  /**The class responsible for rendering the config checker report. */
23
- renderer: ODCheckerRenderer;
27
+ renderer: Renderer;
24
28
  /**The class responsible for translating the config checker report. */
25
- translation: ODCheckerTranslationRegister;
29
+ translation: ODCheckerTranslationRegister<TranslationMessageIds, TranslationOtherIds>;
26
30
  /**Final functions are global functions executed just before the report is created. */
27
- functions: ODCheckerFunctionManager;
31
+ functions: ODCheckerFunctionManager<FunctionIdList>;
28
32
  /**A variable containing the last result returned from `checkAll()` */
29
33
  lastResult: ODCheckerResult | null;
30
- constructor(debug: ODDebugger, storage: ODCheckerStorage, renderer: ODCheckerRenderer, translation: ODCheckerTranslationRegister, functions: ODCheckerFunctionManager);
34
+ constructor(debug: ODDebugger, storage: ODCheckerStorage, renderer: Renderer, translation: ODCheckerTranslationRegister<TranslationMessageIds, TranslationOtherIds>, functions: ODCheckerFunctionManager<FunctionIdList>);
31
35
  /**Check all config checkers registered in this manager.*/
32
36
  checkAll(sort: boolean): ODCheckerResult;
33
37
  /**Create temporary and unlisted `ODConfig`, `ODChecker` & `ODCheckerStorage` classes. This will help you use a `ODCheckerStructure` validator without officially registering it in `opendiscord.checkers`. */
34
38
  createTemporaryCheckerEnvironment(): ODChecker;
39
+ get<CheckerId extends keyof IdList>(id: CheckerId): IdList[CheckerId];
40
+ get(id: ODValidId): ODChecker | null;
41
+ remove<CheckerId extends keyof IdList>(id: CheckerId): IdList[CheckerId];
42
+ remove(id: ODValidId): ODChecker | null;
43
+ exists(id: keyof IdList): boolean;
44
+ exists(id: ODValidId): boolean;
35
45
  }
36
46
  /**## ODCheckerStorage `class`
37
47
  * This is an Open Discord checker storage.
@@ -62,16 +72,85 @@ export declare class ODCheckerStorage {
62
72
  * This is an Open Discord checker renderer.
63
73
  *
64
74
  * It's responsible for rendering the config checker result in the console.
65
- * This class doesn't provide any components! You need to create them by extending this class
75
+ * This class doesn't provide any components! Create new ones by extending this class.
66
76
  *
67
- * You can use this class if you want to change how the config checker looks!
77
+ * Use this class to change the config checker looks!
68
78
  */
69
79
  export declare class ODCheckerRenderer {
70
- /**Get all components */
71
- getComponents(compact: boolean, renderEmpty: boolean, translation: ODCheckerTranslationRegister, data: ODCheckerResult): string[];
72
- /**Render all components */
80
+ /**Get all config checker render components. These can be combined and rendered to the console. */
81
+ getComponents(compact: boolean, renderEmpty: boolean, translation: ODCheckerTranslationRegister<string, string>, data: ODCheckerResult): string[];
82
+ /**Render all config checker render components to the console. */
73
83
  render(components: string[]): void;
74
84
  }
85
+ /**## ODDefaultCheckerRendererTranslations `interface`
86
+ * The required translation sentences for the default checker renderer.
87
+ */
88
+ export interface ODDefaultCheckerRendererTranslations {
89
+ /**Example: `OPEN DISCORD`*/
90
+ headerProjectName: string;
91
+ /**Example: `CONFIG CHECKER`*/
92
+ headerConfigchecker: string;
93
+ /**Example: `check for errors in your config files!`*/
94
+ headerDescription: string;
95
+ /**Example: `the bot won't start until all {0}'s are fixed!`*/
96
+ footerError: string;
97
+ /**Example: `it's recommended to fix all {0}'s before starting!`*/
98
+ footerWarning: string;
99
+ /**Example: `SUPPORT: {0} - DOCS: {1}`*/
100
+ footerSupport: string;
101
+ /**Example: `[ERROR]`*/
102
+ error: string;
103
+ /**Example: `[WARNING]`*/
104
+ warning: string;
105
+ /**Example: `[INFO]`*/
106
+ info: string;
107
+ /**Example: `use {0} for more information!`*/
108
+ compactInfo: string;
109
+ /**Example: `path`*/
110
+ dataPath: string;
111
+ /**Example: `docs`*/
112
+ dataDocs: string;
113
+ /**Example: `message`*/
114
+ dataMessage: string;
115
+ }
116
+ /**## ODDefaultCheckerRenderer `class`
117
+ * This is the default render class which renders the config checkers in the console for most Open Discord projects.
118
+ *
119
+ * This class can be found in the global variable `opendiscord.checkers.renderer`!
120
+ */
121
+ export declare class ODDefaultCheckerRenderer extends ODCheckerRenderer {
122
+ #private;
123
+ /**The main color used when rendering the config checker. */
124
+ mainColor: `#${string}`;
125
+ /**The url to the discord support server. */
126
+ supportUrl: string;
127
+ /**The url to the bot documentation. */
128
+ docsUrl: string;
129
+ /**Add additional header text. */
130
+ extraHeaderText: string[];
131
+ /**Add additional footer text. */
132
+ extraFooterText: string[];
133
+ /**Add additional top text. */
134
+ extraTopText: string[];
135
+ /**Add additional bottom text. */
136
+ extraBottomText: string[];
137
+ /**Set the character used for horizontal lines. */
138
+ horizontalFiller: string;
139
+ /**Set the character used for vertical lines. */
140
+ verticalFiller: string;
141
+ /**Set the prefix used for the description. */
142
+ descriptionSeparator: string;
143
+ /**Set the prefix used for the header.. */
144
+ headerSeparator: string;
145
+ /**Set the prefix used for the footer. */
146
+ footerTipPrefix: string;
147
+ /**Disable rendering the header. */
148
+ disableHeader: boolean;
149
+ /**Disable rendering the footer. */
150
+ disableFooter: boolean;
151
+ constructor(mainColor: `#${string}`, supportUrl: string, docsUrl: string);
152
+ getComponents(compact: boolean, renderEmpty: boolean, translation: ODCheckerTranslationRegister<string, string>, data: ODCheckerResult): string[];
153
+ }
75
154
  /**## ODCheckerTranslationRegister `class`
76
155
  * This is an Open Discord checker translation register.
77
156
  *
@@ -80,13 +159,19 @@ export declare class ODCheckerRenderer {
80
159
  *
81
160
  * You can use this class if you want to translate your config checker messages! **This is optional & isn't required for the checker to work!**
82
161
  */
83
- export declare class ODCheckerTranslationRegister {
162
+ export declare class ODCheckerTranslationRegister<MessageIds extends string = string, OtherIds extends string = string> {
84
163
  #private;
85
164
  /**Get the translation from a config checker message/sentence */
165
+ get(type: "other", id: OtherIds): string;
166
+ get(type: "message", id: MessageIds): string;
86
167
  get(type: "message" | "other", id: string): string | null;
87
168
  /**Set the translation for a config checker message/sentence. This function also overwrites existing translations!*/
169
+ set(type: "other", id: OtherIds, translation: string): boolean;
170
+ set(type: "message", id: MessageIds, translation: string): boolean;
88
171
  set(type: "message" | "other", id: string, translation: string): boolean;
89
172
  /**Delete the translation for a config checker message/sentence. */
173
+ delete(type: "other", id: OtherIds): boolean;
174
+ delete(type: "message", id: MessageIds): boolean;
90
175
  delete(type: "message" | "other", id: string): boolean;
91
176
  /**Get all translations */
92
177
  getAll(): {
@@ -97,12 +182,13 @@ export declare class ODCheckerTranslationRegister {
97
182
  /**Insert the translation params into the text. */
98
183
  insertTranslationParams(text: string, translationParams: string[]): string;
99
184
  /**A shortcut to copy translations from the `ODLanguageManager` to `ODCheckerTranslationRegister` */
185
+ quickTranslate(manager: ODLanguageManager, translationId: string, type: "other" | "message", id: OtherIds | MessageIds): void;
100
186
  quickTranslate(manager: ODLanguageManager, translationId: string, type: "other" | "message", id: string): void;
101
187
  }
102
188
  /**## ODCheckerFunctionCallback `type`
103
189
  * This is the function used in the `ODCheckerFunction` class.
104
190
  */
105
- export type ODCheckerFunctionCallback = (manager: ODCheckerManager, functions: ODCheckerFunctionManager) => ODCheckerResult;
191
+ export type ODCheckerFunctionCallback = (manager: ODCheckerManager<ODCheckerManagerIdConstraint, ODCheckerFunctionManagerIdConstraint, ODCheckerRenderer, string, string>, functions: ODCheckerFunctionManager<ODCheckerFunctionManagerIdConstraint>) => ODCheckerResult;
106
192
  /**## ODCheckerFunction `class`
107
193
  * This is an Open Discord config checker function.
108
194
  *
@@ -114,12 +200,16 @@ export declare class ODCheckerFunction extends ODManagerData {
114
200
  func: ODCheckerFunctionCallback;
115
201
  constructor(id: ODValidId, func: ODCheckerFunctionCallback);
116
202
  }
203
+ /**## ODCheckerFunctionManagerIdConstraint `type`
204
+ * The constraint/layout for id mappings/interfaces of the `ODCheckerFunctionManager` class.
205
+ */
206
+ export type ODCheckerFunctionManagerIdConstraint = Record<string, ODCheckerFunction>;
117
207
  /**## ODCheckerFunctionManager `class`
118
208
  * This is an Open Discord config checker function manager.
119
209
  *
120
210
  * It manages all `ODCheckerFunction`'s and it has some extra shortcuts for frequently used methods.
121
211
  */
122
- export declare class ODCheckerFunctionManager extends ODManager<ODCheckerFunction> {
212
+ export declare class ODCheckerFunctionManager<IdList extends ODCheckerFunctionManagerIdConstraint = ODCheckerFunctionManagerIdConstraint> extends ODManager<ODCheckerFunction> {
123
213
  constructor(debug: ODDebugger);
124
214
  /**A shortcut to create a warning, info or error message */
125
215
  createMessage(checkerId: ODValidId, id: ODValidId, filepath: string, type: "info" | "warning" | "error", message: string, locationTrace: ODCheckerLocationTrace, docs: string | null, translationParams: string[], locationId: ODId, locationDocs: string | null): ODCheckerMessage;
@@ -127,6 +217,12 @@ export declare class ODCheckerFunctionManager extends ODManager<ODCheckerFunctio
127
217
  locationTraceToString(trace: ODCheckerLocationTrace): string;
128
218
  /**De-reference the locationTrace array. Use this before adding a value to the array*/
129
219
  locationTraceDeref(trace: ODCheckerLocationTrace): ODCheckerLocationTrace;
220
+ get<CheckerFunctionId extends keyof IdList>(id: CheckerFunctionId): IdList[CheckerFunctionId];
221
+ get(id: ODValidId): ODCheckerFunction | null;
222
+ remove<CheckerFunctionId extends keyof IdList>(id: CheckerFunctionId): IdList[CheckerFunctionId];
223
+ remove(id: ODValidId): ODCheckerFunction | null;
224
+ exists(id: keyof IdList): boolean;
225
+ exists(id: ODValidId): boolean;
130
226
  }
131
227
  /**## ODCheckerLocationTrace `type`
132
228
  * This type is an array of strings & numbers which represents the location trace from the config checker.
@@ -157,7 +253,7 @@ export declare class ODChecker extends ODManagerData {
157
253
  /**The higher the priority, the faster it gets checked! */
158
254
  priority: number;
159
255
  /**The config file that needs to be checked */
160
- config: ODConfig;
256
+ config: ODConfig<any>;
161
257
  /**The structure of the config file */
162
258
  structure: ODCheckerStructure;
163
259
  /**Temporary storage for all error messages from the check() method (not recommended to use) */
@@ -166,7 +262,7 @@ export declare class ODChecker extends ODManagerData {
166
262
  quit: boolean;
167
263
  /**All additional properties of this config checker. */
168
264
  options: ODCheckerOptions;
169
- constructor(id: ODValidId, storage: ODCheckerStorage, priority: number, config: ODConfig, structure: ODCheckerStructure, options?: ODCheckerOptions);
265
+ constructor(id: ODValidId, storage: ODCheckerStorage, priority: number, config: ODConfig<any>, structure: ODCheckerStructure, options?: ODCheckerOptions);
170
266
  /**Run this checker. Returns all errors*/
171
267
  check(): ODCheckerResult;
172
268
  /**Create a string from the location trace/path in a human readable format. */
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ODCheckerCustomStructure_UniqueIdArray = exports.ODCheckerCustomStructure_UniqueId = exports.ODCheckerCustomStructure_UrlString = exports.ODCheckerCustomStructure_EmojiString = exports.ODCheckerCustomStructure_HexColor = exports.ODCheckerCustomStructure_DiscordToken = exports.ODCheckerCustomStructure_DiscordIdArray = exports.ODCheckerCustomStructure_DiscordId = exports.ODCheckerEnabledObjectStructure = exports.ODCheckerObjectSwitchStructure = exports.ODCheckerTypeSwitchStructure = exports.ODCheckerNullStructure = exports.ODCheckerArrayStructure = exports.ODCheckerBooleanStructure = exports.ODCheckerNumberStructure = exports.ODCheckerStringStructure = exports.ODCheckerObjectStructure = exports.ODCheckerStructure = exports.ODChecker = exports.ODCheckerFunctionManager = exports.ODCheckerFunction = exports.ODCheckerTranslationRegister = exports.ODCheckerRenderer = exports.ODCheckerStorage = exports.ODCheckerManager = void 0;
6
+ exports.ODCheckerCustomStructure_UniqueIdArray = exports.ODCheckerCustomStructure_UniqueId = exports.ODCheckerCustomStructure_UrlString = exports.ODCheckerCustomStructure_EmojiString = exports.ODCheckerCustomStructure_HexColor = exports.ODCheckerCustomStructure_DiscordToken = exports.ODCheckerCustomStructure_DiscordIdArray = exports.ODCheckerCustomStructure_DiscordId = exports.ODCheckerEnabledObjectStructure = exports.ODCheckerObjectSwitchStructure = exports.ODCheckerTypeSwitchStructure = exports.ODCheckerNullStructure = exports.ODCheckerArrayStructure = exports.ODCheckerBooleanStructure = exports.ODCheckerNumberStructure = exports.ODCheckerStringStructure = exports.ODCheckerObjectStructure = exports.ODCheckerStructure = exports.ODChecker = exports.ODCheckerFunctionManager = exports.ODCheckerFunction = exports.ODCheckerTranslationRegister = exports.ODDefaultCheckerRenderer = exports.ODCheckerRenderer = exports.ODCheckerStorage = exports.ODCheckerManager = void 0;
4
7
  ///////////////////////////////////////
5
8
  //CONFIG CHECKER MODULE
6
9
  ///////////////////////////////////////
7
10
  const base_1 = require("./base");
8
11
  const config_1 = require("./config");
12
+ const ansis_1 = __importDefault(require("ansis"));
9
13
  /**## ODCheckerManager `class`
10
14
  * This is an Open Discord checker manager.
11
15
  *
@@ -70,6 +74,15 @@ class ODCheckerManager extends base_1.ODManager {
70
74
  createTemporaryCheckerEnvironment() {
71
75
  return new ODChecker("opendiscord:temporary-environment", new ODCheckerStorage(), 0, new config_1.ODConfig("opendiscord:temporary-environment", {}), new ODCheckerStructure("opendiscord:temporary-environment", {}));
72
76
  }
77
+ get(id) {
78
+ return super.get(id);
79
+ }
80
+ remove(id) {
81
+ return super.remove(id);
82
+ }
83
+ exists(id) {
84
+ return super.exists(id);
85
+ }
73
86
  }
74
87
  exports.ODCheckerManager = ODCheckerManager;
75
88
  /**## ODCheckerStorage `class`
@@ -129,16 +142,16 @@ exports.ODCheckerStorage = ODCheckerStorage;
129
142
  * This is an Open Discord checker renderer.
130
143
  *
131
144
  * It's responsible for rendering the config checker result in the console.
132
- * This class doesn't provide any components! You need to create them by extending this class
145
+ * This class doesn't provide any components! Create new ones by extending this class.
133
146
  *
134
- * You can use this class if you want to change how the config checker looks!
147
+ * Use this class to change the config checker looks!
135
148
  */
136
149
  class ODCheckerRenderer {
137
- /**Get all components */
150
+ /**Get all config checker render components. These can be combined and rendered to the console. */
138
151
  getComponents(compact, renderEmpty, translation, data) {
139
152
  return [];
140
153
  }
141
- /**Render all components */
154
+ /**Render all config checker render components to the console. */
142
155
  render(components) {
143
156
  if (components.length < 1)
144
157
  return;
@@ -150,6 +163,180 @@ class ODCheckerRenderer {
150
163
  }
151
164
  }
152
165
  exports.ODCheckerRenderer = ODCheckerRenderer;
166
+ /**## ODDefaultCheckerRenderer `class`
167
+ * This is the default render class which renders the config checkers in the console for most Open Discord projects.
168
+ *
169
+ * This class can be found in the global variable `opendiscord.checkers.renderer`!
170
+ */
171
+ class ODDefaultCheckerRenderer extends ODCheckerRenderer {
172
+ /**The main color used when rendering the config checker. */
173
+ mainColor;
174
+ /**The url to the discord support server. */
175
+ supportUrl;
176
+ /**The url to the bot documentation. */
177
+ docsUrl;
178
+ /**Add additional header text. */
179
+ extraHeaderText = [];
180
+ /**Add additional footer text. */
181
+ extraFooterText = [];
182
+ /**Add additional top text. */
183
+ extraTopText = [];
184
+ /**Add additional bottom text. */
185
+ extraBottomText = [];
186
+ /**Set the character used for horizontal lines. */
187
+ horizontalFiller = "=";
188
+ /**Set the character used for vertical lines. */
189
+ verticalFiller = "|";
190
+ /**Set the prefix used for the description. */
191
+ descriptionSeparator = " => ";
192
+ /**Set the prefix used for the header.. */
193
+ headerSeparator = " => ";
194
+ /**Set the prefix used for the footer. */
195
+ footerTipPrefix = "=> ";
196
+ /**Disable rendering the header. */
197
+ disableHeader = false;
198
+ /**Disable rendering the footer. */
199
+ disableFooter = false;
200
+ constructor(mainColor, supportUrl, docsUrl) {
201
+ super();
202
+ this.mainColor = mainColor;
203
+ this.supportUrl = supportUrl;
204
+ this.docsUrl = docsUrl;
205
+ }
206
+ getComponents(compact, renderEmpty, translation, data) {
207
+ const tm = translation;
208
+ const t = {
209
+ headerProjectName: tm.get("other", "opendiscord:header-projectname") ?? "OPEN DISCORD",
210
+ headerConfigchecker: tm.get("other", "opendiscord:header-configchecker") ?? "CONFIG CHECKER",
211
+ headerDescription: tm.get("other", "opendiscord:header-description") ?? "check for errors in your config files!",
212
+ footerError: tm.get("other", "opendiscord:footer-error") ?? "the bot won't start until all {0}'s are fixed!",
213
+ footerWarning: tm.get("other", "opendiscord:footer-warning") ?? "it's recommended to fix all {0}'s before starting!",
214
+ footerSupport: tm.get("other", "opendiscord:footer-support") ?? "SUPPORT: {0} - DOCS: {1}",
215
+ error: tm.get("other", "opendiscord:type-error") ?? "[ERROR]",
216
+ warning: tm.get("other", "opendiscord:type-warning") ?? "[WARNING]",
217
+ info: tm.get("other", "opendiscord:type-info") ?? "[INFO]",
218
+ compactInfo: tm.get("other", "opendiscord:compact-information") ?? "use {0} for more information!",
219
+ dataPath: tm.get("other", "opendiscord:data-path") ?? "path",
220
+ dataDocs: tm.get("other", "opendiscord:data-docs") ?? "docs",
221
+ dataMessage: tm.get("other", "opendiscord:data-message") ?? "message"
222
+ };
223
+ const hasErrors = data.messages.filter((m) => m.type == "error").length > 0;
224
+ const hasWarnings = data.messages.filter((m) => m.type == "warning").length > 0;
225
+ const hasInfo = data.messages.filter((m) => m.type == "info").length > 0;
226
+ if (!renderEmpty && !hasErrors && !hasWarnings && (!hasInfo || compact))
227
+ return [];
228
+ const headerText = ansis_1.default.bold.hex(this.mainColor)(t.headerProjectName) + " " + t.headerConfigchecker + this.headerSeparator + ansis_1.default.hex(this.mainColor)(t.headerDescription);
229
+ const footerErrorText = (hasErrors) ? this.footerTipPrefix + ansis_1.default.gray(tm.insertTranslationParams(t.footerError, [ansis_1.default.bold.red(t.error)])) : "";
230
+ const footerWarningText = (hasWarnings) ? this.footerTipPrefix + ansis_1.default.gray(tm.insertTranslationParams(t.footerWarning, [ansis_1.default.bold.yellow(t.warning)])) : "";
231
+ const footerSupportText = tm.insertTranslationParams(t.footerSupport, [ansis_1.default.green(this.supportUrl), ansis_1.default.green(this.docsUrl)]);
232
+ const bottomCompactInfo = (compact) ? ansis_1.default.gray(tm.insertTranslationParams(t.compactInfo, [ansis_1.default.bold.green("npm start -- --checker")])) : "";
233
+ const finalHeader = [headerText, ...this.extraHeaderText];
234
+ const finalFooter = [footerErrorText, footerWarningText, footerSupportText, ...this.extraFooterText];
235
+ const finalTop = [...this.extraTopText];
236
+ const finalBottom = [bottomCompactInfo, ...this.extraBottomText];
237
+ const borderLength = this.#getLongestLength([...finalHeader, ...finalFooter]);
238
+ const finalComponents = [];
239
+ //header
240
+ if (!this.disableHeader) {
241
+ finalHeader.forEach((text) => {
242
+ if (text.length < 1)
243
+ return;
244
+ finalComponents.push(this.#createBlockFromText(text, borderLength));
245
+ });
246
+ }
247
+ finalComponents.push(this.#getHorizontalDivider(borderLength + 4));
248
+ //top
249
+ finalTop.forEach((text) => {
250
+ if (text.length < 1)
251
+ return;
252
+ finalComponents.push(this.verticalFiller + " " + text);
253
+ });
254
+ finalComponents.push(this.verticalFiller);
255
+ //messages
256
+ if (compact) {
257
+ //use compact messages
258
+ data.messages.forEach((msg, index) => {
259
+ //compact mode doesn't render info
260
+ if (msg.type == "info")
261
+ return;
262
+ //check if translation available & use it if possible
263
+ const rawTranslation = tm.get("message", msg.messageId.value);
264
+ const translatedMessage = (rawTranslation) ? tm.insertTranslationParams(rawTranslation, msg.translationParams) : msg.message;
265
+ if (msg.type == "error")
266
+ finalComponents.push(this.verticalFiller + " " + ansis_1.default.bold.red(`${t.error} ${translatedMessage}`));
267
+ else if (msg.type == "warning")
268
+ finalComponents.push(this.verticalFiller + " " + ansis_1.default.bold.yellow(`${t.warning} ${translatedMessage}`));
269
+ const pathSplitter = msg.path ? ":" : "";
270
+ finalComponents.push(this.verticalFiller + ansis_1.default.bold(this.descriptionSeparator) + ansis_1.default.cyan(`${ansis_1.default.magenta(msg.filepath + pathSplitter)} ${msg.path}`));
271
+ if (index != data.messages.length - 1)
272
+ finalComponents.push(this.verticalFiller);
273
+ });
274
+ }
275
+ else {
276
+ //use full messages
277
+ data.messages.forEach((msg, index) => {
278
+ //check if translation available & use it if possible
279
+ const rawTranslation = tm.get("message", msg.messageId.value);
280
+ const translatedMessage = (rawTranslation) ? tm.insertTranslationParams(rawTranslation, msg.translationParams) : msg.message;
281
+ if (msg.type == "error")
282
+ finalComponents.push(this.verticalFiller + " " + ansis_1.default.bold.red(`${t.error} ${translatedMessage}`));
283
+ else if (msg.type == "warning")
284
+ finalComponents.push(this.verticalFiller + " " + ansis_1.default.bold.yellow(`${t.warning} ${translatedMessage}`));
285
+ else if (msg.type == "info")
286
+ finalComponents.push(this.verticalFiller + " " + ansis_1.default.bold.blue(`${t.info} ${translatedMessage}`));
287
+ const pathSplitter = msg.path ? ":" : "";
288
+ finalComponents.push(this.verticalFiller + " " + ansis_1.default.bold((t.dataPath) + this.descriptionSeparator) + ansis_1.default.cyan(`${ansis_1.default.magenta(msg.filepath + pathSplitter)} ${msg.path}`));
289
+ if (msg.locationDocs)
290
+ finalComponents.push(this.verticalFiller + " " + ansis_1.default.bold(t.dataDocs + this.descriptionSeparator) + ansis_1.default.italic.gray(msg.locationDocs));
291
+ if (msg.messageDocs)
292
+ finalComponents.push(this.verticalFiller + " " + ansis_1.default.bold(t.dataMessage + this.descriptionSeparator) + ansis_1.default.italic.gray(msg.messageDocs));
293
+ if (index != data.messages.length - 1)
294
+ finalComponents.push(this.verticalFiller);
295
+ });
296
+ }
297
+ //bottom
298
+ finalComponents.push(this.verticalFiller);
299
+ finalBottom.forEach((text) => {
300
+ if (text.length < 1)
301
+ return;
302
+ finalComponents.push(this.verticalFiller + " " + text);
303
+ });
304
+ //footer
305
+ finalComponents.push(this.#getHorizontalDivider(borderLength + 4));
306
+ if (!this.disableFooter) {
307
+ finalFooter.forEach((text) => {
308
+ if (text.length < 1)
309
+ return;
310
+ finalComponents.push(this.#createBlockFromText(text, borderLength));
311
+ });
312
+ finalComponents.push(this.#getHorizontalDivider(borderLength + 4));
313
+ }
314
+ //return all components
315
+ return finalComponents;
316
+ }
317
+ /**Get the length of the longest string in the array. */
318
+ #getLongestLength(texts) {
319
+ return Math.max(...texts.map((t) => ansis_1.default.strip(t).length));
320
+ }
321
+ /**Get a horizontal divider used between different parts of the config checker result. */
322
+ #getHorizontalDivider(width) {
323
+ if (width > 2)
324
+ width = width - 2;
325
+ else
326
+ return this.verticalFiller + this.verticalFiller;
327
+ let divider = this.verticalFiller + this.horizontalFiller.repeat(width) + this.verticalFiller;
328
+ return divider;
329
+ }
330
+ /**Create a block of text with a vertical divider on the left & right side. */
331
+ #createBlockFromText(text, width) {
332
+ if (width < 3)
333
+ return this.verticalFiller + this.verticalFiller;
334
+ let newWidth = width - ansis_1.default.strip(text).length + 1;
335
+ let final = this.verticalFiller + " " + text + " ".repeat(newWidth) + this.verticalFiller;
336
+ return final;
337
+ }
338
+ }
339
+ exports.ODDefaultCheckerRenderer = ODDefaultCheckerRenderer;
153
340
  /**## ODCheckerTranslationRegister `class`
154
341
  * This is an Open Discord checker translation register.
155
342
  *
@@ -161,12 +348,10 @@ exports.ODCheckerRenderer = ODCheckerRenderer;
161
348
  class ODCheckerTranslationRegister {
162
349
  /**This is the array that stores all the data. ❌ **(don't edit unless really needed!)***/
163
350
  #translations = [];
164
- /**Get the translation from a config checker message/sentence */
165
351
  get(type, id) {
166
352
  const result = this.#translations.find(d => (d.id == id) && (d.type == type));
167
353
  return (result) ? result.translation : null;
168
354
  }
169
- /**Set the translation for a config checker message/sentence. This function also overwrites existing translations!*/
170
355
  set(type, id, translation) {
171
356
  const index = this.#translations.findIndex(d => (d.id == id) && (d.type == type));
172
357
  if (index > -1) {
@@ -179,7 +364,6 @@ class ODCheckerTranslationRegister {
179
364
  return false;
180
365
  }
181
366
  }
182
- /**Delete the translation for a config checker message/sentence. */
183
367
  delete(type, id) {
184
368
  const index = this.#translations.findIndex(d => (d.id == id) && (d.type == type));
185
369
  if (index > -1) {
@@ -201,7 +385,6 @@ class ODCheckerTranslationRegister {
201
385
  });
202
386
  return text;
203
387
  }
204
- /**A shortcut to copy translations from the `ODLanguageManager` to `ODCheckerTranslationRegister` */
205
388
  quickTranslate(manager, translationId, type, id) {
206
389
  const translation = manager.getTranslation(translationId);
207
390
  if (translation)
@@ -264,6 +447,15 @@ class ODCheckerFunctionManager extends base_1.ODManager {
264
447
  locationTraceDeref(trace) {
265
448
  return JSON.parse(JSON.stringify(trace));
266
449
  }
450
+ get(id) {
451
+ return super.get(id);
452
+ }
453
+ remove(id) {
454
+ return super.remove(id);
455
+ }
456
+ exists(id) {
457
+ return super.exists(id);
458
+ }
267
459
  }
268
460
  exports.ODCheckerFunctionManager = ODCheckerFunctionManager;
269
461
  /**## ODChecker `class`