@open-discord-bots/framework 0.2.11 → 0.2.13

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 (107) hide show
  1. package/dist/api/index.d.ts +26 -26
  2. package/dist/api/index.js +26 -42
  3. package/dist/api/main.d.ts +24 -24
  4. package/dist/api/main.js +7 -11
  5. package/dist/api/modules/action.d.ts +12 -12
  6. package/dist/api/modules/action.js +11 -17
  7. package/dist/api/modules/base.d.ts +7 -5
  8. package/dist/api/modules/base.js +22 -67
  9. package/dist/api/modules/builder.d.ts +44 -44
  10. package/dist/api/modules/builder.js +81 -142
  11. package/dist/api/modules/checker.d.ts +7 -7
  12. package/dist/api/modules/checker.js +55 -87
  13. package/dist/api/modules/client.d.ts +4 -4
  14. package/dist/api/modules/client.js +71 -118
  15. package/dist/api/modules/code.d.ts +2 -2
  16. package/dist/api/modules/code.js +3 -8
  17. package/dist/api/modules/config.d.ts +2 -2
  18. package/dist/api/modules/config.js +21 -63
  19. package/dist/api/modules/console.d.ts +16 -16
  20. package/dist/api/modules/console.js +61 -83
  21. package/dist/api/modules/cooldown.d.ts +2 -2
  22. package/dist/api/modules/cooldown.js +13 -23
  23. package/dist/api/modules/database.d.ts +2 -2
  24. package/dist/api/modules/database.js +19 -29
  25. package/dist/api/modules/event.d.ts +2 -2
  26. package/dist/api/modules/event.js +6 -11
  27. package/dist/api/modules/flag.d.ts +2 -2
  28. package/dist/api/modules/flag.js +3 -8
  29. package/dist/api/modules/fuse.js +2 -7
  30. package/dist/api/modules/helpmenu.d.ts +2 -2
  31. package/dist/api/modules/helpmenu.js +8 -16
  32. package/dist/api/modules/language.d.ts +2 -2
  33. package/dist/api/modules/language.js +12 -21
  34. package/dist/api/modules/permission.d.ts +3 -3
  35. package/dist/api/modules/permission.js +9 -47
  36. package/dist/api/modules/plugin.d.ts +2 -2
  37. package/dist/api/modules/plugin.js +9 -18
  38. package/dist/api/modules/post.d.ts +3 -3
  39. package/dist/api/modules/post.js +3 -8
  40. package/dist/api/modules/progressbar.d.ts +2 -2
  41. package/dist/api/modules/progressbar.js +14 -26
  42. package/dist/api/modules/responder.d.ts +42 -42
  43. package/dist/api/modules/responder.js +79 -138
  44. package/dist/api/modules/session.d.ts +2 -2
  45. package/dist/api/modules/session.js +4 -42
  46. package/dist/api/modules/startscreen.d.ts +4 -4
  47. package/dist/api/modules/startscreen.js +28 -44
  48. package/dist/api/modules/statistic.d.ts +3 -3
  49. package/dist/api/modules/statistic.js +11 -22
  50. package/dist/api/modules/verifybar.d.ts +5 -5
  51. package/dist/api/modules/verifybar.js +6 -11
  52. package/dist/api/modules/worker.d.ts +15 -15
  53. package/dist/api/modules/worker.js +12 -17
  54. package/dist/cli/editConfig.d.ts +2 -2
  55. package/dist/cli/editConfig.js +194 -248
  56. package/dist/cli/index.d.ts +2 -2
  57. package/dist/cli/index.js +37 -62
  58. package/dist/index.d.ts +4 -4
  59. package/dist/index.js +6 -13
  60. package/dist/startup/compilation.d.ts +1 -1
  61. package/dist/startup/compilation.js +35 -42
  62. package/dist/startup/dump.d.ts +1 -1
  63. package/dist/startup/dump.js +4 -41
  64. package/dist/startup/errorHandling.d.ts +1 -1
  65. package/dist/startup/errorHandling.js +2 -38
  66. package/dist/startup/pluginLauncher.d.ts +1 -1
  67. package/dist/startup/pluginLauncher.js +14 -52
  68. package/dist/utilities/index.d.ts +3 -3
  69. package/dist/utilities/index.js +20 -71
  70. package/package.json +5 -4
  71. package/src/api/index.ts +26 -26
  72. package/src/api/main.ts +25 -25
  73. package/src/api/modules/action.ts +13 -13
  74. package/src/api/modules/base.ts +14 -10
  75. package/src/api/modules/builder.ts +56 -56
  76. package/src/api/modules/checker.ts +7 -7
  77. package/src/api/modules/client.ts +18 -18
  78. package/src/api/modules/code.ts +2 -2
  79. package/src/api/modules/component.txt +350 -0
  80. package/src/api/modules/config.ts +3 -3
  81. package/src/api/modules/console.ts +28 -28
  82. package/src/api/modules/cooldown.ts +2 -2
  83. package/src/api/modules/database.ts +3 -3
  84. package/src/api/modules/event.ts +5 -5
  85. package/src/api/modules/flag.ts +2 -2
  86. package/src/api/modules/helpmenu.ts +4 -4
  87. package/src/api/modules/language.ts +3 -3
  88. package/src/api/modules/permission.ts +3 -3
  89. package/src/api/modules/plugin.ts +4 -4
  90. package/src/api/modules/post.ts +3 -3
  91. package/src/api/modules/progressbar.ts +5 -3
  92. package/src/api/modules/responder.ts +48 -48
  93. package/src/api/modules/session.ts +2 -2
  94. package/src/api/modules/startscreen.ts +4 -4
  95. package/src/api/modules/statistic.ts +3 -4
  96. package/src/api/modules/verifybar.ts +5 -5
  97. package/src/api/modules/worker.ts +25 -25
  98. package/src/cli/editConfig.ts +23 -37
  99. package/src/cli/index.ts +3 -3
  100. package/src/index.ts +5 -5
  101. package/src/startup/compilation.ts +2 -2
  102. package/src/startup/dump.ts +2 -2
  103. package/src/startup/errorHandling.ts +2 -2
  104. package/src/startup/pluginLauncher.ts +11 -8
  105. package/src/utilities/index.ts +4 -4
  106. package/tools/cleanup.js +1 -1
  107. package/tsconfig.json +2 -1
