@open-discord-bots/framework 0.2.17 → 0.3.0

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 (49) hide show
  1. package/dist/api/index.d.ts +16 -15
  2. package/dist/api/index.js +16 -15
  3. package/dist/api/main.d.ts +31 -23
  4. package/dist/api/main.js +3 -1
  5. package/dist/api/modules/action.d.ts +2 -2
  6. package/dist/api/modules/action.js +1 -5
  7. package/dist/api/modules/base.d.ts +2 -2
  8. package/dist/api/modules/builder.d.ts +2 -2
  9. package/dist/api/modules/builder.js +0 -4
  10. package/dist/api/modules/checker.d.ts +2 -2
  11. package/dist/api/modules/checker.js +2 -6
  12. package/dist/api/modules/component.d.ts +922 -0
  13. package/dist/api/modules/component.js +1344 -0
  14. package/dist/api/modules/config.d.ts +30 -1
  15. package/dist/api/modules/config.js +81 -0
  16. package/dist/api/modules/cooldown.d.ts +5 -5
  17. package/dist/api/modules/cooldown.js +1 -17
  18. package/dist/api/modules/database.d.ts +21 -13
  19. package/dist/api/modules/database.js +0 -23
  20. package/dist/api/modules/helpmenu.d.ts +9 -7
  21. package/dist/api/modules/helpmenu.js +22 -17
  22. package/dist/api/modules/language.d.ts +2 -2
  23. package/dist/api/modules/language.js +3 -7
  24. package/dist/api/modules/progressbar.d.ts +2 -1
  25. package/dist/api/modules/progressbar.js +1 -1
  26. package/dist/api/modules/responder.d.ts +2 -2
  27. package/dist/api/modules/responder.js +0 -4
  28. package/dist/api/modules/session.d.ts +1 -1
  29. package/dist/api/modules/session.js +1 -1
  30. package/dist/api/modules/startscreen.d.ts +2 -2
  31. package/dist/api/modules/startscreen.js +5 -3
  32. package/package.json +3 -2
  33. package/src/api/index.ts +16 -15
  34. package/src/api/main.ts +33 -24
  35. package/src/api/modules/action.ts +2 -4
  36. package/src/api/modules/base.ts +2 -2
  37. package/src/api/modules/builder.ts +2 -4
  38. package/src/api/modules/checker.ts +5 -6
  39. package/src/api/modules/component.ts +1822 -0
  40. package/src/api/modules/config.ts +78 -1
  41. package/src/api/modules/cooldown.ts +8 -13
  42. package/src/api/modules/database.ts +24 -32
  43. package/src/api/modules/helpmenu.ts +29 -22
  44. package/src/api/modules/language.ts +5 -7
  45. package/src/api/modules/progressbar.ts +2 -3
  46. package/src/api/modules/responder.ts +2 -4
  47. package/src/api/modules/session.ts +1 -1
  48. package/src/api/modules/startscreen.ts +6 -4
  49. package/src/api/modules/component.txt +0 -350
@@ -1,26 +1,27 @@
1
1
  export * from "./main.js";
2
+ export * from "./modules/action.js";
2
3
  export * from "./modules/base.js";
3
- export * from "./modules/event.js";
4
+ export * from "./modules/builder.js";
5
+ export * from "./modules/checker.js";
6
+ export * from "./modules/client.js";
7
+ export * from "./modules/code.js";
8
+ export * from "./modules/component.js";
4
9
  export * from "./modules/config.js";
10
+ export * from "./modules/console.js";
11
+ export * from "./modules/cooldown.js";
5
12
  export * from "./modules/database.js";
6
- export * from "./modules/language.js";
13
+ export * from "./modules/event.js";
7
14
  export * from "./modules/flag.js";
8
- export * from "./modules/console.js";
9
15
  export * from "./modules/fuse.js";
16
+ export * from "./modules/helpmenu.js";
17
+ export * from "./modules/language.js";
18
+ export * from "./modules/permission.js";
10
19
  export * from "./modules/plugin.js";
11
- export * from "./modules/checker.js";
12
- export * from "./modules/client.js";
13
- export * from "./modules/worker.js";
14
- export * from "./modules/builder.js";
20
+ export * from "./modules/post.js";
21
+ export * from "./modules/progressbar.js";
15
22
  export * from "./modules/responder.js";
16
- export * from "./modules/action.js";
17
- export * from "./modules/permission.js";
18
- export * from "./modules/helpmenu.js";
19
23
  export * from "./modules/session.js";
24
+ export * from "./modules/startscreen.js";
20
25
  export * from "./modules/statistic.js";
