@open-discord-bots/framework 0.0.8 → 0.1.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.
@@ -1,5 +1,5 @@
1
- import { api } from "../index";
2
- import { ODCliHeaderOpts } from "./cli";
1
+ import * as api from "../api/index";
2
+ import { ODCliHeaderOpts } from ".";
3
3
  export declare class ODCliEditConfigInstance {
4
4
  private readonly opts;
5
5
  private readonly opendiscord;
@@ -1,13 +1,47 @@
1
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
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.ODCliEditConfigInstance = void 0;
7
- const index_1 = require("../index");
40
+ const api = __importStar(require("../api/index"));
41
+ const utilities = __importStar(require("../utilities/index"));
8
42
  const terminal_kit_1 = require("terminal-kit");
9
43
  const ansis_1 = __importDefault(require("ansis"));
10
- const cli_1 = require("./cli");
44
+ const _1 = require(".");
11
45
  class ODCliEditConfigInstance {
12
46
  opts;
13
47
  opendiscord;
@@ -16,11 +50,11 @@ class ODCliEditConfigInstance {
16
50
  this.opendiscord = opendiscord;
17
51
  }
18
52
  async renderEditConfig(backFn) {
19
- (0, cli_1.renderHeader)(this.opts, []);
53
+ (0, _1.renderHeader)(this.opts, []);
20
54
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select which config you would like to edit.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
21
55
  const checkerList = this.opendiscord.checkers.getAll();
22
56
  const checkerNameList = checkerList.map((checker) => (checker.options.cliDisplayName ? checker.options.cliDisplayName + " (" + checker.config.file + ")" : checker.config.file));
23
- const checkerNameLength = index_1.utilities.getLongestLength(checkerNameList);
57
+ const checkerNameLength = utilities.getLongestLength(checkerNameList);
24
58
  const finalCheckerNameList = checkerNameList.map((name, index) => name.padEnd(checkerNameLength + 5, " ") + ansis_1.default.gray(checkerList[index].options.cliDisplayDescription ? "=> " + checkerList[index].options.cliDisplayDescription : ""));
25
59
  const answer = await terminal_kit_1.terminal.singleColumnMenu(finalCheckerNameList, {
26
60
  leftPadding: "> ",
@@ -37,31 +71,31 @@ class ODCliEditConfigInstance {
37
71
  await this.chooseConfigStructure(checker, async () => { await this.renderEditConfig(backFn); }, checker.structure, configData, {}, NaN, ["(" + checker.config.path + ")"]);
38
72
  }
39
73
  async chooseConfigStructure(checker, backFn, structure, data, parent, parentIndex, path) {
40
- if (structure instanceof index_1.api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data)
74
+ if (structure instanceof api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data)
41
75
  await this.renderConfigObjectStructureSelector(checker, backFn, structure, data, parent, parentIndex, path);
42
- else if (structure instanceof index_1.api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data)
76
+ else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data)
43
77
  await this.renderConfigEnabledObjectStructureSelector(checker, backFn, structure, data, parent, parentIndex, path);
44
- else if (structure instanceof index_1.api.ODCheckerObjectSwitchStructure && typeof data == "object" && !Array.isArray(data) && data)
78
+ else if (structure instanceof api.ODCheckerObjectSwitchStructure && typeof data == "object" && !Array.isArray(data) && data)
45
79
  await this.renderConfigObjectSwitchStructureSelector(checker, backFn, structure, data, parent, parentIndex, path);
46
- else if (structure instanceof index_1.api.ODCheckerArrayStructure && Array.isArray(data))
80
+ else if (structure instanceof api.ODCheckerArrayStructure && Array.isArray(data))
47
81
  await this.renderConfigArrayStructureSelector(checker, backFn, structure, data, parent, parentIndex, path);
48
- else if (structure instanceof index_1.api.ODCheckerBooleanStructure && typeof data == "boolean")
82
+ else if (structure instanceof api.ODCheckerBooleanStructure && typeof data == "boolean")
49
83
  await this.renderConfigBooleanStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
50
- else if (structure instanceof index_1.api.ODCheckerNumberStructure && typeof data == "number")
84
+ else if (structure instanceof api.ODCheckerNumberStructure && typeof data == "number")
51
85
  await this.renderConfigNumberStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
52
- else if (structure instanceof index_1.api.ODCheckerStringStructure && typeof data == "string")
86
+ else if (structure instanceof api.ODCheckerStringStructure && typeof data == "string")
53
87
  await this.renderConfigStringStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
54
- else if (structure instanceof index_1.api.ODCheckerNullStructure && data === null)
88
+ else if (structure instanceof api.ODCheckerNullStructure && data === null)
55
89
  await this.renderConfigNullStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
56
- else if (structure instanceof index_1.api.ODCheckerTypeSwitchStructure)
90
+ else if (structure instanceof api.ODCheckerTypeSwitchStructure)
57
91
  await this.renderConfigTypeSwitchStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
58
92
  else
59
93
  terminal_kit_1.terminal.red.bold("❌ Unable to detect type of variable! Please try to edit this property in the JSON file itself!");
60
94
  }
61
95
  async renderConfigObjectStructureSelector(checker, backFn, structure, data, parent, parentIndex, path) {
62
96
  if (typeof data != "object" || Array.isArray(data))
63
- throw new index_1.api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
64
- (0, cli_1.renderHeader)(this.opts, path);
97
+ throw new api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
98
+ (0, _1.renderHeader)(this.opts, path);
65
99
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select which variable you would like to edit.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
66
100
  if (!structure.options.children)
67
101
  return await backFn();
@@ -71,7 +105,7 @@ class ODCliEditConfigInstance {
71
105
  }
72
106
  const list = structure.options.children.filter((child) => !child.cliHideInEditMode);
73
107
  const nameList = list.map((child) => (child.checker.options.cliDisplayName ? child.checker.options.cliDisplayName : child.key));
74
- const nameLength = index_1.utilities.getLongestLength(nameList);
108
+ const nameLength = utilities.getLongestLength(nameList);
75
109
  const finalnameList = nameList.map((name, index) => name.padEnd(nameLength + 5, " ") + ansis_1.default.gray((!list[index].checker.options.cliHideDescriptionInParent && list[index].checker.options.cliDisplayDescription) ? "=> " + list[index].checker.options.cliDisplayDescription : ""));
76
110
  const answer = await terminal_kit_1.terminal.singleColumnMenu(finalnameList, {
77
111
  leftPadding: "> ",
@@ -89,24 +123,24 @@ class ODCliEditConfigInstance {
89
123
  }
90
124
  async renderConfigEnabledObjectStructureSelector(checker, backFn, structure, data, parent, parentIndex, path) {
91
125
  if (typeof data != "object" || Array.isArray(data))
92
- throw new index_1.api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
126
+ throw new api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
93
127
  const enabledProperty = structure.options.property;
94
128
  const subStructure = structure.options.checker;
95
129
  if (!enabledProperty || !subStructure || !subStructure.options.children)
96
130
  return await backFn();
97
131
  if (!subStructure.options.children.find((child) => child.key === structure.options.property)) {
98
132
  if (typeof structure.options.enabledValue == "string")
99
- subStructure.options.children.unshift({ key: enabledProperty, optional: false, priority: 1, checker: new index_1.api.ODCheckerStringStructure("opendiscord:CLI-checker-enabled-object-structure", {}) });
133
+ subStructure.options.children.unshift({ key: enabledProperty, optional: false, priority: 1, checker: new api.ODCheckerStringStructure("opendiscord:CLI-checker-enabled-object-structure", {}) });
100
134
  else if (typeof structure.options.enabledValue == "number")
101
- subStructure.options.children.unshift({ key: enabledProperty, optional: false, priority: 1, checker: new index_1.api.ODCheckerNumberStructure("opendiscord:CLI-checker-enabled-object-structure", {}) });
135
+ subStructure.options.children.unshift({ key: enabledProperty, optional: false, priority: 1, checker: new api.ODCheckerNumberStructure("opendiscord:CLI-checker-enabled-object-structure", {}) });
102
136
  else if (typeof structure.options.enabledValue == "boolean")
103
- subStructure.options.children.unshift({ key: enabledProperty, optional: false, priority: 1, checker: new index_1.api.ODCheckerBooleanStructure("opendiscord:CLI-checker-enabled-object-structure", {}) });
137
+ subStructure.options.children.unshift({ key: enabledProperty, optional: false, priority: 1, checker: new api.ODCheckerBooleanStructure("opendiscord:CLI-checker-enabled-object-structure", {}) });
104
138
  }
105
139
  await this.chooseConfigStructure(checker, backFn, subStructure, data, parent, parentIndex, path);
106
140
  }
107
141
  async renderConfigObjectSwitchStructureSelector(checker, backFn, structure, data, parent, parentIndex, path) {
108
142
  if (typeof data != "object" || Array.isArray(data))
109
- throw new index_1.api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
143
+ throw new api.ODSystemError("OD CLI => Property is not of the type 'object'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
110
144
  if (!structure.options.objects)
111
145
  return await backFn();
112
146
  let didMatch = false;
@@ -119,12 +153,12 @@ class ODCliEditConfigInstance {
119
153
  }
120
154
  }
121
155
  if (!didMatch)
122
- throw new index_1.api.ODSystemError("OD CLI => Unable to detect type of object in the object switch. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
156
+ throw new api.ODSystemError("OD CLI => Unable to detect type of object in the object switch. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
123
157
  }
124
158
  async renderConfigArrayStructureSelector(checker, backFn, structure, data, parent, parentIndex, path) {
125
159
  if (!Array.isArray(data))
126
- throw new index_1.api.ODSystemError("OD CLI => Property is not of the type 'array'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
127
- (0, cli_1.renderHeader)(this.opts, path);
160
+ throw new api.ODSystemError("OD CLI => Property is not of the type 'array'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
161
+ (0, _1.renderHeader)(this.opts, path);
128
162
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select what you would like to do.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
129
163
  if (!structure.options.propertyChecker)
130
164
  return await backFn();
@@ -167,7 +201,7 @@ class ODCliEditConfigInstance {
167
201
  }
168
202
  async renderConfigArrayStructureEditSelector(checker, backFn, arrayStructure, structure, data, parent, parentIndex, path) {
169
203
  const propertyName = arrayStructure.options.cliDisplayPropertyName ?? "index";
170
- (0, cli_1.renderHeader)(this.opts, path);
204
+ (0, _1.renderHeader)(this.opts, path);
171
205
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the " + propertyName + " you would like to edit.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
172
206
  const longestDataListName = Math.max(...data.map((d, i) => this.getArrayPreviewStructureNameLength(structure, d, data, i)));
173
207
  const dataList = data.map((d, i) => (i + 1) + ". " + this.getArrayPreviewFromStructure(structure, d, data, i, longestDataListName));
@@ -186,7 +220,7 @@ class ODCliEditConfigInstance {
186
220
  }
187
221
  async renderConfigArrayStructureMoveSelector(checker, backFn, arrayStructure, structure, data, parent, parentIndex, path) {
188
222
  const propertyName = arrayStructure.options.cliDisplayPropertyName ?? "index";
189
- (0, cli_1.renderHeader)(this.opts, path);
223
+ (0, _1.renderHeader)(this.opts, path);
190
224
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the " + propertyName + " you would like to move.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
191
225
  const longestDataListName = Math.max(...data.map((d, i) => this.getArrayPreviewStructureNameLength(structure, d, data, i)));
192
226
  const dataList = data.map((d, i) => (i + 1) + ". " + this.getArrayPreviewFromStructure(structure, d, data, i, longestDataListName));
@@ -200,7 +234,7 @@ class ODCliEditConfigInstance {
200
234
  }).promise;
201
235
  if (dataAnswer.canceled)
202
236
  return await backFn();
203
- (0, cli_1.renderHeader)(this.opts, [...path, dataAnswer.selectedIndex]);
237
+ (0, _1.renderHeader)(this.opts, [...path, dataAnswer.selectedIndex]);
204
238
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the position you would like to move to.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
205
239
  const moveAnswer = await terminal_kit_1.terminal.singleColumnMenu(data.map((d, i) => "Position " + (i + 1)), {
206
240
  leftPadding: "> ",
@@ -218,12 +252,12 @@ class ODCliEditConfigInstance {
218
252
  insertedData.forEach((d, i) => data[i] = d);
219
253
  await checker.config.save();
220
254
  terminal_kit_1.terminal.bold.blue("\n\n✅ Property moved succesfully!");
221
- await index_1.utilities.timer(400);
255
+ await utilities.timer(400);
222
256
  await backFn();
223
257
  }
224
258
  async renderConfigArrayStructureRemoveSelector(checker, backFn, arrayStructure, structure, data, parent, parentIndex, path) {
225
259
  const propertyName = arrayStructure.options.cliDisplayPropertyName ?? "index";
226
- (0, cli_1.renderHeader)(this.opts, path);
260
+ (0, _1.renderHeader)(this.opts, path);
227
261
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the " + propertyName + " you would like to delete.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
228
262
  const longestDataListName = Math.max(...data.map((d, i) => this.getArrayPreviewStructureNameLength(structure, d, data, i)));
229
263
  const dataList = data.map((d, i) => (i + 1) + ". " + this.getArrayPreviewFromStructure(structure, d, data, i, longestDataListName));
@@ -240,12 +274,12 @@ class ODCliEditConfigInstance {
240
274
  data.splice(dataAnswer.selectedIndex, 1);
241
275
  await checker.config.save();
242
276
  terminal_kit_1.terminal.bold.blue("\n\n✅ Property deleted succesfully!");
243
- await index_1.utilities.timer(400);
277
+ await utilities.timer(400);
244
278
  await backFn();
245
279
  }
246
280
  async renderConfigArrayStructureDuplicateSelector(checker, backFn, arrayStructure, structure, data, parent, parentIndex, path) {
247
281
  const propertyName = arrayStructure.options.cliDisplayPropertyName ?? "index";
248
- (0, cli_1.renderHeader)(this.opts, path);
282
+ (0, _1.renderHeader)(this.opts, path);
249
283
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select the " + propertyName + " you would like to duplicate.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
250
284
  const longestDataListName = Math.max(...data.map((d, i) => this.getArrayPreviewStructureNameLength(structure, d, data, i)));
251
285
  const dataList = data.map((d, i) => (i + 1) + ". " + this.getArrayPreviewFromStructure(structure, d, data, i, longestDataListName));
@@ -262,13 +296,13 @@ class ODCliEditConfigInstance {
262
296
  data.push(JSON.parse(JSON.stringify(data[dataAnswer.selectedIndex])));
263
297
  await checker.config.save();
264
298
  terminal_kit_1.terminal.bold.blue("\n\n✅ Property duplicated succesfully!");
265
- await index_1.utilities.timer(400);
299
+ await utilities.timer(400);
266
300
  await backFn();
267
301
  }
268
302
  async renderConfigBooleanStructureEditor(checker, backFn, structure, data, parent, parentIndex, path) {
269
303
  if (typeof data != "boolean")
270
- throw new index_1.api.ODSystemError("OD CLI => Property is not of the type 'boolean'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
271
- (0, cli_1.renderHeader)(this.opts, path);
304
+ throw new api.ODSystemError("OD CLI => Property is not of the type 'boolean'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
305
+ (0, _1.renderHeader)(this.opts, path);
272
306
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the boolean property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "boolean property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
273
307
  terminal_kit_1.terminal.gray("\nCurrent value: " + ansis_1.default.bold[data ? "green" : "red"](data.toString()) + "\n");
274
308
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
@@ -292,21 +326,21 @@ class ODCliEditConfigInstance {
292
326
  parent[parentIndex] = newValue;
293
327
  await checker.config.save();
294
328
  terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
295
- await index_1.utilities.timer(400);
329
+ await utilities.timer(400);
296
330
  await backFn();
297
331
  }
298
332
  else {
299
333
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
300
334
  terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
301
335
  terminal_kit_1.terminal.gray("\n" + messages);
302
- await index_1.utilities.timer(1000 + (2000 * checker.messages.length));
336
+ await utilities.timer(1000 + (2000 * checker.messages.length));
303
337
  await this.renderConfigBooleanStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
304
338
  }
305
339
  }
306
340
  async renderConfigNumberStructureEditor(checker, backFn, structure, data, parent, parentIndex, path, prefillValue) {
307
341
  if (typeof data != "number")
308
- throw new index_1.api.ODSystemError("OD CLI => Property is not of the type 'number'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
309
- (0, cli_1.renderHeader)(this.opts, path);
342
+ throw new api.ODSystemError("OD CLI => Property is not of the type 'number'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
343
+ (0, _1.renderHeader)(this.opts, path);
310
344
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the number property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "number property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(insert a new value and press enter, go back using escape)\n"));
311
345
  terminal_kit_1.terminal.gray("\nCurrent value: " + ansis_1.default.bold.blue(data.toString()) + "\n");
312
346
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
@@ -327,25 +361,25 @@ class ODCliEditConfigInstance {
327
361
  parent[parentIndex] = newValue;
328
362
  await checker.config.save();
329
363
  terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
330
- await index_1.utilities.timer(400);
364
+ await utilities.timer(400);
331
365
  await backFn();
332
366
  }
333
367
  else {
334
368
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
335
369
  terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
336
370
  terminal_kit_1.terminal.red("\n" + messages);
337
- await index_1.utilities.timer(1000 + (2000 * checker.messages.length));
371
+ await utilities.timer(1000 + (2000 * checker.messages.length));
338
372
  await this.renderConfigNumberStructureEditor(checker, backFn, structure, data, parent, parentIndex, path, answer);
339
373
  }
340
374
  }
341
375
  async renderConfigStringStructureEditor(checker, backFn, structure, data, parent, parentIndex, path, prefillValue) {
342
376
  if (typeof data != "string")
343
- throw new index_1.api.ODSystemError("OD CLI => Property is not of the type 'string'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
344
- (0, cli_1.renderHeader)(this.opts, path);
377
+ throw new api.ODSystemError("OD CLI => Property is not of the type 'string'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
378
+ (0, _1.renderHeader)(this.opts, path);
345
379
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the string property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "string property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(insert a new value and press enter, go back using escape)\n"));
346
380
  terminal_kit_1.terminal.gray("\nCurrent value:" + (data.includes("\n") ? "\n" : " \"") + ansis_1.default.bold.blue(data) + ansis_1.default.gray(!data.includes("\n") ? "\"\n" : "\n"));
347
381
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
348
- const customExtraOptions = (structure instanceof index_1.api.ODCheckerCustomStructure_DiscordId) ? structure.extraOptions : undefined;
382
+ const customExtraOptions = (structure instanceof api.ODCheckerCustomStructure_DiscordId) ? structure.extraOptions : undefined;
349
383
  const customAutocompleteFunc = structure.options.cliAutocompleteFunc ? await structure.options.cliAutocompleteFunc() : null;
350
384
  const autocompleteList = ((customAutocompleteFunc ?? structure.options.cliAutocompleteList) ?? customExtraOptions) ?? structure.options.choices;
351
385
  const autoCompleteMenuOpts = {
@@ -382,21 +416,21 @@ class ODCliEditConfigInstance {
382
416
  parent[parentIndex] = newValue;
383
417
  await checker.config.save();
384
418
  terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
385
- await index_1.utilities.timer(400);
419
+ await utilities.timer(400);
386
420
  await backFn();
387
421
  }
388
422
  else {
389
423
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
390
424
  terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
391
425
  terminal_kit_1.terminal.red("\n" + messages);
392
- await index_1.utilities.timer(1000 + (2000 * checker.messages.length));
426
+ await utilities.timer(1000 + (2000 * checker.messages.length));
393
427
  await this.renderConfigStringStructureEditor(checker, backFn, structure, data, parent, parentIndex, path, answer);
394
428
  }
395
429
  }
396
430
  async renderConfigNullStructureEditor(checker, backFn, structure, data, parent, parentIndex, path) {
397
431
  if (data !== null)
398
- throw new index_1.api.ODSystemError("OD CLI => Property is not of the type 'null'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
399
- (0, cli_1.renderHeader)(this.opts, path);
432
+ throw new api.ODSystemError("OD CLI => Property is not of the type 'null'. Please check your config for possible errors. (index: " + parentIndex + ", path: " + path.join(".") + ")");
433
+ (0, _1.renderHeader)(this.opts, path);
400
434
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the null property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "null property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
401
435
  terminal_kit_1.terminal.gray("\nCurrent value: " + ansis_1.default.bold.blue("null") + "\n");
402
436
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
@@ -420,19 +454,19 @@ class ODCliEditConfigInstance {
420
454
  parent[parentIndex] = newValue;
421
455
  await checker.config.save();
422
456
  terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
423
- await index_1.utilities.timer(400);
457
+ await utilities.timer(400);
424
458
  await backFn();
425
459
  }
426
460
  else {
427
461
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
428
462
  terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
429
463
  terminal_kit_1.terminal.red("\n" + messages);
430
- await index_1.utilities.timer(1000 + (2000 * checker.messages.length));
464
+ await utilities.timer(1000 + (2000 * checker.messages.length));
431
465
  await this.renderConfigNullStructureEditor(checker, backFn, structure, data, parent, parentIndex, path);
432
466
  }
433
467
  }
434
468
  async renderConfigTypeSwitchStructureEditor(checker, backFn, structure, data, parent, parentIndex, path) {
435
- (0, cli_1.renderHeader)(this.opts, path);
469
+ (0, _1.renderHeader)(this.opts, path);
436
470
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now editing " + (typeof parentIndex == "string" ? "the property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
437
471
  terminal_kit_1.terminal.gray("\nCurrent value: " + ansis_1.default.bold.blue(data.toString()) + "\n");
438
472
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
@@ -474,29 +508,29 @@ class ODCliEditConfigInstance {
474
508
  await this.renderConfigNullStructureEditor(checker, async () => { await this.renderConfigTypeSwitchStructureEditor(checker, backFn, structure, data, parent, parentIndex, path); }, structure.options.null, null, parent, parentIndex, path);
475
509
  }
476
510
  getArrayPreviewStructureNameLength(structure, data, parent, parentIndex) {
477
- if (structure instanceof index_1.api.ODCheckerBooleanStructure && typeof data == "boolean")
511
+ if (structure instanceof api.ODCheckerBooleanStructure && typeof data == "boolean")
478
512
  return data.toString().length;
479
- else if (structure instanceof index_1.api.ODCheckerNumberStructure && typeof data == "number")
513
+ else if (structure instanceof api.ODCheckerNumberStructure && typeof data == "number")
480
514
  return data.toString().length;
481
- else if (structure instanceof index_1.api.ODCheckerStringStructure && typeof data == "string")
515
+ else if (structure instanceof api.ODCheckerStringStructure && typeof data == "string")
482
516
  return data.length;
483
- else if (structure instanceof index_1.api.ODCheckerNullStructure && data === null)
517
+ else if (structure instanceof api.ODCheckerNullStructure && data === null)
484
518
  return "Null".length;
485
- else if (structure instanceof index_1.api.ODCheckerArrayStructure && Array.isArray(data))
519
+ else if (structure instanceof api.ODCheckerArrayStructure && Array.isArray(data))
486
520
  return "Array".length;
487
- else if (structure instanceof index_1.api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
521
+ else if (structure instanceof api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
488
522
  if (!structure.options.cliDisplayKeyInParentArray)
489
523
  return "Object".length;
490
524
  else
491
525
  return data[structure.options.cliDisplayKeyInParentArray].toString().length;
492
526
  }
493
- else if (structure instanceof index_1.api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
527
+ else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
494
528
  const subStructure = structure.options.checker;
495
529
  if (!subStructure)
496
530
  return "<unknown-property>".length;
497
531
  return this.getArrayPreviewStructureNameLength(subStructure, data, parent, parentIndex);
498
532
  }
499
- else if (structure instanceof index_1.api.ODCheckerObjectSwitchStructure && typeof data == "object" && !Array.isArray(data) && data) {
533
+ else if (structure instanceof api.ODCheckerObjectSwitchStructure && typeof data == "object" && !Array.isArray(data) && data) {
500
534
  for (const objectTemplate of (structure.options.objects ?? [])) {
501
535
  if (objectTemplate.properties.every((prop) => data[prop.key] === prop.value)) {
502
536
  //object template matches data
@@ -506,7 +540,7 @@ class ODCliEditConfigInstance {
506
540
  }
507
541
  return "<unknown-property>".length;
508
542
  }
509
- else if (structure instanceof index_1.api.ODCheckerTypeSwitchStructure) {
543
+ else if (structure instanceof api.ODCheckerTypeSwitchStructure) {
510
544
  if (typeof data == "boolean" && structure.options.boolean)
511
545
  return this.getArrayPreviewStructureNameLength(structure.options.boolean, data, parent, parentIndex);
512
546
  else if (typeof data == "number" && structure.options.number)
@@ -526,30 +560,30 @@ class ODCliEditConfigInstance {
526
560
  return "<unknown-property>".length;
527
561
  }
528
562
  getArrayPreviewFromStructure(structure, data, parent, parentIndex, nameLength) {
529
- if (structure instanceof index_1.api.ODCheckerBooleanStructure && typeof data == "boolean")
563
+ if (structure instanceof api.ODCheckerBooleanStructure && typeof data == "boolean")
530
564
  return data.toString();
531
- else if (structure instanceof index_1.api.ODCheckerNumberStructure && typeof data == "number")
565
+ else if (structure instanceof api.ODCheckerNumberStructure && typeof data == "number")
532
566
  return data.toString();
533
- else if (structure instanceof index_1.api.ODCheckerStringStructure && typeof data == "string")
567
+ else if (structure instanceof api.ODCheckerStringStructure && typeof data == "string")
534
568
  return data;
535
- else if (structure instanceof index_1.api.ODCheckerNullStructure && data === null)
569
+ else if (structure instanceof api.ODCheckerNullStructure && data === null)
536
570
  return "Null";
537
- else if (structure instanceof index_1.api.ODCheckerArrayStructure && Array.isArray(data))
571
+ else if (structure instanceof api.ODCheckerArrayStructure && Array.isArray(data))
538
572
  return "Array";
539
- else if (structure instanceof index_1.api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
573
+ else if (structure instanceof api.ODCheckerObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
540
574
  const additionalKeys = (structure.options.cliDisplayAdditionalKeysInParentArray ?? []).map((key) => key + ": " + data[key].toString()).join(", ");
541
575
  if (!structure.options.cliDisplayKeyInParentArray)
542
576
  return "Object";
543
577
  else
544
578
  return data[structure.options.cliDisplayKeyInParentArray].toString().padEnd(nameLength + 5, " ") + ansis_1.default.gray(additionalKeys.length > 0 ? "(" + additionalKeys + ")" : "");
545
579
  }
546
- else if (structure instanceof index_1.api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
580
+ else if (structure instanceof api.ODCheckerEnabledObjectStructure && typeof data == "object" && !Array.isArray(data) && data) {
547
581
  const subStructure = structure.options.checker;
548
582
  if (!subStructure)
549
583
  return "<unknown-property>";
550
584
  return this.getArrayPreviewFromStructure(subStructure, data, parent, parentIndex, nameLength);
551
585
  }
552
- else if (structure instanceof index_1.api.ODCheckerObjectSwitchStructure && typeof data == "object" && !Array.isArray(data) && data) {
586
+ else if (structure instanceof api.ODCheckerObjectSwitchStructure && typeof data == "object" && !Array.isArray(data) && data) {
553
587
  for (const objectTemplate of (structure.options.objects ?? [])) {
554
588
  if (objectTemplate.properties.every((prop) => data[prop.key] === prop.value)) {
555
589
  //object template matches data
@@ -559,7 +593,7 @@ class ODCliEditConfigInstance {
559
593
  }
560
594
  return "<unknown-property>";
561
595
  }
562
- else if (structure instanceof index_1.api.ODCheckerTypeSwitchStructure) {
596
+ else if (structure instanceof api.ODCheckerTypeSwitchStructure) {
563
597
  if (typeof data == "boolean" && structure.options.boolean)
564
598
  return this.getArrayPreviewFromStructure(structure.options.boolean, data, parent, parentIndex, nameLength);
565
599
  else if (typeof data == "number" && structure.options.number)
@@ -579,23 +613,23 @@ class ODCliEditConfigInstance {
579
613
  return "<unknown-property>";
580
614
  }
581
615
  async chooseAdditionConfigStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath) {
582
- if (structure instanceof index_1.api.ODCheckerObjectStructure)
616
+ if (structure instanceof api.ODCheckerObjectStructure)
583
617
  await this.renderAdditionConfigObjectStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
584
- else if (structure instanceof index_1.api.ODCheckerBooleanStructure)
618
+ else if (structure instanceof api.ODCheckerBooleanStructure)
585
619
  await this.renderAdditionConfigBooleanStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
586
- else if (structure instanceof index_1.api.ODCheckerNumberStructure)
620
+ else if (structure instanceof api.ODCheckerNumberStructure)
587
621
  await this.renderAdditionConfigNumberStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
588
- else if (structure instanceof index_1.api.ODCheckerStringStructure)
622
+ else if (structure instanceof api.ODCheckerStringStructure)
589
623
  await this.renderAdditionConfigStringStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
590
- else if (structure instanceof index_1.api.ODCheckerNullStructure)
624
+ else if (structure instanceof api.ODCheckerNullStructure)
591
625
  await this.renderAdditionConfigNullStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
592
- else if (structure instanceof index_1.api.ODCheckerEnabledObjectStructure)
626
+ else if (structure instanceof api.ODCheckerEnabledObjectStructure)
593
627
  await this.renderAdditionConfigEnabledObjectStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
594
- else if (structure instanceof index_1.api.ODCheckerObjectSwitchStructure)
628
+ else if (structure instanceof api.ODCheckerObjectSwitchStructure)
595
629
  await this.renderAdditionConfigObjectSwitchStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
596
- else if (structure instanceof index_1.api.ODCheckerArrayStructure)
630
+ else if (structure instanceof api.ODCheckerArrayStructure)
597
631
  await this.renderAdditionConfigArrayStructureSelector(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
598
- else if (structure instanceof index_1.api.ODCheckerTypeSwitchStructure)
632
+ else if (structure instanceof api.ODCheckerTypeSwitchStructure)
599
633
  await this.renderAdditionConfigTypeSwitchStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
600
634
  else
601
635
  await backFn();
@@ -608,26 +642,26 @@ class ODCliEditConfigInstance {
608
642
  const childStructure = children.find((c) => c.key == key);
609
643
  if (childStructure) {
610
644
  const defaultValue = childStructure.checker.options.cliInitDefaultValue;
611
- if (childStructure.checker instanceof index_1.api.ODCheckerBooleanStructure)
645
+ if (childStructure.checker instanceof api.ODCheckerBooleanStructure)
612
646
  localData[key] = (typeof defaultValue == "boolean" ? defaultValue : false);
613
- else if (childStructure.checker instanceof index_1.api.ODCheckerNumberStructure)
647
+ else if (childStructure.checker instanceof api.ODCheckerNumberStructure)
614
648
  localData[key] = (typeof defaultValue == "number" ? defaultValue : 0);
615
- else if (childStructure.checker instanceof index_1.api.ODCheckerStringStructure)
649
+ else if (childStructure.checker instanceof api.ODCheckerStringStructure)
616
650
  localData[key] = (typeof defaultValue == "string" ? defaultValue : "");
617
- else if (childStructure.checker instanceof index_1.api.ODCheckerNullStructure)
651
+ else if (childStructure.checker instanceof api.ODCheckerNullStructure)
618
652
  localData[key] = (defaultValue === null ? defaultValue : null);
619
- else if (childStructure.checker instanceof index_1.api.ODCheckerArrayStructure)
653
+ else if (childStructure.checker instanceof api.ODCheckerArrayStructure)
620
654
  localData[key] = (Array.isArray(defaultValue) ? JSON.parse(JSON.stringify(defaultValue)) : []);
621
- else if (childStructure.checker instanceof index_1.api.ODCheckerObjectStructure)
655
+ else if (childStructure.checker instanceof api.ODCheckerObjectStructure)
622
656
  localData[key] = ((typeof defaultValue == "object" && !Array.isArray(defaultValue) && defaultValue) ? JSON.parse(JSON.stringify(defaultValue)) : {});
623
- else if (childStructure.checker instanceof index_1.api.ODCheckerObjectSwitchStructure)
657
+ else if (childStructure.checker instanceof api.ODCheckerObjectSwitchStructure)
624
658
  localData[key] = ((typeof defaultValue == "object" && !Array.isArray(defaultValue) && defaultValue) ? JSON.parse(JSON.stringify(defaultValue)) : {});
625
- else if (childStructure.checker instanceof index_1.api.ODCheckerEnabledObjectStructure)
659
+ else if (childStructure.checker instanceof api.ODCheckerEnabledObjectStructure)
626
660
  localData[key] = ((typeof defaultValue == "object" && !Array.isArray(defaultValue) && defaultValue) ? JSON.parse(JSON.stringify(defaultValue)) : {});
627
- else if (childStructure.checker instanceof index_1.api.ODCheckerTypeSwitchStructure && typeof defaultValue != "undefined")
661
+ else if (childStructure.checker instanceof api.ODCheckerTypeSwitchStructure && typeof defaultValue != "undefined")
628
662
  localData[key] = JSON.parse(JSON.stringify(defaultValue));
629
663
  else
630
- throw new index_1.api.ODSystemError("OD CLI => Object skip key has an invalid checker structure! key: " + key);
664
+ throw new api.ODSystemError("OD CLI => Object skip key has an invalid checker structure! key: " + key);
631
665
  }
632
666
  }
633
667
  //add properties that need to be configured
@@ -638,7 +672,7 @@ class ODCliEditConfigInstance {
638
672
  }, async () => {
639
673
  //finish setup
640
674
  terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
641
- await index_1.utilities.timer(400);
675
+ await utilities.timer(400);
642
676
  await nextFn(localData);
643
677
  });
644
678
  }
@@ -667,11 +701,11 @@ class ODCliEditConfigInstance {
667
701
  return await backFn();
668
702
  let propertyStructure;
669
703
  if (typeof enabledValue == "string")
670
- propertyStructure = new index_1.api.ODCheckerStringStructure("opendiscord:CLI-checker-enabled-object-structure", {});
704
+ propertyStructure = new api.ODCheckerStringStructure("opendiscord:CLI-checker-enabled-object-structure", {});
671
705
  else if (typeof enabledValue == "number")
672
- propertyStructure = new index_1.api.ODCheckerNumberStructure("opendiscord:CLI-checker-enabled-object-structure", {});
706
+ propertyStructure = new api.ODCheckerNumberStructure("opendiscord:CLI-checker-enabled-object-structure", {});
673
707
  else if (typeof enabledValue == "boolean")
674
- propertyStructure = new index_1.api.ODCheckerBooleanStructure("opendiscord:CLI-checker-enabled-object-structure", {});
708
+ propertyStructure = new api.ODCheckerBooleanStructure("opendiscord:CLI-checker-enabled-object-structure", {});
675
709
  else
676
710
  throw new Error("OD CLI => enabled object structure has an invalid type of enabledProperty. It must be a primitive boolean/number/string.");
677
711
  const localData = {};
@@ -681,7 +715,7 @@ class ODCliEditConfigInstance {
681
715
  else {
682
716
  localData[enabledProperty] = data;
683
717
  //copy old object checker to new object checker => all options get de-referenced (this is needed for the new object skip keys are temporary)
684
- const newStructure = new index_1.api.ODCheckerObjectStructure(subStructure.id, { children: [] });
718
+ const newStructure = new api.ODCheckerObjectStructure(subStructure.id, { children: [] });
685
719
  //copy all options over to the new checker
686
720
  newStructure.options.children = [...subStructure.options.children];
687
721
  newStructure.options.cliInitSkipKeys = subStructure.options.children.map((child) => child.key);
@@ -696,7 +730,7 @@ class ODCliEditConfigInstance {
696
730
  }, propertyStructure, localData, enabledProperty, [...path, parentIndex], [...localPath, parentIndex]);
697
731
  }
698
732
  async renderAdditionConfigObjectSwitchStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath) {
699
- (0, cli_1.renderHeader)(this.opts, [...path, parentIndex]);
733
+ (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
700
734
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("What type of object would you like to add?\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
701
735
  const answer = await terminal_kit_1.terminal.singleColumnMenu(structure.options.objects.map((obj) => obj.name), {
702
736
  leftPadding: "> ",
@@ -711,7 +745,7 @@ class ODCliEditConfigInstance {
711
745
  const objectTemplate = structure.options.objects[answer.selectedIndex];
712
746
  //copy old object checker to new object checker => all options get de-referenced (this is needed for the new object switch properties which are temporary)
713
747
  const oldStructure = objectTemplate.checker;
714
- const newStructure = new index_1.api.ODCheckerObjectStructure(oldStructure.id, { children: [] });
748
+ const newStructure = new api.ODCheckerObjectStructure(oldStructure.id, { children: [] });
715
749
  //copy all options over to the new checker
716
750
  newStructure.options.children = [...oldStructure.options.children];
717
751
  newStructure.options.cliInitSkipKeys = [...(oldStructure.options.cliInitSkipKeys ?? [])];
@@ -730,17 +764,17 @@ class ODCliEditConfigInstance {
730
764
  for (const prop of objectTemplate.properties) {
731
765
  if (!newStructure.options.children.find((child) => child.key === prop.key)) {
732
766
  if (typeof prop.value == "string")
733
- newStructure.options.children.unshift({ key: prop.key, optional: false, priority: 1, checker: new index_1.api.ODCheckerStringStructure("opendiscord:CLI-checker-object-switch-structure", { cliInitDefaultValue: prop.value }) });
767
+ newStructure.options.children.unshift({ key: prop.key, optional: false, priority: 1, checker: new api.ODCheckerStringStructure("opendiscord:CLI-checker-object-switch-structure", { cliInitDefaultValue: prop.value }) });
734
768
  else if (typeof prop.value == "number")
735
- newStructure.options.children.unshift({ key: prop.key, optional: false, priority: 1, checker: new index_1.api.ODCheckerNumberStructure("opendiscord:CLI-checker-object-switch-structure", { cliInitDefaultValue: prop.value }) });
769
+ newStructure.options.children.unshift({ key: prop.key, optional: false, priority: 1, checker: new api.ODCheckerNumberStructure("opendiscord:CLI-checker-object-switch-structure", { cliInitDefaultValue: prop.value }) });
736
770
  else if (typeof prop.value == "boolean")
737
- newStructure.options.children.unshift({ key: prop.key, optional: false, priority: 1, checker: new index_1.api.ODCheckerBooleanStructure("opendiscord:CLI-checker-object-switch-structure", { cliInitDefaultValue: prop.value }) });
771
+ newStructure.options.children.unshift({ key: prop.key, optional: false, priority: 1, checker: new api.ODCheckerBooleanStructure("opendiscord:CLI-checker-object-switch-structure", { cliInitDefaultValue: prop.value }) });
738
772
  }
739
773
  }
740
774
  await this.chooseAdditionConfigStructure(checker, backFn, nextFn, newStructure, parent, parentIndex, path, localPath);
741
775
  }
742
776
  async renderAdditionConfigBooleanStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath) {
743
- (0, cli_1.renderHeader)(this.opts, [...path, parentIndex]);
777
+ (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
744
778
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the boolean property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "boolean property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
745
779
  terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
746
780
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
@@ -762,19 +796,19 @@ class ODCliEditConfigInstance {
762
796
  const isDataValid = structure.check(checker, newValue, newPath);
763
797
  if (isDataValid) {
764
798
  terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
765
- await index_1.utilities.timer(400);
799
+ await utilities.timer(400);
766
800
  await nextFn(newValue);
767
801
  }
768
802
  else {
769
803
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
770
804
  terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
771
805
  terminal_kit_1.terminal.gray("\n" + messages);
772
- await index_1.utilities.timer(1000 + (2000 * checker.messages.length));
806
+ await utilities.timer(1000 + (2000 * checker.messages.length));
773
807
  await this.renderAdditionConfigBooleanStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
774
808
  }
775
809
  }
776
810
  async renderAdditionConfigNumberStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, prefillValue) {
777
- (0, cli_1.renderHeader)(this.opts, [...path, parentIndex]);
811
+ (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
778
812
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the number property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "number property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(insert a new value and press enter, go back using escape)\n"));
779
813
  terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
780
814
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
@@ -793,23 +827,23 @@ class ODCliEditConfigInstance {
793
827
  const isDataValid = structure.check(checker, newValue, newPath);
794
828
  if (isDataValid) {
795
829
  terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
796
- await index_1.utilities.timer(400);
830
+ await utilities.timer(400);
797
831
  await nextFn(newValue);
798
832
  }
799
833
  else {
800
834
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
801
835
  terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
802
836
  terminal_kit_1.terminal.red("\n" + messages);
803
- await index_1.utilities.timer(1000 + (2000 * checker.messages.length));
837
+ await utilities.timer(1000 + (2000 * checker.messages.length));
804
838
  await this.renderAdditionConfigNumberStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, answer);
805
839
  }
806
840
  }
807
841
  async renderAdditionConfigStringStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, prefillValue) {
808
- (0, cli_1.renderHeader)(this.opts, [...path, parentIndex]);
842
+ (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
809
843
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the string property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "string property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(insert a new value and press enter, go back using escape)\n"));
810
844
  terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
811
845
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
812
- const customExtraOptions = (structure instanceof index_1.api.ODCheckerCustomStructure_DiscordId) ? structure.extraOptions : undefined;
846
+ const customExtraOptions = (structure instanceof api.ODCheckerCustomStructure_DiscordId) ? structure.extraOptions : undefined;
813
847
  const customAutocompleteFunc = structure.options.cliAutocompleteFunc ? await structure.options.cliAutocompleteFunc() : null;
814
848
  const autocompleteList = ((customAutocompleteFunc ?? structure.options.cliAutocompleteList) ?? customExtraOptions) ?? structure.options.choices;
815
849
  const autoCompleteMenuOpts = {
@@ -844,19 +878,19 @@ class ODCliEditConfigInstance {
844
878
  const isDataValid = structure.check(checker, newValue, newPath);
845
879
  if (isDataValid) {
846
880
  terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
847
- await index_1.utilities.timer(400);
881
+ await utilities.timer(400);
848
882
  await nextFn(newValue);
849
883
  }
850
884
  else {
851
885
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
852
886
  terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
853
887
  terminal_kit_1.terminal.red("\n" + messages);
854
- await index_1.utilities.timer(1000 + (2000 * checker.messages.length));
888
+ await utilities.timer(1000 + (2000 * checker.messages.length));
855
889
  await this.renderAdditionConfigStringStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, answer);
856
890
  }
857
891
  }
858
892
  async renderAdditionConfigNullStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath) {
859
- (0, cli_1.renderHeader)(this.opts, [...path, parentIndex]);
893
+ (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
860
894
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the null property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "null property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
861
895
  terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
862
896
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
@@ -878,19 +912,19 @@ class ODCliEditConfigInstance {
878
912
  const isDataValid = structure.check(checker, newValue, newPath);
879
913
  if (isDataValid) {
880
914
  terminal_kit_1.terminal.bold.blue("\n\n✅ Variable saved succesfully!");
881
- await index_1.utilities.timer(400);
915
+ await utilities.timer(400);
882
916
  await nextFn(newValue);
883
917
  }
884
918
  else {
885
919
  const messages = checker.messages.map((msg) => "=> [" + msg.type.toUpperCase() + "] " + msg.message).join("\n");
886
920
  terminal_kit_1.terminal.bold.blue("\n\n❌ Variable is invalid! Please try again!");
887
921
  terminal_kit_1.terminal.red("\n" + messages);
888
- await index_1.utilities.timer(1000 + (2000 * checker.messages.length));
922
+ await utilities.timer(1000 + (2000 * checker.messages.length));
889
923
  await this.renderAdditionConfigNullStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath);
890
924
  }
891
925
  }
892
926
  async renderAdditionConfigArrayStructureSelector(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath, localData = []) {
893
- (0, cli_1.renderHeader)(this.opts, [...path, parentIndex]);
927
+ (0, _1.renderHeader)(this.opts, [...path, parentIndex]);
894
928
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select what you would like to do with the new array.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
895
929
  if (!structure.options.propertyChecker)
896
930
  return await backFn();
@@ -932,7 +966,7 @@ class ODCliEditConfigInstance {
932
966
  await this.renderConfigArrayStructureDuplicateSelector(checker, backFnFunc, structure, structure.options.propertyChecker, localData, parent, parentIndex, path);
933
967
  }
934
968
  async renderAdditionConfigTypeSwitchStructure(checker, backFn, nextFn, structure, parent, parentIndex, path, localPath) {
935
- (0, cli_1.renderHeader)(this.opts, path);
969
+ (0, _1.renderHeader)(this.opts, path);
936
970
  (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("You are now creating " + (typeof parentIndex == "string" ? "the property " + ansis_1.default.blue("\"" + parentIndex + "\"") : "property " + ansis_1.default.blue("#" + (parentIndex + 1))) + ".\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, go back using escape)\n"));
937
971
  terminal_kit_1.terminal.gray("\nProperty: " + ansis_1.default.bold.blue(structure.options.cliDisplayName ?? [...localPath, parentIndex].join(".")) + "\n");
938
972
  terminal_kit_1.terminal.gray("Description: " + ansis_1.default.bold(structure.options.cliDisplayDescription ?? "/") + "\n");
@@ -1,4 +1,4 @@
1
- import { api } from "../index";
1
+ import * as api from "../api/index";
2
2
  import { Terminal } from "terminal-kit";
3
3
  import * as discord from "discord.js";
4
4
  export * from "./editConfig";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- export * as api from "./api/api";
2
- export * as utilities from "./api/utils";
3
- export * as cli from "./cli/cli";
4
1
  export { loadDumpCommand } from "./startup/dump";
5
2
  export { loadAllPlugins } from "./startup/pluginLauncher";
6
3
  export { frameworkStartup } from "./startup/compilation";
package/dist/index.js CHANGED
@@ -1,42 +1,6 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.frameworkStartup = exports.loadAllPlugins = exports.loadDumpCommand = exports.cli = exports.utilities = exports.api = void 0;
37
- exports.api = __importStar(require("./api/api"));
38
- exports.utilities = __importStar(require("./api/utils"));
39
- exports.cli = __importStar(require("./cli/cli"));
3
+ exports.frameworkStartup = exports.loadAllPlugins = exports.loadDumpCommand = void 0;
40
4
  var dump_1 = require("./startup/dump");
41
5
  Object.defineProperty(exports, "loadDumpCommand", { enumerable: true, get: function () { return dump_1.loadDumpCommand; } });
42
6
  var pluginLauncher_1 = require("./startup/pluginLauncher");
@@ -1,3 +1,3 @@
1
- import type { ODProjectType } from "../api/api";
1
+ import type { ODProjectType } from "../api";
2
2
  export declare function checkFrameworkAllowed(project?: ODProjectType): void;
3
3
  export declare function frameworkStartup(startupFlags: string[], project: ODProjectType, startCallback: () => void): void;
@@ -1,4 +1,4 @@
1
- import { api } from "../index";
1
+ import * as api from "../api/index";
2
2
  /** ### What is this?
3
3
  * This is the `!OPENTICKET:dump` command.
4
4
  * It's a utility command which can only be used by the creator of Open Discord/Ticket/Moderation or the owner of the bot.
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.loadDumpCommand = void 0;
37
- const index_1 = require("../index");
37
+ const api = __importStar(require("../api/index"));
38
38
  const discord = __importStar(require("discord.js"));
39
39
  const fs = __importStar(require("fs"));
40
40
  /** ### What is this?
@@ -52,7 +52,7 @@ const fs = __importStar(require("fs"));
52
52
  const loadDumpCommand = (opendiscord) => {
53
53
  if (!opendiscord.sharedFuses.getFuse("allowDumpCommand"))
54
54
  return;
55
- opendiscord.client.textCommands.add(new index_1.api.ODTextCommand("opendiscord:dump", {
55
+ opendiscord.client.textCommands.add(new api.ODTextCommand("opendiscord:dump", {
56
56
  allowBots: false,
57
57
  guildPermission: true,
58
58
  dmPermission: true,
@@ -1,2 +1,2 @@
1
- import { api } from "../index";
1
+ import * as api from "../api/index";
2
2
  export declare function loadErrorHandling(opendiscord: api.ODMain, project: api.ODProjectType): void;
@@ -1,7 +1,40 @@
1
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
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.loadErrorHandling = loadErrorHandling;
4
- const index_1 = require("../index");
37
+ const api = __importStar(require("../api/index"));
5
38
  function loadErrorHandling(opendiscord, project) {
6
39
  process.on("uncaughtException", async (error, origin) => {
7
40
  try {
@@ -26,7 +59,7 @@ function loadErrorHandling(opendiscord, project) {
26
59
  }
27
60
  else {
28
61
  //unknown error
29
- const errmsg = new index_1.api.ODError(error, origin);
62
+ const errmsg = new api.ODError(error, origin);
30
63
  opendiscord.log(errmsg);
31
64
  if (opendiscord.sharedFuses.getFuse("crashOnError"))
32
65
  process.exit(1);
@@ -1,2 +1,2 @@
1
- import { api } from "../index";
1
+ import * as api from "../api/index";
2
2
  export declare const loadAllPlugins: (opendiscord: api.ODMain) => Promise<void>;
@@ -1,10 +1,43 @@
1
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
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.loadAllPlugins = void 0;
7
- const index_1 = require("../index");
40
+ const api = __importStar(require("../api/index"));
8
41
  const fs_1 = __importDefault(require("fs"));
9
42
  const loadAllPlugins = async (opendiscord) => {
10
43
  //start launching plugins
@@ -36,64 +69,64 @@ const loadAllPlugins = async (opendiscord) => {
36
69
  try {
37
70
  const rawplugindata = JSON.parse(fs_1.default.readFileSync("./plugins/" + p + "/plugin.json").toString());
38
71
  if (typeof rawplugindata != "object")
39
- throw new index_1.api.ODPluginError("Failed to load plugin.json");
72
+ throw new api.ODPluginError("Failed to load plugin.json");
40
73
  if (typeof rawplugindata.id != "string")
41
- throw new index_1.api.ODPluginError("Failed to load plugin.json/id");
74
+ throw new api.ODPluginError("Failed to load plugin.json/id");
42
75
  if (typeof rawplugindata.name != "string")
43
- throw new index_1.api.ODPluginError("Failed to load plugin.json/name");
76
+ throw new api.ODPluginError("Failed to load plugin.json/name");
44
77
  if (typeof rawplugindata.version != "string")
45
- throw new index_1.api.ODPluginError("Failed to load plugin.json/version");
78
+ throw new api.ODPluginError("Failed to load plugin.json/version");
46
79
  if (typeof rawplugindata.startFile != "string")
47
- throw new index_1.api.ODPluginError("Failed to load plugin.json/startFile");
80
+ throw new api.ODPluginError("Failed to load plugin.json/startFile");
48
81
  //only check "supportedVersions" if it exists (should be array)
49
82
  if (rawplugindata.supportedVersions) {
50
83
  if (!Array.isArray(rawplugindata.supportedVersions))
51
- throw new index_1.api.ODPluginError("Failed to load plugin.json/supportedVersions (must be array)");
84
+ throw new api.ODPluginError("Failed to load plugin.json/supportedVersions (must be array)");
52
85
  for (const version of rawplugindata.supportedVersions) {
53
86
  if (typeof version !== "string") {
54
- throw new index_1.api.ODPluginError("Failed to load plugin.json/supportedVersions (all items must be strings)");
87
+ throw new api.ODPluginError("Failed to load plugin.json/supportedVersions (all items must be strings)");
55
88
  }
56
89
  //only OT (Open Ticket) & OM (Open Moderation) are supported at the moment
57
90
  if (!pluginVersionRegex.test(version)) {
58
- throw new index_1.api.ODPluginError(`Failed to load plugin.json/supportedVersions (invalid format: "${version}", expected format like "OTv4.0.x" or "OMv1.0.0")`);
91
+ throw new api.ODPluginError(`Failed to load plugin.json/supportedVersions (invalid format: "${version}", expected format like "OTv4.0.x" or "OMv1.0.0")`);
59
92
  }
60
93
  }
61
94
  }
62
95
  if (typeof rawplugindata.enabled != "boolean")
63
- throw new index_1.api.ODPluginError("Failed to load plugin.json/enabled");
96
+ throw new api.ODPluginError("Failed to load plugin.json/enabled");
64
97
  if (typeof rawplugindata.priority != "number")
65
- throw new index_1.api.ODPluginError("Failed to load plugin.json/priority");
98
+ throw new api.ODPluginError("Failed to load plugin.json/priority");
66
99
  if (!Array.isArray(rawplugindata.events))
67
- throw new index_1.api.ODPluginError("Failed to load plugin.json/events");
100
+ throw new api.ODPluginError("Failed to load plugin.json/events");
68
101
  if (!Array.isArray(rawplugindata.npmDependencies))
69
- throw new index_1.api.ODPluginError("Failed to load plugin.json/npmDependencies");
102
+ throw new api.ODPluginError("Failed to load plugin.json/npmDependencies");
70
103
  if (!Array.isArray(rawplugindata.requiredPlugins))
71
- throw new index_1.api.ODPluginError("Failed to load plugin.json/requiredPlugins");
104
+ throw new api.ODPluginError("Failed to load plugin.json/requiredPlugins");
72
105
  if (!Array.isArray(rawplugindata.incompatiblePlugins))
73
- throw new index_1.api.ODPluginError("Failed to load plugin.json/incompatiblePlugins");
106
+ throw new api.ODPluginError("Failed to load plugin.json/incompatiblePlugins");
74
107
  if (typeof rawplugindata.details != "object")
75
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details");
108
+ throw new api.ODPluginError("Failed to load plugin.json/details");
76
109
  if (typeof rawplugindata.details.author != "string")
77
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/author");
110
+ throw new api.ODPluginError("Failed to load plugin.json/details/author");
78
111
  //only check "contributors" if it exists (should be array)
79
112
  if (rawplugindata.details.contributors && !Array.isArray(rawplugindata.details.contributors))
80
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/contributors (must be array)");
113
+ throw new api.ODPluginError("Failed to load plugin.json/details/contributors (must be array)");
81
114
  if (typeof rawplugindata.details.shortDescription != "string")
82
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/shortDescription");
115
+ throw new api.ODPluginError("Failed to load plugin.json/details/shortDescription");
83
116
  if (typeof rawplugindata.details.longDescription != "string")
84
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/longDescription");
117
+ throw new api.ODPluginError("Failed to load plugin.json/details/longDescription");
85
118
  if (typeof rawplugindata.details.imageUrl != "string")
86
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/imageUrl");
119
+ throw new api.ODPluginError("Failed to load plugin.json/details/imageUrl");
87
120
  if (typeof rawplugindata.details.projectUrl != "string")
88
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/projectUrl");
121
+ throw new api.ODPluginError("Failed to load plugin.json/details/projectUrl");
89
122
  if (!Array.isArray(rawplugindata.details.tags))
90
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/tags");
123
+ throw new api.ODPluginError("Failed to load plugin.json/details/tags");
91
124
  if (rawplugindata.id != p)
92
- throw new index_1.api.ODPluginError("Failed to load plugin, directory name is required to match the id");
125
+ throw new api.ODPluginError("Failed to load plugin, directory name is required to match the id");
93
126
  if (opendiscord.plugins.exists(rawplugindata.id))
94
- throw new index_1.api.ODPluginError("Failed to load plugin, this id already exists in another plugin");
127
+ throw new api.ODPluginError("Failed to load plugin, this id already exists in another plugin");
95
128
  //plugin.json is valid => load plugin
96
- const plugin = new index_1.api.ODPlugin(p, rawplugindata);
129
+ const plugin = new api.ODPlugin(p, rawplugindata);
97
130
  opendiscord.plugins.add(plugin);
98
131
  }
99
132
  catch (e) {
@@ -134,7 +167,7 @@ const loadAllPlugins = async (opendiscord) => {
134
167
  if (plugin.data.supportedVersions && plugin.data.supportedVersions.length > 0) {
135
168
  const currentVersion = opendiscord.versions.get("opendiscord:version");
136
169
  if (!currentVersion)
137
- throw new index_1.api.ODSystemError("Unable to get project version: opendiscord.versions.get('opendiscord:version')!");
170
+ throw new api.ODSystemError("Unable to get project version: opendiscord.versions.get('opendiscord:version')!");
138
171
  let isCompatible = false;
139
172
  for (const versionStr of plugin.data.supportedVersions) {
140
173
  const match = versionStr.match(pluginVersionRegex);
@@ -231,7 +264,7 @@ const loadAllPlugins = async (opendiscord) => {
231
264
  //preload all events required for every plugin
232
265
  for (const plugin of sortedPlugins) {
233
266
  if (plugin.enabled)
234
- plugin.data.events.forEach((event) => opendiscord.events.add(new index_1.api.ODEvent(event)));
267
+ plugin.data.events.forEach((event) => opendiscord.events.add(new api.ODEvent(event)));
235
268
  }
236
269
  //execute all working plugins
237
270
  for (const plugin of sortedPlugins) {
@@ -1,4 +1,4 @@
1
- import * as api from "./api";
1
+ import * as api from "../api/index";
2
2
  /**## sharedFuses `utility variable`
3
3
  * All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
4
4
  */
@@ -51,7 +51,7 @@ exports.ordinalNumber = ordinalNumber;
51
51
  exports.trimEmojis = trimEmojis;
52
52
  const fs = __importStar(require("fs"));
53
53
  const ansis_1 = __importDefault(require("ansis"));
54
- const api = __importStar(require("./api"));
54
+ const api = __importStar(require("../api/index"));
55
55
  /**## sharedFuses `utility variable`
56
56
  * All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
57
57
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-discord-bots/framework",
3
3
  "author": "DJj123dj",
4
- "version": "0.0.8",
4
+ "version": "0.1.1",
5
5
  "description": "The core framework of the popular open-source discord bots: Open Ticket & Open Moderation.",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -25,5 +25,10 @@
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"
28
+ },
29
+ "exports": {
30
+ ".": "./dist/index.js",
31
+ "./api": "./dist/api/index.js",
32
+ "./utilities": "./dist/utilities/index.js"
28
33
  }
29
34
  }
@@ -1,7 +1,8 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
  import {Terminal, terminal} from "terminal-kit"
3
4
  import ansis from "ansis"
4
- import {ODCliHeaderOpts, renderHeader} from "./cli"
5
+ import {ODCliHeaderOpts, renderHeader} from "."
5
6
 
6
7
  export class ODCliEditConfigInstance {
7
8
  private readonly opts: ODCliHeaderOpts
@@ -1,4 +1,5 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
  import {Terminal, terminal} from "terminal-kit"
3
4
  import * as discord from "discord.js"
4
5
  import ansis from "ansis"
package/src/index.ts CHANGED
@@ -1,10 +1,7 @@
1
-
2
- export * as api from "./api/api"
3
- export * as utilities from "./api/utils"
4
- export * as cli from "./cli/cli"
5
1
  export { loadDumpCommand } from "./startup/dump"
6
2
  export { loadAllPlugins } from "./startup/pluginLauncher"
7
3
  export { frameworkStartup } from "./startup/compilation"
4
+ export { loadErrorHandling } from "./startup/errorHandling"
8
5
  import { checkFrameworkAllowed } from "./startup/compilation"
9
6
 
10
7
  //check directory structure
@@ -3,7 +3,7 @@ import ts from "typescript"
3
3
  import { createHash, Hash } from "crypto"
4
4
  import nodepath from "path"
5
5
  import ansis from "ansis"
6
- import type { ODProjectType } from "../api/api"
6
+ import type { ODProjectType } from "../api"
7
7
 
8
8
  /** ## What is this?
9
9
  * This is a function which compares `./src/` with a hash stored in `./dist/hash.txt`.
@@ -1,4 +1,5 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
  import * as discord from "discord.js"
3
4
  import * as fs from "fs"
4
5
 
@@ -1,4 +1,5 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
 
3
4
  export function loadErrorHandling(opendiscord:api.ODMain,project:api.ODProjectType){
4
5
  process.on("uncaughtException",async (error,origin) => {
@@ -1,4 +1,5 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
  import fs from "fs"
3
4
 
4
5
  export const loadAllPlugins = async (opendiscord:api.ODMain) => {
@@ -1,6 +1,6 @@
1
1
  import * as fs from "fs"
2
2
  import ansis from "ansis"
3
- import * as api from "./api"
3
+ import * as api from "../api/index"
4
4
 
5
5
  /**## sharedFuses `utility variable`
6
6
  * All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
File without changes
File without changes
File without changes
File without changes