@@ -1,7 +1,7 @@
1
- import * as api from "../api/index";
1
+ import * as api from "../api/index.js";
2
2
  import { Terminal } from "terminal-kit";
3
3
  import * as discord from "discord.js";
4
- export * from "./editConfig";
4
+ export * from "./editConfig.js";
5
5
  /**## ODCliHeaderOpts `interface`
6
6
  * All metadata required for rendering the Interactive Setup CLI header.
7
7
  */
package/dist/cli/index.js CHANGED
@@ -1,66 +1,41 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.presetColors = exports.autoCompleteMenuOpts = void 0;
21
- exports.centerText = centerText;
22
- exports.terminate = terminate;
23
- exports.generateUniqueIdFromName = generateUniqueIdFromName;
24
- exports.renderHeader = renderHeader;
25
- exports.execute = execute;
26
- const terminal_kit_1 = require("terminal-kit");
27
- const ansis_1 = __importDefault(require("ansis"));
28
- const crypto_1 = __importDefault(require("crypto"));
29
- __exportStar(require("./editConfig"), exports);
1
+ import { terminal } from "terminal-kit";
2
+ import ansis from "ansis";
3
+ import crypto from "crypto";
4
+ export * from "./editConfig.js";
30
5
  /**A utility function to center text to a certain width. */