21
- export * from "./modules/code.js";
22
- export * from "./modules/cooldown.js";
23
- export * from "./modules/post.js";
24
26
  export * from "./modules/verifybar.js";
25
- export * from "./modules/progressbar.js";
26
- export * from "./modules/startscreen.js";
27
+ export * from "./modules/worker.js";
package/dist/api/index.js CHANGED
@@ -1,28 +1,29 @@
1
1
  //MAIN MODULE
2
2
  export * from "./main.js";
3
3
  //BASE MODULES
4
+ export * from "./modules/action.js";
4
5
  export * from "./modules/base.js";
5
- export * from "./modules/event.js";
6
+ export * from "./modules/builder.js";
7
+ export * from "./modules/checker.js";
8
+ export * from "./modules/client.js";
9
+ export * from "./modules/code.js";
10
+ export * from "./modules/component.js";
6
11
  export * from "./modules/config.js";
12
+ export * from "./modules/console.js";
13
+ export * from "./modules/cooldown.js";
7
14
  export * from "./modules/database.js";
8
- export * from "./modules/language.js";
15
+ export * from "./modules/event.js";
9
16
  export * from "./modules/flag.js";
10
- export * from "./modules/console.js";
11
17
  export * from "./modules/fuse.js";
18
+ export * from "./modules/helpmenu.js";
19
+ export * from "./modules/language.js";
20
+ export * from "./modules/permission.js";
12
21
  export * from "./modules/plugin.js";
13
- export * from "./modules/checker.js";
14
- export * from "./modules/client.js";
15
- export * from "./modules/worker.js";
16
- export * from "./modules/builder.js";
22
+ export * from "./modules/post.js";
23
+ export * from "./modules/progressbar.js";
17
24
  export * from "./modules/responder.js";
18
- export * from "./modules/action.js";
19
- export * from "./modules/permission.js";
20
- export * from "./modules/helpmenu.js";
21
25
  export * from "./modules/session.js";
26
+ export * from "./modules/startscreen.js";
22
27
  export * from "./modules/statistic.js";
23
- export * from "./modules/code.js";
24
- export * from "./modules/cooldown.js";
25
- export * from "./modules/post.js";
26
28
  export * from "./modules/verifybar.js";
27
- export * from "./modules/progressbar.js";
28
- export * from "./modules/startscreen.js";
29
+ export * from "./modules/worker.js";
@@ -22,11 +22,12 @@ import { ODPostManager } from "./modules/post.js";
22
22
  import { ODClientManager } from "./modules/client.js";
23
23
  import { ODSharedFuseManager } from "./modules/fuse.js";
24
24
  import { ODStartScreenManager } from "./modules/startscreen.js";
25
+ import { ODComponentManager } from "./modules/component.js";
25
26
  /**## ODMainManagers `interface`
26
27
  * The global properties for the main class of the bot.
27
28
  */
