@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,8 +1,8 @@
1
- import { ODManager, ODManagerData, ODValidId } from "./base";
1
+ import { ODManager, ODManagerData, ODValidId } from "./base.js";
2
2
  /**## ODWorkerCallback `type`
3
3
  * This is the callback used in `ODWorker`!
4
4
  */
5
- export type ODWorkerCallback<Instance, Source extends string, Params> = (instance: Instance, params: Params, source: Source, cancel: () => void) => void | Promise<void>;
5
+ export type ODWorkerCallback<Instance, Origin extends string, Params> = (instance: Instance, params: Params, origin: Origin, cancel: () => void) => void | Promise<void>;
6
6
  /**## ODWorker `class`
7
7
  * This is an Open Discord worker.
8
8
  *
@@ -10,15 +10,15 @@ export type ODWorkerCallback<Instance, Source extends string, Params> = (instanc
10
10
  *
11
11
  * - It has an `id` for identification of the function
12
12
  * - A `priority` to know when to execute this callback (related to others)
13
- * - It knows who called this callback (`source`)
13
+ * - It knows who called this callback (`origin`)
14
14
  * - And much more!
15
15
  */
16
- export declare class ODWorker<Instance, Source extends string, Params> extends ODManagerData {
16
+ export declare class ODWorker<Instance, Origin extends string, Params> extends ODManagerData {
17
17
  /**The priority of this worker */
18
18
  priority: number;
19
19
  /**The main callback of this worker */
20
- callback: ODWorkerCallback<Instance, Source, Params>;
21
- constructor(id: ODValidId, priority: number, callback: ODWorkerCallback<Instance, Source, Params>);
20
+ callback: ODWorkerCallback<Instance, Origin, Params>;
21
+ constructor(id: ODValidId, priority: number, callback: ODWorkerCallback<Instance, Origin, Params>);
22
22
  }
23
23
  /**## ODWorker `class`
24
24
  * This is an Open Discord worker manager.
@@ -27,21 +27,21 @@ export declare class ODWorker<Instance, Source extends string, Params> extends O
27
27
  *
28
28
  * You can register a custom worker in this class to create a message or button.
29
29
  */
30
- export declare class ODWorkerManager<Instance, Source extends string, Params, WorkerIds extends string = string> extends ODManager<ODWorker<Instance, Source, Params>> {
30
+ export declare class ODWorkerManager<Instance, Origin extends string, Params, WorkerIds extends string = string> extends ODManager<ODWorker<Instance, Origin, Params>> {
31
31
  #private;
32
32
  /**The backup worker will be executed when one of the workers fails or cancels execution. */
33
33
  backupWorker: ODWorker<{
34
34
  reason: "error" | "cancel";
35
- }, Source, Params> | null;
35
+ }, Origin, Params> | null;
36
36
  constructor(priorityOrder: "ascending" | "descending");
37
37
  /**Get all workers in sorted order. */
38
- getSortedWorkers(priority: "ascending" | "descending"): ODWorker<Instance, Source, Params>[];
39
- /**Execute all workers on an instance using the given source & parameters. */
40
- executeWorkers(instance: Instance, source: Source, params: Params): Promise<void>;
41
- get(id: WorkerIds): ODWorker<Instance, Source, Params>;
42
- get(id: ODValidId): ODWorker<Instance, Source, Params> | null;
43
- remove(id: WorkerIds): ODWorker<Instance, Source, Params>;
44
- remove(id: ODValidId): ODWorker<Instance, Source, Params> | null;
38
+ getSortedWorkers(priority: "ascending" | "descending"): ODWorker<Instance, Origin, Params>[];
39
+ /**Execute all workers on an instance using the given origin & parameters. */
40
+ executeWorkers(instance: Instance, origin: Origin, params: Params): Promise<void>;
41
+ get(id: WorkerIds): ODWorker<Instance, Origin, Params>;
42
+ get(id: ODValidId): ODWorker<Instance, Origin, Params> | null;
43
+ remove(id: WorkerIds): ODWorker<Instance, Origin, Params>;
44
+ remove(id: ODValidId): ODWorker<Instance, Origin, Params> | null;
45
45
  exists(id: WorkerIds): boolean;
46
46
  exists(id: ODValidId): boolean;
47
47
  }
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ODWorkerManager = exports.ODWorker = void 0;
4
1
  ///////////////////////////////////////
5
2
  //WORKER MODULE
6
3
  ///////////////////////////////////////
7
- const base_1 = require("./base");
4
+ import { ODManager, ODManagerData, ODSystemError } from "./base.js";
8
5
  /**## ODWorker `class`
9
6
  * This is an Open Discord worker.
10
7
  *
@@ -12,10 +9,10 @@ const base_1 = require("./base");
12
9
  *
13
10
  * - It has an `id` for identification of the function
14
11
  * - A `priority` to know when to execute this callback (related to others)
15
- * - It knows who called this callback (`source`)
12
+ * - It knows who called this callback (`origin`)
16
13
  * - And much more!
17
14
  */
18
- class ODWorker extends base_1.ODManagerData {
15
+ export class ODWorker extends ODManagerData {
19
16
  /**The priority of this worker */
20
17
  priority;
21
18
  /**The main callback of this worker */
@@ -26,7 +23,6 @@ class ODWorker extends base_1.ODManagerData {
26
23
  this.callback = callback;
27
24
  }
28
25
  }
29
- exports.ODWorker = ODWorker;
30
26
  /**## ODWorker `class`
31
27
  * This is an Open Discord worker manager.
32
28
  *
@@ -34,7 +30,7 @@ exports.ODWorker = ODWorker;
34
30
  *
35
31
  * You can register a custom worker in this class to create a message or button.
36
32
  */
37
- class ODWorkerManager extends base_1.ODManager {
33
+ export class ODWorkerManager extends ODManager {
38
34
  /**The order of execution for workers inside this manager. */
39
35
  #priorityOrder;
40
36
  /**The backup worker will be executed when one of the workers fails or cancels execution. */
@@ -53,8 +49,8 @@ class ODWorkerManager extends base_1.ODManager {
53
49
  return b.priority - a.priority;
54
50
  });
55
51
  }
56
- /**Execute all workers on an instance using the given source & parameters. */
57
- async executeWorkers(instance, source, params) {
52
+ /**Execute all workers on an instance using the given origin & parameters. */
53
+ async executeWorkers(instance, origin, params) {
58
54
  const derefParams = { ...params };
59
55
  const workers = this.getSortedWorkers(this.#priorityOrder);
60
56
  let didCancel = false;
@@ -63,29 +59,29 @@ class ODWorkerManager extends base_1.ODManager {
63
59
  if (didCancel)
64
60
  break;
65
61
  try {
66
- await worker.callback(instance, derefParams, source, () => {
62
+ await worker.callback(instance, derefParams, origin, () => {
67
63
  didCancel = true;
68
64
  });
69
65
  }
70
66
  catch (err) {
71
- process.emit("uncaughtException", err);
67
+ process.emit("uncaughtException", new ODSystemError(err));
72
68
  didCrash = true;
73
69
  }
74
70
  }
75
71
  if (didCancel && this.backupWorker) {
76
72
  try {
77
- await this.backupWorker.callback({ reason: "cancel" }, derefParams, source, () => { });
73
+ await this.backupWorker.callback({ reason: "cancel" }, derefParams, origin, () => { });
78
74
  }
79
75
  catch (err) {
80
- process.emit("uncaughtException", err);
76
+ process.emit("uncaughtException", new ODSystemError(err));
81
77
  }
82
78
  }
83
79
  else if (didCrash && this.backupWorker) {
84
80
  try {
85
- await this.backupWorker.callback({ reason: "error" }, derefParams, source, () => { });
81
+ await this.backupWorker.callback({ reason: "error" }, derefParams, origin, () => { });
86
82
  }
87
83
  catch (err) {
88
- process.emit("uncaughtException", err);
84
+ process.emit("uncaughtException", new ODSystemError(err));
89
85
  }
90
86
  }
91
87
  }
@@ -99,4 +95,3 @@ class ODWorkerManager extends base_1.ODManager {
99
95
  return super.exists(id);
100
96
  }
101
97
  }
102
- exports.ODWorkerManager = ODWorkerManager;
@@ -1,5 +1,5 @@
1
- import * as api from "../api/index";
2
- import { ODCliHeaderOpts } from ".";
1
+ import * as api from "../api/index.js";
2
+ import { ODCliHeaderOpts } from "./index.js";
3
3
  export declare class ODCliEditConfigInstance {
4
4
  private readonly opts;
5
5
  private readonly opendiscord;