31
- function centerText(text, width) {
6
+ export function centerText(text, width) {
32
7
  if (width < text.length)
33
8
  return text;
34
- let newWidth = width - ansis_1.default.strip(text).length + 1;
9
+ let newWidth = width - ansis.strip(text).length + 1;
35
10
  let final = " ".repeat(newWidth / 2) + text;
36
11
  return final;
37
12
  }
38
13
  /**A utility function to terminate the interactive CLI. */
39
- async function terminate(opts) {
40
- terminal_kit_1.terminal.grabInput(false);
41
- terminal_kit_1.terminal.clear();
42
- terminal_kit_1.terminal.green("👋 Exited the " + opts.projectName + " Interactive Setup CLI.\n");
14
+ export async function terminate(opts) {
15
+ terminal.grabInput(false);
16
+ terminal.clear();
17
+ terminal.green("👋 Exited the " + opts.projectName + " Interactive Setup CLI.\n");
43
18
  process.exit(0);
44
19
  }
45
20
  /**A utility function generate a unique config ID based on a user-named input. */
46
- function generateUniqueIdFromName(name) {
21
+ export function generateUniqueIdFromName(name) {
47
22
  //id only allows a-z, 0-9 & dash characters (& replace spaces with dashes)
48
23
  const filteredChars = name.toLowerCase().replaceAll(" ", "-").split("").filter((ch) => /^[a-zA-Z0-9-]{1}$/.test(ch));
49
- const randomSuffix = "-" + crypto_1.default.randomBytes(4).toString("hex");
24
+ const randomSuffix = "-" + crypto.randomBytes(4).toString("hex");
50
25
  return filteredChars.join("") + randomSuffix;
51
26
  }
52
27
  /**Render the header of the interactive setup CLI. */
53
- function renderHeader(opts, path) {
54
- terminal_kit_1.terminal.grabInput(true);
55
- terminal_kit_1.terminal.clear().moveTo(1, 1);
56
- (0, terminal_kit_1.terminal)(ansis_1.default.hex("#f8ba00")(opts.logo.join("\n") + "\n"));
57
- terminal_kit_1.terminal.bold(centerText("Interactive Setup CLI - Version: " + opts.projectVersion.toString() + " - Support: https://discord.dj-dj.be\n", 88));
28
+ export function renderHeader(opts, path) {
29
+ terminal.grabInput(true);
30
+ terminal.clear().moveTo(1, 1);
31
+ terminal(ansis.hex("#f8ba00")(opts.logo.join("\n") + "\n"));
32
+ terminal.bold(centerText("Interactive Setup CLI - Version: " + opts.projectVersion.toString() + " - Support: https://discord.dj-dj.be\n", 88));
58
33
  if (typeof path == "string")
59
- terminal_kit_1.terminal.cyan(centerText(path + "\n\n", 88));
34
+ terminal.cyan(centerText(path + "\n\n", 88));
60
35
  else if (path.length < 1)
61
- terminal_kit_1.terminal.cyan(centerText("👋 Hi! Welcome to the " + opts.projectName + " Interactive Setup CLI! 👋\n\n", 88));
36
+ terminal.cyan(centerText("👋 Hi! Welcome to the " + opts.projectName + " Interactive Setup CLI! 👋\n\n", 88));
62
37
  else
63
- terminal_kit_1.terminal.cyan(centerText("🌐 Current Location: " + path.map((v, i) => {
38
+ terminal.cyan(centerText("🌐 Current Location: " + path.map((v, i) => {
64
39
  if (i == 0)
65
40
  return v.toString();
66
41
  else if (typeof v == "string")
@@ -72,15 +47,15 @@ function renderHeader(opts, path) {
72
47
  /**Render the mode selector for the interactive setup CLI */
73
48
  async function renderCliModeSelector(opts, backFn, renderEditConfig, renderQuickSetup) {
74
49
  renderHeader(opts, []);
75
- (0, terminal_kit_1.terminal)(ansis_1.default.bold.green("Please select what CLI module you want to use.\n") + ansis_1.default.italic.gray("(use arrow keys to navigate, exit using escape)\n"));
76
- const answer = await terminal_kit_1.terminal.singleColumnMenu([
77
- "✏️ Edit Config " + ansis_1.default.gray("=> Edit the current config, add/remove settings & more!"),
78
- "⏱️ Quick Setup " + ansis_1.default.gray("=> A quick and easy way of setting up the bot in your Discord server."),
50
+ terminal(ansis.bold.green("Please select what CLI module you want to use.\n") + ansis.italic.gray("(use arrow keys to navigate, exit using escape)\n"));
51
+ const answer = await terminal.singleColumnMenu([
52
+ "✏️ Edit Config " + ansis.gray("=> Edit the current config, add/remove settings & more!"),
53
+ "⏱️ Quick Setup " + ansis.gray("=> A quick and easy way of setting up the bot in your Discord server."),
79
54
  ], {
80
55
  leftPadding: "> ",
81
- style: terminal_kit_1.terminal.cyan,
82
- selectedStyle: terminal_kit_1.terminal.bgDefaultColor.bold,
83
- submittedStyle: terminal_kit_1.terminal.bgBlue,
56
+ style: terminal.cyan,
57
+ selectedStyle: terminal.bgDefaultColor.bold,
58
+ submittedStyle: terminal.bgBlue,
84
59
  extraLines: 2,
85
60
  cancelable: true
86
61
  }).promise;
@@ -94,26 +69,26 @@ async function renderCliModeSelector(opts, backFn, renderEditConfig, renderQuick
94
69
  return await backFn();
95
70
  }
96
71
  /**Execute/start the Interactive Setup CLI. Make sure no other processes disturb the flow. */
97
- async function execute(opts, renderEditConfig, renderQuickSetup) {
98
- terminal_kit_1.terminal.on("key", (name) => {
72
+ export async function execute(opts, renderEditConfig, renderQuickSetup) {
73
+ terminal.on("key", (name) => {
99
74
  if (name == "CTRL_C")
100
75
  terminate(opts);
101
76
  });
102
- if (terminal_kit_1.terminal.width < 100 || terminal_kit_1.terminal.height < 35) {
103
- (0, terminal_kit_1.terminal)(ansis_1.default.red.bold("\n\nMake sure your console, terminal or CMD window has a " + ansis_1.default.cyan("minimum width & height") + " of " + ansis_1.default.cyan("100x35") + " characters."));
104
- (0, terminal_kit_1.terminal)(ansis_1.default.red.bold("\nOtherwise the " + opts.projectName + " Interactive Setup CLI will be rendered incorrectly."));
105
- (0, terminal_kit_1.terminal)(ansis_1.default.red.bold("\nThe current terminal dimensions are: " + ansis_1.default.cyan(terminal_kit_1.terminal.width + "x" + terminal_kit_1.terminal.height) + "."));
77
+ if (terminal.width < 100 || terminal.height < 35) {
78
+ terminal(ansis.red.bold("\n\nMake sure your console, terminal or CMD window has a " + ansis.cyan("minimum width & height") + " of " + ansis.cyan("100x35") + " characters."));
79
+ terminal(ansis.red.bold("\nOtherwise the " + opts.projectName + " Interactive Setup CLI will be rendered incorrectly."));
80
+ terminal(ansis.red.bold("\nThe current terminal dimensions are: " + ansis.cyan(terminal.width + "x" + terminal.height) + "."));
106
81
  }
107
82
  else
108
83
  await renderCliModeSelector(opts, async () => { await terminate(opts); }, renderEditConfig, renderQuickSetup);
109
84
  }
110
85
  /**A basic style template for select menu's in the interactive setup CLI. */
111
- exports.autoCompleteMenuOpts = {
112
- style: terminal_kit_1.terminal.white,
113
- selectedStyle: terminal_kit_1.terminal.bgBlue.white
86
+ export const autoCompleteMenuOpts = {
87
+ style: terminal.white,
88
+ selectedStyle: terminal.bgBlue.white
114
89
  };
115
90
  /**A set of preset colors to be used when auto-filling colors in the interactive setup CLI. */
116
- exports.presetColors = new Map([
91
+ export const presetColors = new Map([
117
92
  ["dark red", "#992d22"],
118
93
  ["red", "#ff0000"],
119
94
  ["light red", "#f06c6c"],
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { loadDumpCommand } from "./startup/dump";
2
- export { loadAllPlugins } from "./startup/pluginLauncher";
3
- export { frameworkStartup } from "./startup/compilation";
4
- export { loadErrorHandling } from "./startup/errorHandling";
1
+ export { loadDumpCommand } from "./startup/dump.js";
2
+ export { loadAllPlugins } from "./startup/pluginLauncher.js";
3
+ export { frameworkStartup } from "./startup/compilation.js";
4
+ export { loadErrorHandling } from "./startup/errorHandling.js";
package/dist/index.js CHANGED
@@ -1,14 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadErrorHandling = exports.frameworkStartup = exports.loadAllPlugins = exports.loadDumpCommand = void 0;
4
- var dump_1 = require("./startup/dump");
5
- Object.defineProperty(exports, "loadDumpCommand", { enumerable: true, get: function () { return dump_1.loadDumpCommand; } });
6
- var pluginLauncher_1 = require("./startup/pluginLauncher");
7
- Object.defineProperty(exports, "loadAllPlugins", { enumerable: true, get: function () { return pluginLauncher_1.loadAllPlugins; } });
8
- var compilation_1 = require("./startup/compilation");
9
- Object.defineProperty(exports, "frameworkStartup", { enumerable: true, get: function () { return compilation_1.frameworkStartup; } });
10
- var errorHandling_1 = require("./startup/errorHandling");
11
- Object.defineProperty(exports, "loadErrorHandling", { enumerable: true, get: function () { return errorHandling_1.loadErrorHandling; } });
12
- const compilation_2 = require("./startup/compilation");
1
+ export { loadDumpCommand } from "./startup/dump.js";
2
+ export { loadAllPlugins } from "./startup/pluginLauncher.js";
3
+ export { frameworkStartup } from "./startup/compilation.js";
4
+ export { loadErrorHandling } from "./startup/errorHandling.js";
5
+ import { checkFrameworkAllowed } from "./startup/compilation.js";
13
6
  //check directory structure
14
- (0, compilation_2.checkFrameworkAllowed)();
7
+ checkFrameworkAllowed();
@@ -1,3 +1,3 @@
1
- import type { ODProjectType } from "../api";
1
+ import type { ODProjectType } from "../api/index.js";
2
2
  export declare function checkFrameworkAllowed(project?: ODProjectType): void;
3
3
  export declare function frameworkStartup(startupFlags: string[], project: ODProjectType, startCallback: () => void): void;
@@ -1,15 +1,8 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.checkFrameworkAllowed = checkFrameworkAllowed;
7
- exports.frameworkStartup = frameworkStartup;
8
- const fs_1 = __importDefault(require("fs"));
9
- const typescript_1 = __importDefault(require("typescript"));
10
- const crypto_1 = require("crypto");
11
- const path_1 = __importDefault(require("path"));
12
- const ansis_1 = __importDefault(require("ansis"));
1
+ import fs from "fs";
2
+ import ts from "typescript";
3
+ import { createHash } from "crypto";
4
+ import nodepath from "path";
5
+ import ansis from "ansis";
13
6
  /** ## What is this?
14
7
  * This is a function which compares `./src/` with a hash stored in `./dist/hash.txt`.
15
8
  * The hash is based on the modified date & file metadata of all files in `./src/`.
@@ -18,12 +11,12 @@ const ansis_1 = __importDefault(require("ansis"));
18
11
  * This will help you save CPU resources because the bot shouldn't re-compile when nothing has been changed :)
19
12
  */
20
13
  function computeSourceHash(dir, upperHash) {
21
- const hash = upperHash ? upperHash : (0, crypto_1.createHash)("sha256");
22
- const info = fs_1.default.readdirSync(dir, { withFileTypes: true });
14
+ const hash = upperHash ? upperHash : createHash("sha256");
15
+ const info = fs.readdirSync(dir, { withFileTypes: true });
23
16
  for (const file of info) {
24
- const fullPath = path_1.default.join(dir, file.name);
17
+ const fullPath = nodepath.join(dir, file.name);
25
18
  if (file.isFile() && [".js", ".ts", ".jsx", ".tsx"].some((ext) => file.name.endsWith(ext))) {
26
- const statInfo = fs_1.default.statSync(fullPath);
19
+ const statInfo = fs.statSync(fullPath);
27
20
  //compute hash using file metadata
28
21
  const fileInfo = `${fullPath}:${statInfo.size}:${statInfo.mtimeMs}`;
29
22
  hash.update(fileInfo);
@@ -47,8 +40,8 @@ function requiresCompilation(project) {
47
40
  const sourceHash = computeSourceHash("./src/");
48
41
  const pluginHash = computeSourceHash("./plugins/");
49
42
  const hash = sourceHash + ":" + pluginHash;
50
- if (fs_1.default.existsSync("./dist/hash.txt")) {
51
- const distHash = fs_1.default.readFileSync("./dist/hash.txt").toString();
43
+ if (fs.existsSync("./dist/hash.txt")) {
44
+ const distHash = fs.readFileSync("./dist/hash.txt").toString();
52
45
  if (distHash === hash)
53
46
  return false;
54
47
  else
@@ -61,9 +54,9 @@ function saveNewCompilationHash() {
61
54
  const sourceHash = computeSourceHash("./src/");
62
55
  const pluginHash = computeSourceHash("./plugins/");
63
56
  const hash = sourceHash + ":" + pluginHash;
64
- fs_1.default.writeFileSync("./dist/hash.txt", hash);
57
+ fs.writeFileSync("./dist/hash.txt", hash);
65
58
  }
66
- function checkFrameworkAllowed(project) {
59
+ export function checkFrameworkAllowed(project) {
67
60
  const logTitle = (project) ? ((project == "openticket") ? "OT" : "OM") : "OD";
68
61
  const requiredStructures = [
69
62
  "index.js",
@@ -78,11 +71,11 @@ function checkFrameworkAllowed(project) {
78
71
  "./plugins/",
79
72
  ];
80
73
  for (const path of requiredStructures) {
81
- if (!fs_1.default.existsSync(path))
74
+ if (!fs.existsSync(path))
82
75
  throw new Error(logTitle + ": Project uses invalid structure for Open Discord! (missing: " + path + ")");
83
76
  }
84
- const licenseContents = fs_1.default.readFileSync("./LICENSE.md").toString();
85
- const readmeContents = fs_1.default.readFileSync("./README.md").toString();
77
+ const licenseContents = fs.readFileSync("./LICENSE.md").toString();
78
+ const readmeContents = fs.readFileSync("./README.md").toString();
86
79
  if (!licenseContents.includes("DJj123dj & Contributors") ||
87
80
  !licenseContents.includes("GNU GENERAL PUBLIC LICENSE") ||
88
81
  !licenseContents.includes("DJdj Development. <https://www.dj-dj.be/>") ||
@@ -94,7 +87,7 @@ function checkFrameworkAllowed(project) {
94
87
  if (!readmeContents.includes("DJdj Development") || !readmeContents.includes("DJj123dj"))
95
88
  throw new Error(logTitle + ": Please do not use this framework in third party bots or outside Open Ticket/Moderation! (3)");
96
89
  }
97
- function frameworkStartup(startupFlags, project, startCallback) {
90
+ export function frameworkStartup(startupFlags, project, startCallback) {
98
91
  const logTitle = (project == "openticket") ? "OT" : "OM";
99
92
  //push additional startup flags (for pterodactyl panels)
100
93
  process.argv.push(...startupFlags);
@@ -103,18 +96,18 @@ function frameworkStartup(startupFlags, project, startCallback) {
103
96
  //start compilation
104
97
  if (!process.argv.includes("--no-compile")) {
105
98
  const requiredDependencies = new Set();
106
- if (fs_1.default.existsSync("./plugins")) {
99
+ if (fs.existsSync("./plugins")) {
107
100
  console.log(logTitle + ": Reading plugin.json files...");
108
- for (const pluginDir of fs_1.default.readdirSync("./plugins")) {
101
+ for (const pluginDir of fs.readdirSync("./plugins")) {
109
102
  if (pluginDir === ".DS_Store")
110
103
  continue;
111
- const pluginPath = path_1.default.join("./plugins", pluginDir);
112
- if (!fs_1.default.statSync(pluginPath).isDirectory())
104
+ const pluginPath = nodepath.join("./plugins", pluginDir);
105
+ if (!fs.statSync(pluginPath).isDirectory())
113
106
  continue;
114
- const pluginJsonPath = path_1.default.join(pluginPath, "plugin.json");
115
- if (fs_1.default.existsSync(pluginJsonPath)) {
107
+ const pluginJsonPath = nodepath.join(pluginPath, "plugin.json");
108
+ if (fs.existsSync(pluginJsonPath)) {
116
109
  try {
117
- const pluginData = JSON.parse(fs_1.default.readFileSync(pluginJsonPath).toString());
110
+ const pluginData = JSON.parse(fs.readFileSync(pluginJsonPath).toString());
118
111
  if (pluginData.npmDependencies && Array.isArray(pluginData.npmDependencies)) {
119
112
  pluginData.npmDependencies.forEach((dep) => {
120
113
  if (typeof dep === "string" && dep.trim()) {
@@ -140,8 +133,8 @@ function frameworkStartup(startupFlags, project, startCallback) {
140
133
  }
141
134
  }
142
135
  if (missingDeps.length > 0) {
143
- console.log(ansis_1.default.red(logTitle + ": ❌ Fatal Error --> Missing npm dependencies required by plugins:\n\n") + ansis_1.default.cyan(missingDeps.map((dep) => " - " + dep).join("\n") + "\n"));
144
- console.log(logTitle + ": Please install missing dependencies using the following command:\n> " + ansis_1.default.bold.green("npm install " + missingDeps.join(" ")) + "\n");
136
+ console.log(ansis.red(logTitle + ": ❌ Fatal Error --> Missing npm dependencies required by plugins:\n\n") + ansis.cyan(missingDeps.map((dep) => " - " + dep).join("\n") + "\n"));
137
+ console.log(logTitle + ": Please install missing dependencies using the following command:\n> " + ansis.bold.green("npm install " + missingDeps.join(" ")) + "\n");
145
138
  process.exit(1);
146
139
  }
147
140
  }
@@ -150,31 +143,31 @@ function frameworkStartup(startupFlags, project, startCallback) {
150
143
  console.log(logTitle + ": Compilation Required...");
151
144
  //REMOVE EXISTING BUILDS
152
145
  console.log(logTitle + ": Removing Prebuilds...");
153
- fs_1.default.rmSync("./dist", { recursive: true, force: true });
146
+ fs.rmSync("./dist", { recursive: true, force: true });
154
147
  //COMPILE TYPESCRIPT
155
148
  console.log(logTitle + ": Compiling Typescript...");
156
- const configPath = path_1.default.resolve('./tsconfig.json');
157
- const configFile = typescript_1.default.readConfigFile(configPath, typescript_1.default.sys.readFile);
149
+ const configPath = nodepath.resolve('./tsconfig.json');
150
+ const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
158
151
  //check for tsconfig errors
159
152
  if (configFile.error) {
160
- const message = typescript_1.default.formatDiagnosticsWithColorAndContext([configFile.error], typescript_1.default.createCompilerHost({}));
153
+ const message = ts.formatDiagnosticsWithColorAndContext([configFile.error], ts.createCompilerHost({}));
161
154
  console.error(message);
162
155
  process.exit(1);
163
156
  }
164
157
  //parse tsconfig file
165
- const parsedConfig = typescript_1.default.parseJsonConfigFileContent(configFile.config, typescript_1.default.sys, path_1.default.dirname(configPath));
158
+ const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, nodepath.dirname(configPath));
166
159
  //create program/compiler
167
- const program = typescript_1.default.createProgram({
160
+ const program = ts.createProgram({
168
161
  rootNames: parsedConfig.fileNames,
169
162
  options: parsedConfig.options
170
163
  });
171
164
  //emit all compiled files
172
165
  const emitResult = program.emit();
173
166
  //print emit errors/warnings (type errors)
174
- const allDiagnostics = typescript_1.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
175
- const formattedDiagnostics = typescript_1.default.formatDiagnosticsWithColorAndContext(allDiagnostics, typescript_1.default.createCompilerHost(parsedConfig.options));
167
+ const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
168
+ const formattedDiagnostics = ts.formatDiagnosticsWithColorAndContext(allDiagnostics, ts.createCompilerHost(parsedConfig.options));
176
169
  console.log(formattedDiagnostics);
177
- if (emitResult.emitSkipped || allDiagnostics.find((d) => d.category == typescript_1.default.DiagnosticCategory.Error || d.category == typescript_1.default.DiagnosticCategory.Warning)) {
170
+ if (emitResult.emitSkipped || allDiagnostics.find((d) => d.category == ts.DiagnosticCategory.Error || d.category == ts.DiagnosticCategory.Warning)) {
178
171
  console.log(logTitle + ": Compilation Failed!");
179
172
  process.exit(1);
180
173
  }
@@ -1,4 +1,4 @@
1
- import * as api from "../api/index";
1
+ import * as api from "../api/index.js";
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.
@@ -1,42 +1,6 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.loadDumpCommand = void 0;
37
- const api = __importStar(require("../api/index"));
38
- const discord = __importStar(require("discord.js"));
39
- const fs = __importStar(require("fs"));
1
+ import * as api from "../api/index.js";
2
+ import * as discord from "discord.js";
3
+ import * as fs from "fs";
40
4
  /** ### What is this?
41
5
  * This is the `!OPENTICKET:dump` command.
42
6
  * It's a utility command which can only be used by the creator of Open Discord/Ticket/Moderation or the owner of the bot.
@@ -49,7 +13,7 @@ const fs = __importStar(require("fs"));
49
13
  * ### Can I disable it?
50
14
  * If you want to turn it off, you turn off the fuse using `opendiscord.sharedFuses.setFuse("allowDumpCommand",false)`
51
15
  */
52
- const loadDumpCommand = (opendiscord) => {
16
+ export const loadDumpCommand = (opendiscord) => {
53
17
  if (!opendiscord.sharedFuses.getFuse("allowDumpCommand"))
54
18
  return;
55
19
  opendiscord.client.textCommands.add(new api.ODTextCommand("opendiscord:dump", {
@@ -76,4 +40,3 @@ const loadDumpCommand = (opendiscord) => {
76
40
  }
77
41
  });
78
42
  };
79
- exports.loadDumpCommand = loadDumpCommand;
@@ -1,2 +1,2 @@
1
- import * as api from "../api/index";
1
+ import * as api from "../api/index.js";
2
2
  export declare function loadErrorHandling(opendiscord: api.ODMain, project: api.ODProjectType): void;
@@ -1,41 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.loadErrorHandling = loadErrorHandling;
37
- const api = __importStar(require("../api/index"));
38
- function loadErrorHandling(opendiscord, project) {
1
+ import * as api from "../api/index.js";
2
+ export function loadErrorHandling(opendiscord, project) {
39
3
  process.on("uncaughtException", async (error, origin) => {
40
4
  try {
41
5
  const beforeEvent = opendiscord.events.get("onErrorHandling");
@@ -1,2 +1,2 @@
1
- import * as api from "../api/index";
1
+ import * as api from "../api/index.js";
2
2
  export declare const loadAllPlugins: (opendiscord: api.ODMain) => Promise<void>;
@@ -1,73 +1,36 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.loadAllPlugins = void 0;
40
- const api = __importStar(require("../api/index"));
41
- const fs_1 = __importDefault(require("fs"));
42
- const loadAllPlugins = async (opendiscord) => {
1
+ import * as api from "../api/index.js";
2
+ import fs from "fs";
3
+ export const loadAllPlugins = async (opendiscord) => {
43
4
  //start launching plugins
44
5
  opendiscord.log("Loading plugins...", "system");
45
6
  let initPluginError = false;
46
- if (!fs_1.default.existsSync("./plugins")) {
7
+ if (!fs.existsSync("./plugins")) {
47
8
  opendiscord.log("Couldn't find ./plugins directory, canceling all plugin execution!", "error");
48
9
  return;
49
10
  }
50
- const plugins = fs_1.default.readdirSync("./plugins");
11
+ const plugins = fs.readdirSync("./plugins");
51
12
  const pluginVersionRegex = /^(OT|OM)v(\d+)\.(\d+|x)\.(\d+|x)$/;
52
13
  //check & validate
53
14
  for (const p of plugins) {
54
15
  //prechecks
55
16
  if (p === ".DS_Store")
56
- return; //ignore MacOS DS_Store file
57
- if (!fs_1.default.statSync("./plugins/" + p).isDirectory())
58
- return opendiscord.log("Plugin is not a directory, canceling plugin execution...", "plugin", [
17
+ continue; //ignore MacOS DS_Store file
18
+ if (!fs.statSync("./plugins/" + p).isDirectory()) {
19
+ opendiscord.log("Plugin is not a directory, canceling plugin execution...", "plugin", [
59
20
  { key: "plugin", value: "./plugins/" + p }
60
21
  ]);
61
- if (!fs_1.default.existsSync("./plugins/" + p + "/plugin.json")) {
22
+ continue;
23
+ }
24
+ if (!fs.existsSync("./plugins/" + p + "/plugin.json")) {
62
25
  initPluginError = true;
63
26
  opendiscord.log("Plugin doesn't have a plugin.json, canceling plugin execution...", "plugin", [
64
27
  { key: "plugin", value: "./plugins/" + p }
65
28
  ]);
66
- return;
29
+ continue;
67
30
  }
68
31
  //plugin loading
69
32
  try {
70
- const rawplugindata = JSON.parse(fs_1.default.readFileSync("./plugins/" + p + "/plugin.json").toString());
33
+ const rawplugindata = JSON.parse(fs.readFileSync("./plugins/" + p + "/plugin.json").toString());
71
34
  if (typeof rawplugindata != "object")
72
35
  throw new api.ODPluginError("Failed to load plugin.json");
73
36
  if (typeof rawplugindata.id != "string")
@@ -139,7 +102,7 @@ const loadAllPlugins = async (opendiscord) => {
139
102
  opendiscord.debugfile.writeText(e.stack);
140
103
  //try to get some crashed plugin data
141
104
  try {
142
- const rawplugindata = JSON.parse(fs_1.default.readFileSync("./plugins/" + p + "/plugin.json").toString());
105
+ const rawplugindata = JSON.parse(fs.readFileSync("./plugins/" + p + "/plugin.json").toString());
143
106
  opendiscord.plugins.unknownCrashedPlugins.push({
144
107
  name: rawplugindata.name ?? "./plugins/" + p,
145
108
  description: (rawplugindata.details && rawplugindata.details.shortDescription) ? rawplugindata.details.shortDescription : "This plugin crashed :(",
@@ -296,4 +259,3 @@ const loadAllPlugins = async (opendiscord) => {
296
259
  }
297
260
  }
298
261
  };
299
- exports.loadAllPlugins = loadAllPlugins;
@@ -1,4 +1,4 @@
1
- import * as api from "../api/index";
1
+ import * as api from "../api/index.js";
2
2
  /**## sharedFuses `utility variable`
3
3
  * All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
4
4
  */
@@ -38,7 +38,7 @@ export declare function timedAwait<ReturnValue>(promise: ReturnValue, timeout: n
38
38
  /**## dateString `utility function`
39
39
  * Use this function to create a short date string in the following format: `DD/MM/YYYY HH:MM:SS`
40
40
  */
41
- export declare function dateString(date: any): string;
41
+ export declare function dateString(date: Date): string;
42
42
  /**## asyncReplace `utility function`
43
43
  * Same as `string.replace(search, value)` but with async compatibility
44
44
  */
@@ -54,7 +54,7 @@ export declare function ordinalNumber(num: number): string;
54
54
  /**## trimEmojis `utility function`
55
55
  * Trim/remove all emoji's from a Javascript string.
56
56
  */
57
- export declare function trimEmojis(text: any): any;
57
+ export declare function trimEmojis(text: string): string;
58
58
  /**## easterEggs `utility object`
59
59
  * Object containing data for Open Ticket easter eggs.
60
60
  */