28
29
  export interface ODMainManagers {
29
- /**The manager that handles all versions in the bot. */
30
+ /**A collection of versions of the bot, systems, frameworks & services. */
30
31
  versions: ODVersionManager;
31
32
  /**The timestamp that the (node.js) process of the bot started. */
32
33
  processStartupDate: Date;
@@ -44,47 +45,53 @@ export interface ODMainManagers {
44
45
  plugins: ODPluginManager;
45
46
  /**The manager that manages & checks all the console flags of the bot. (like `--debug`) */
46
47
  flags: ODFlagManager;
47
- /**The manager responsible for progress bars in the console. */
48
+ /**The manager responsible for displaying progress bars in the console. */
48
49
  progressbars: ODProgressBarManager;
49
- /**The manager that manages & contains all the config files of the bot. (like `config/general.json`) */
50
+ /**A collection of all the config files of the bot and plugins. (like `config/general.json`) */
50
51
  configs: ODConfigManager;
51
- /**The manager that manages & contains all the databases of the bot. (like `database/global.json`) */
52
+ /**A collection of all the databases of the bot and plugins. (like `database/global.json`) */
52
53
  databases: ODDatabaseManager;
53
- /**The manager that manages all the data sessions of the bot. (it's a temporary database) */
54
+ /**A collection of all the sessions of the bot. (Sessions are temporary objects stored in memory) */
54
55
  sessions: ODSessionManager;
55
- /**The manager that manages all languages & translations of the bot. (but not for plugins) */
56
+ /**The global translation manager which manges all language files, translations & switches between them. (Does not manage translations for plugins) */
56
57
  languages: ODLanguageManager;
57
- /**The manager that handles & executes all config checkers in the bot. (the code that checks if you have something wrong in your config) */
58
+ /**The manager responsible for checking the bot & plugin configs. (it checks for mistakes in your config) */
58
59
  checkers: ODCheckerManager;
59
- /**The manager that manages all builders in the bot. (e.g. buttons, dropdowns, messages, modals, etc) */
60
+ /**A collection of button, dropdown, embed, ... templates which can be used to construct messages and modals.
61
+ * ### (🚨 Better alternative: `opendiscord.components (ODComponentManager)`)
62
+ */
60
63
  builders: ODBuilderManager;
61
- /**The manager that manages all responders in the bot. (e.g. commands, buttons, dropdowns, modals) */
64
+ /**A collection of building blocks and templates for messages & modals with native support for Discord Components v2. (e.g. buttons, dropdowns, checkboxes, radio groups, file uploads, ...)
65
+ * ### (✅ New replacement for: `opendiscord.builders (ODBuilderManager)`)
66
+ */
67
+ components: ODComponentManager;
68
+ /**The manager that handles responses to all interactions of the bot. (e.g. slash/text commands, buttons, dropdowns, modals) */
62
69
  responders: ODResponderManager;
63
- /**The manager that manages all actions or procedures in the bot. (e.g. ticket-creation, ticket-deletion, ticket-claiming, etc) */
70
+ /**A collection of procedures. A procedure is a complex task which can be executed from multiple responders or events. (e.g. ticket-creation, ticket-deletion, ticket-claiming, ...) */
64
71
  actions: ODActionManager;
65
- /**The manager that manages all verify bars in the bot. (the ✅ ❌ buttons) */
72
+ /**A collection of verify bars from the bot. (the ✅ ❌ buttons in messages) */
66
73
  verifybars: ODVerifyBarManager;
67
- /**The manager that contains all permissions for commands & actions in the bot. (use it to check if someone has admin perms or not) */
74
+ /**A manager which will help with calculating permissions for commands & actions. */
68
75
  permissions: ODPermissionManager;
69
- /**The manager that contains all cooldowns of the bot. (e.g. ticket-cooldowns) */
76
+ /**The manager which will manage cooldowns in the bot. (e.g. ticket-create cooldowns) */
70
77
  cooldowns: ODCooldownManager;
71
- /**The manager that manages & renders the Open Discord help menu. (not the embed, but the text) */
78
+ /**The manager that collects & renders the Open Discord help menu contents. (not the final embed) */
72
79
  helpmenu: ODHelpMenuManager;
73
- /**The manager that manages, saves & renders the Open Discord statistics. (not the embed, but the text & database) */
80
+ /**The manager that registers, saves & updates statistics in the database. */
74
81
  statistics: ODStatisticManager;
75
- /**This manager is a place where you can put code that executes when the bot almost finishes the setup. (can be used for less important stuff that doesn't require an exact time-order) */
82
+ /**A place where you can put general-purpose code which will start on startup of the bot. (Perfect for background tasks) */
76
83
  code: ODCodeManager;
77
- /**The manager that manages all posts (static discord channels) in the bot. (e.g. transcripts, logs, etc) */
84
+ /**A collection of static Discord post channels. It allows the bot to find back log, transcript or configured channels based on a linked ID. */
78
85
  posts: ODPostManager;
79
- /**The manager responsible for everything related to the client. (e.g. status, login, slash & text commands, etc) */
86
+ /**A wrapper around the `discord.Client` class. It handles client login, activity and registering text/slash commands. */
80
87
  client: ODClientManager;
81
- /**Shared fuses between Open Discord bots. With these fuses/switches, you can turn off "default behaviours" from the bot. Useful for replacing default behaviour with a custom implementation. */
88
+ /**Shared fuses between Open Discord bots. Turn off "default behaviours" from the bot which is useful for replacing default behaviour with a custom implementation. */
82
89
  sharedFuses: ODSharedFuseManager;
83
- /**This manager manages all the variables in the ENV. It reads from both the `.env` file & the `process.env`. (these 2 will be combined) */
90
+ /**A manager which collects variables from the Process ENV and `.env` file. */
84
91
  env: ODEnvHelper;
85
- /**The manager responsible for the livestatus system. (remote console logs) */
92
+ /**LiveStatus is a protocol which displays live updates from DJdj Development in the startscreen of the bot. (e.g. new version available) */
86
93
  livestatus: ODLiveStatusManager;
87
- /**The manager responsible for the livestatus system. (remote console logs) */
94
+ /**The manager responsible for rendering the startscreen of the bot. */
88
95
  startscreen: ODStartScreenManager;
89
96
  }
90
97
  /**## ODMain `class`
@@ -93,7 +100,7 @@ export interface ODMainManagers {
93
100
  *
94
101
  * This class can't be overwritten or extended & is available as the global variable `opendiscord`!
95
102
  */
96
- export declare class ODMain implements ODMainManagers {
103
+ export declare abstract class ODMain implements ODMainManagers {
97
104
  readonly project: ODProjectType;
98
105
  readonly versions: ODVersionManager;
99
106
  readonly processStartupDate: Date;
@@ -111,6 +118,7 @@ export declare class ODMain implements ODMainManagers {
111
118
  readonly languages: ODLanguageManager;
112
119
  readonly checkers: ODCheckerManager;
113
120
  readonly builders: ODBuilderManager;
121
+ readonly components: ODComponentManager;
114
122
  readonly responders: ODResponderManager;
115
123
  readonly actions: ODActionManager;
116
124
  readonly verifybars: ODVerifyBarManager;
package/dist/api/main.js CHANGED
@@ -25,6 +25,7 @@ export class ODMain {
25
25
  languages;
26
26
  checkers;
27
27
  builders;
28
+ components;
28
29
  responders;
29
30
  actions;
30
31
  verifybars;
@@ -42,7 +43,7 @@ export class ODMain {
42
43
  constructor(managers, project) {
43
44
  this.project = project;
44
45
  this.versions = managers.versions;
45
- this.versions.add(ODVersion.fromString("opendiscord:api", "v0.2.17"));
46
+ this.versions.add(ODVersion.fromString("opendiscord:api", "v0.3.0"));
46
47
  this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
47
48
  this.debugfile = managers.debugfile;
48
49
  this.console = managers.console;
@@ -57,6 +58,7 @@ export class ODMain {
57
58
  this.languages = managers.languages;
58
59
  this.checkers = managers.checkers;
59
60
  this.builders = managers.builders;
61
+ this.components = managers.components;
60
62
  this.client = managers.client;
61
63
  this.responders = managers.responders;
62
64
  this.actions = managers.actions;
@@ -8,12 +8,12 @@ import { ODDebugger } from "./console.js";
8
8
  *
9
9
  * This class can't be used stand-alone & needs to be extended from!
10
10
  */
11
- export declare class ODActionImplementation<Origin extends string, Params extends object, Result extends object, WorkerIds extends string = string> extends ODManagerData {
11
+ export declare abstract class ODActionImplementation<Origin extends string, Params extends object, Result extends object, WorkerIds extends string = string> extends ODManagerData {
12
12
  /**The manager that has all workers of this implementation */
13
13
  workers: ODWorkerManager<Partial<Result>, Origin, Params, WorkerIds>;
14
14
  constructor(id: ODValidId, callback?: ODWorkerCallback<Partial<Result>, Origin, Params>, priority?: number, callbackId?: ODValidId);
15
15
  /**Execute all workers & return the result. */
16
- run(origin: Origin, params: Params): Promise<Partial<Result>>;
16
+ abstract run(origin: Origin, params: Params): Promise<Partial<Result>>;
17
17
  }
18
18
  /**## ODActionManagerIdConstraint `type`
19
19
  * The constraint/layout for id mappings/interfaces of the `ODActionManager` class.
@@ -1,7 +1,7 @@
1
1
  ///////////////////////////////////////
2
2
  //ACTION MODULE
3
3
  ///////////////////////////////////////
4
- import { ODManager, ODSystemError, ODManagerData } from "./base.js";
4
+ import { ODManager, ODManagerData } from "./base.js";
5
5
  import { ODWorkerManager, ODWorker } from "./worker.js";
6
6
  /**## ODActionImplementation `class`
7
7
  * This is an Open Discord action implementation.
@@ -19,10 +19,6 @@ export class ODActionImplementation extends ODManagerData {
19
19
  if (callback)
20
20
  this.workers.add(new ODWorker(callbackId ? callbackId : id, priority ?? 0, callback));
21
21
  }
22
- /**Execute all workers & return the result. */
23
- async run(origin, params) {
24
- throw new ODSystemError("Tried to build an unimplemented ODResponderImplementation");
25
- }
26
22
  }
27
23
  /**## ODActionManager `class`
28
24
  * This is an Open Discord action manager.
@@ -74,7 +74,7 @@ export declare class ODId {
74
74
  * It is used to let the "onChange" event in the `ODManager` class work.
75
75
  * You can use this class when extending your own `ODManager`
76
76
  */
77
- export declare class ODManagerChangeHelper {
77
+ export declare abstract class ODManagerChangeHelper {
78
78
  #private;
79
79
  /**Trigger an `onChange()` event in the parent `ODManager` of this class. */
80
80
  protected _change(): void;
@@ -88,7 +88,7 @@ export declare class ODManagerChangeHelper {
88
88
  *
89
89
  * There is an `id:ODId` property & also some events used in the manager.
90
90
  */
91
- export declare class ODManagerData extends ODManagerChangeHelper {
91
+ export declare abstract class ODManagerData extends ODManagerChangeHelper {
92
92
  /**The id of this data. */
93
93
  id: ODId;
94
94
  constructor(id: ODValidId);
@@ -9,7 +9,7 @@ import { ODDebugger } from "./console.js";
9
9
  *
10
10
  * This class can't be used stand-alone & needs to be extended from!
11
11
  */
12
- export declare class ODBuilderImplementation<Instance, Origin extends string, Params, BuildType extends {
12
+ export declare abstract class ODBuilderImplementation<Instance, Origin extends string, Params, BuildType extends {
13
13
  id: ODId;
14
14
  }, WorkerIds extends string = string> extends ODManagerData {
15
15
  /**The manager that has all workers of this implementation */
@@ -26,7 +26,7 @@ export declare class ODBuilderImplementation<Instance, Origin extends string, Pa
26
26
  /**Reset the current cache */
27
27
  resetCache(): this;
28
28
  /**Execute all workers & return the result. */
29
- build(origin: Origin, params: Params): Promise<BuildType>;
29
+ abstract build(origin: Origin, params: Params): Promise<BuildType>;
30
30
  }
31
31
  /**## ODBuilderManager `class`
32
32
  * This is an Open Discord builder manager.
@@ -38,10 +38,6 @@ export class ODBuilderImplementation extends ODManagerData {
38
38
  this.didCache = false;
39
39
  return this;
40
40
  }
41
- /**Execute all workers & return the result. */
42
- async build(origin, params) {
43
- throw new ODSystemError("Tried to build an unimplemented ODBuilderImplementation");
44
- }
45
41
  }
46
42
  /**## ODBuilderManager `class`
47
43
  * This is an Open Discord builder manager.
@@ -76,9 +76,9 @@ export declare class ODCheckerStorage {
76
76
  *
77
77
  * Use this class to change the config checker looks!
78
78
  */
79
- export declare class ODCheckerRenderer {
79
+ export declare abstract class ODCheckerRenderer {
80
80
  /**Get all config checker render components. These can be combined and rendered to the console. */
81
- getComponents(compact: boolean, renderEmpty: boolean, translation: ODCheckerTranslationRegister<string, string>, data: ODCheckerResult): string[];
81
+ abstract getComponents(compact: boolean, renderEmpty: boolean, translation: ODCheckerTranslationRegister<string, string>, data: ODCheckerResult): string[];
82
82
  /**Render all config checker render components to the console. */
83
83
  render(components: string[]): void;
84
84
  }
@@ -2,7 +2,7 @@
2
2
  //CONFIG CHECKER MODULE
3
3
  ///////////////////////////////////////
4
4
  import { ODId, ODManager, ODManagerData } from "./base.js";
5
- import { ODConfig } from "./config.js";
5
+ import { ODMemoryConfig } from "./config.js";
6
6
  import ansis from "ansis";
7
7
  /**## ODCheckerManager `class`
8
8
  * This is an Open Discord checker manager.
@@ -66,7 +66,7 @@ export class ODCheckerManager extends ODManager {
66
66
  }
67
67
  /**Create temporary and unlisted `ODConfig`, `ODChecker` & `ODCheckerStorage` classes. This will help you use a `ODCheckerStructure` validator without officially registering it in `opendiscord.checkers`. */
68
68
  createTemporaryCheckerEnvironment() {
69
- return new ODChecker("opendiscord:temporary-environment", new ODCheckerStorage(), 0, new ODConfig("opendiscord:temporary-environment", {}), new ODCheckerStructure("opendiscord:temporary-environment", {}));
69
+ return new ODChecker("opendiscord:temporary-environment", new ODCheckerStorage(), 0, new ODMemoryConfig("opendiscord:temporary-environment", {}), new ODCheckerStructure("opendiscord:temporary-environment", {}));
70
70
  }
71
71
  get(id) {
72
72
  return super.get(id);
@@ -139,10 +139,6 @@ export class ODCheckerStorage {
139
139
  * Use this class to change the config checker looks!
140
140
  */
141
141
  export class ODCheckerRenderer {
142
- /**Get all config checker render components. These can be combined and rendered to the console. */
143
- getComponents(compact, renderEmpty, translation, data) {
144
- return [];
145
- }
146
142
  /**Render all config checker render components to the console. */
147
143
  render(components) {
148
144
  if (components.length < 1)