@open-discord-bots/framework 0.1.2 → 0.2.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 (76) hide show
  1. package/dist/api/modules/action.d.ts +26 -4
  2. package/dist/api/modules/action.js +16 -0
  3. package/dist/api/modules/base.d.ts +12 -2
  4. package/dist/api/modules/base.js +11 -1
  5. package/dist/api/modules/builder.d.ts +117 -21
  6. package/dist/api/modules/builder.js +72 -0
  7. package/dist/api/modules/checker.d.ts +111 -15
  8. package/dist/api/modules/checker.js +201 -9
  9. package/dist/api/modules/client.d.ts +45 -22
  10. package/dist/api/modules/client.js +58 -34
  11. package/dist/api/modules/code.d.ts +11 -1
  12. package/dist/api/modules/code.js +9 -0
  13. package/dist/api/modules/config.d.ts +15 -5
  14. package/dist/api/modules/config.js +9 -0
  15. package/dist/api/modules/console.d.ts +11 -1
  16. package/dist/api/modules/console.js +9 -0
  17. package/dist/api/modules/cooldown.d.ts +11 -1
  18. package/dist/api/modules/cooldown.js +9 -0
  19. package/dist/api/modules/database.d.ts +36 -4
  20. package/dist/api/modules/database.js +9 -17
  21. package/dist/api/modules/event.d.ts +10 -1
  22. package/dist/api/modules/event.js +6 -0
  23. package/dist/api/modules/flag.d.ts +11 -1
  24. package/dist/api/modules/flag.js +9 -0
  25. package/dist/api/modules/helpmenu.d.ts +22 -2
  26. package/dist/api/modules/helpmenu.js +18 -0
  27. package/dist/api/modules/language.d.ts +15 -1
  28. package/dist/api/modules/language.js +9 -4
  29. package/dist/api/modules/permission.d.ts +11 -1
  30. package/dist/api/modules/permission.js +9 -0
  31. package/dist/api/modules/plugin.d.ts +23 -3
  32. package/dist/api/modules/plugin.js +18 -0
  33. package/dist/api/modules/post.d.ts +11 -1
  34. package/dist/api/modules/post.js +9 -0
  35. package/dist/api/modules/progressbar.d.ts +24 -3
  36. package/dist/api/modules/progressbar.js +19 -0
  37. package/dist/api/modules/responder.d.ts +105 -21
  38. package/dist/api/modules/responder.js +54 -0
  39. package/dist/api/modules/session.d.ts +11 -1
  40. package/dist/api/modules/session.js +9 -0
  41. package/dist/api/modules/startscreen.d.ts +17 -7
  42. package/dist/api/modules/startscreen.js +9 -0
  43. package/dist/api/modules/stat.d.ts +42 -8
  44. package/dist/api/modules/stat.js +18 -4
  45. package/dist/api/modules/verifybar.d.ts +18 -4
  46. package/dist/api/modules/verifybar.js +9 -0
  47. package/dist/api/modules/worker.d.ts +7 -1
  48. package/dist/api/modules/worker.js +9 -0
  49. package/dist/utilities/index.js +1 -0
  50. package/package.json +1 -1
  51. package/src/api/main.ts +10 -10
  52. package/src/api/modules/action.ts +37 -4
  53. package/src/api/modules/base.ts +30 -3
  54. package/src/api/modules/builder.ts +226 -21
  55. package/src/api/modules/checker.ts +292 -17
  56. package/src/api/modules/client.ts +129 -43
  57. package/src/api/modules/code.ts +27 -1
  58. package/src/api/modules/config.ts +33 -7
  59. package/src/api/modules/console.ts +27 -1
  60. package/src/api/modules/cooldown.ts +27 -1
  61. package/src/api/modules/database.ts +55 -4
  62. package/src/api/modules/event.ts +24 -1
  63. package/src/api/modules/flag.ts +27 -1
  64. package/src/api/modules/helpmenu.ts +55 -2
  65. package/src/api/modules/language.ts +35 -1
  66. package/src/api/modules/permission.ts +27 -1
  67. package/src/api/modules/plugin.ts +55 -3
  68. package/src/api/modules/post.ts +27 -1
  69. package/src/api/modules/progressbar.ts +56 -3
  70. package/src/api/modules/responder.ts +184 -21
  71. package/src/api/modules/session.ts +27 -1
  72. package/src/api/modules/startscreen.ts +33 -7
  73. package/src/api/modules/stat.ts +79 -8
  74. package/src/api/modules/verifybar.ts +31 -5
  75. package/src/api/modules/worker.ts +22 -1
  76. package/src/utilities/index.ts +1 -0
@@ -1,6 +1,6 @@
1
1
  import { ODId, ODManager, ODManagerData, ODValidId } from "./base";
2
2
  import { ODDebugger } from "./console";
3
- import { ODDatabase, ODJsonDatabaseStructure } from "./database";
3
+ import { ODDatabase, ODDatabaseIdConstraint, ODJsonDatabaseStructure } from "./database";
4
4
  import * as discord from "discord.js";
5
5
  /**## ODValidStatValue `type`
6
6
  * These are the only allowed types for a stat value to improve compatibility with different database systems.
@@ -16,6 +16,10 @@ export type ODStatsManagerInitCallback = (database: ODJsonDatabaseStructure, del
16
16
  * This type contains all valid methods for changing the value of a stat.
17
17
  */
18
18
  export type ODStatScopeSetMode = "set" | "increase" | "decrease";
19
+ /**## ODStatsManagerIdConstraint `type`
20
+ * The constraint/layout for id mappings/interfaces of the `ODStatsManager` class.
21
+ */
22
+ export type ODStatsManagerIdConstraint = Record<string, ODStatScope>;
19
23
  /**## ODStatsManager `class`
20
24
  * This is an Open Discord stats manager.
21
25
  *
@@ -24,13 +28,13 @@ export type ODStatScopeSetMode = "set" | "increase" | "decrease";
24
28
  *
25
29
  * Stats can be accessed in the individual scopes.
26
30
  */
27
- export declare class ODStatsManager extends ODManager<ODStatScope> {
31
+ export declare class ODStatsManager<IdList extends ODStatsManagerIdConstraint = ODStatsManagerIdConstraint> extends ODManager<ODStatScope> {
28
32
  #private;
29
33
  /**Alias to Open Discord stats database. */
30
- database: ODDatabase | null;
34
+ database: ODDatabase<ODDatabaseIdConstraint> | null;
31
35
  constructor(debug: ODDebugger);
32
36
  /**Select the database to use to read/write all stats from/to. */
33
- useDatabase(database: ODDatabase): void;
37
+ useDatabase(database: ODDatabase<ODDatabaseIdConstraint>): void;
34
38
  add(data: ODStatScope, overwrite?: boolean): boolean;
35
39
  /**Init all stats and run `onInit()` listeners. */
36
40
  init(): Promise<void>;
@@ -38,7 +42,17 @@ export declare class ODStatsManager extends ODManager<ODStatScope> {
38
42
  reset(): Promise<void>;
39
43
  /**Run a function when the stats are initialized. This can be used to clear stats from users that left the server or tickets which don't exist anymore. */
40
44
  onInit(callback: ODStatsManagerInitCallback): void;
45
+ get<StatsId extends keyof IdList>(id: StatsId): IdList[StatsId];
46
+ get(id: ODValidId): ODStatScope | null;
47
+ remove<StatsId extends keyof IdList>(id: StatsId): IdList[StatsId];
48
+ remove(id: ODValidId): ODStatScope | null;
49
+ exists(id: keyof IdList): boolean;
50
+ exists(id: ODValidId): boolean;
41
51
  }
52
+ /**## ODStatScopeIdConstraint `type`
53
+ * The constraint/layout for id mappings/interfaces of the `ODStatScope` class.
54
+ */
55
+ export type ODStatScopeIdConstraint = Record<string, ODStat>;
42
56
  /**## ODStatScope `class`
43
57
  * This is an Open Discord stat scope.
44
58
  *
@@ -47,33 +61,46 @@ export declare class ODStatsManager extends ODManager<ODStatScope> {
47
61
  *
48
62
  * The built-in Open Discord scopes are: `global`, `user`, `ticket`
49
63
  */
50
- export declare class ODStatScope extends ODManager<ODStat> {
64
+ export declare class ODStatScope<IdList extends ODStatScopeIdConstraint = ODStatScopeIdConstraint> extends ODManager<ODStat> {
51
65
  /**The id of this statistics scope. */
52
66
  id: ODId;
53
67
  /**Is this stat scope already initialized? */
54
68
  ready: boolean;
55
69
  /**Alias to Open Discord stats database. */
56
- database: ODDatabase | null;
70
+ database: ODDatabase<ODDatabaseIdConstraint> | null;
57
71
  /**The name of this scope (used in embed title) */
58
72
  name: string;
59
73
  constructor(id: ODValidId, name: string);
60
74
  /**Select the database to use to read/write all stats from/to. (Automatically assigned when used in `ODStatsManager`) */
61
- useDatabase(database: ODDatabase): void;
75
+ useDatabase(database: ODDatabase<ODDatabaseIdConstraint>): void;
62
76
  /**Get the value of a statistic. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
77
+ getStat<StatsId extends keyof IdList>(id: StatsId, scopeId: string): Promise<ODValidStatValue | null>;
63
78
  getStat(id: ODValidId, scopeId: string): Promise<ODValidStatValue | null>;
64
79
  /**Get the value of a statistic for all `scopeId`'s. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
80
+ getAllStats<StatsId extends keyof IdList>(id: StatsId): Promise<{
81
+ id: string;
82
+ value: ODValidStatValue;
83
+ }[]>;
65
84
  getAllStats(id: ODValidId): Promise<{
66
85
  id: string;
67
86
  value: ODValidStatValue;
68
87
  }[]>;
69
88
  /**Set, increase or decrease the value of a statistic. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
89
+ setStat<StatsId extends keyof IdList>(id: StatsId, scopeId: string, value: ODValidStatValue, mode: ODStatScopeSetMode): Promise<boolean>;
70
90
  setStat(id: ODValidId, scopeId: string, value: ODValidStatValue, mode: ODStatScopeSetMode): Promise<boolean>;
71
91
  /**Reset the value of a statistic to the initial value. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
92
+ resetStat<StatsId extends keyof IdList>(id: ODValidId, scopeId: string): Promise<ODValidStatValue | null>;
72
93
  resetStat(id: ODValidId, scopeId: string): Promise<ODValidStatValue | null>;
73
94
  /**Initialize this stat scope & return a list of all statistic ids in the following format: `<scopeid>_<statid>` */
74
95
  init(): string[];
75
96
  /**Render all stats in this scope for usage in a discord message/embed. */
76
97
  render(scopeId: string, guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User): Promise<string>;
98
+ get<StatsId extends keyof IdList>(id: StatsId): IdList[StatsId];
99
+ get(id: ODValidId): ODStat | null;
100
+ remove<StatsId extends keyof IdList>(id: StatsId): IdList[StatsId];
101
+ remove(id: ODValidId): ODStat | null;
102
+ exists(id: keyof IdList): boolean;
103
+ exists(id: ODValidId): boolean;
77
104
  }
78
105
  /**## ODStatGlobalScope `class`
79
106
  * This is an Open Discord stat global scope.
@@ -83,13 +110,20 @@ export declare class ODStatScope extends ODManager<ODStat> {
83
110
  *
84
111
  * This scope is made specifically for the global stats of Open Discord.
85
112
  */
86
- export declare class ODStatGlobalScope extends ODStatScope {
113
+ export declare class ODStatGlobalScope<IdList extends ODStatScopeIdConstraint = ODStatScopeIdConstraint> extends ODStatScope<IdList> {
114
+ getStat<StatsId extends keyof IdList>(id: StatsId): Promise<ODValidStatValue | null>;
87
115
  getStat(id: ODValidId): Promise<ODValidStatValue | null>;
116
+ getAllStats<StatsId extends keyof IdList>(id: StatsId): Promise<{
117
+ id: string;
118
+ value: ODValidStatValue;
119
+ }[]>;
88
120
  getAllStats(id: ODValidId): Promise<{
89
121
  id: string;
90
122
  value: ODValidStatValue;
91
123
  }[]>;
124
+ setStat<StatsId extends keyof IdList>(id: StatsId, value: ODValidStatValue, mode: ODStatScopeSetMode): Promise<boolean>;
92
125
  setStat(id: ODValidId, value: ODValidStatValue, mode: ODStatScopeSetMode): Promise<boolean>;
126
+ resetStat<StatsId extends keyof IdList>(id: ODValidId): Promise<ODValidStatValue | null>;
93
127
  resetStat(id: ODValidId): Promise<ODValidStatValue | null>;
94
128
  render(scopeId: "GLOBAL", guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User): Promise<string>;
95
129
  }
@@ -76,6 +76,15 @@ class ODStatsManager extends base_1.ODManager {
76
76
  onInit(callback) {
77
77
  this.#initListeners.push(callback);
78
78
  }
79
+ get(id) {
80
+ return super.get(id);
81
+ }
82
+ remove(id) {
83
+ return super.remove(id);
84
+ }
85
+ exists(id) {
86
+ return super.exists(id);
87
+ }
79
88
  }
80
89
  exports.ODStatsManager = ODStatsManager;
81
90
  /**## ODStatScope `class`
@@ -104,7 +113,6 @@ class ODStatScope extends base_1.ODManager {
104
113
  useDatabase(database) {
105
114
  this.database = database;
106
115
  }
107
- /**Get the value of a statistic. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
108
116
  async getStat(id, scopeId) {
109
117
  if (!this.database)
110
118
  return null;
@@ -121,7 +129,6 @@ class ODStatScope extends base_1.ODManager {
121
129
  //return null on error
122
130
  return null;
123
131
  }
124
- /**Get the value of a statistic for all `scopeId`'s. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
125
132
  async getAllStats(id) {
126
133
  if (!this.database)
127
134
  return [];
@@ -137,7 +144,6 @@ class ODStatScope extends base_1.ODManager {
137
144
  //return null on error
138
145
  return output;
139
146
  }
140
- /**Set, increase or decrease the value of a statistic. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
141
147
  async setStat(id, scopeId, value, mode) {
142
148
  if (!this.database)
143
149
  return false;
@@ -163,7 +169,6 @@ class ODStatScope extends base_1.ODManager {
163
169
  }
164
170
  return true;
165
171
  }
166
- /**Reset the value of a statistic to the initial value. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
167
172
  async resetStat(id, scopeId) {
168
173
  if (!this.database)
169
174
  return null;
@@ -207,6 +212,15 @@ class ODStatScope extends base_1.ODManager {
207
212
  }
208
213
  return result.filter((stat) => stat !== "").join("\n");
209
214
  }
215
+ get(id) {
216
+ return super.get(id);
217
+ }
218
+ remove(id) {
219
+ return super.remove(id);
220
+ }
221
+ exists(id) {
222
+ return super.exists(id);
223
+ }
210
224
  }
211
225
  exports.ODStatScope = ODStatScope;
212
226
  /**## ODStatGlobalScope `class`
@@ -11,17 +11,17 @@ import { ODWorkerManager } from "./worker";
11
11
  *
12
12
  * It doesn't contain the code which activates or spawns the verifybars!
13
13
  */
14
- export declare class ODVerifyBar extends ODManagerData {
14
+ export declare class ODVerifyBar<SuccessWorkerIds extends string = string, FailureWorkerIds extends string = string> extends ODManagerData {
15
15
  /**All workers that will run when the verifybar is accepted. */
16
16
  success: ODWorkerManager<ODButtonResponderInstance, "verifybar", {
17
17
  data: string | null;
18
18
  verifybarMessage: discord.Message<boolean> | null;
19
- }>;
19
+ }, SuccessWorkerIds>;
20
20
  /**All workers that will run when the verifybar is stopped. */
21
21
  failure: ODWorkerManager<ODButtonResponderInstance, "verifybar", {
22
22
  data: string | null;
23
23
  verifybarMessage: discord.Message<boolean> | null;
24
- }>;
24
+ }, FailureWorkerIds>;
25
25
  /**The message that will be built wen activating this verifybar. */
26
26
  message: ODMessage<"verifybar", {
27
27
  guild: discord.Guild | null;
@@ -36,11 +36,19 @@ export declare class ODVerifyBar extends ODManagerData {
36
36
  guild: discord.Guild | null;
37
37
  channel: discord.TextBasedChannel;
38
38
  user: discord.User;
39
+ verifybar: ODVerifyBar;
39
40
  originalMessage: discord.Message<boolean>;
40
41
  }>, enabled?: boolean);
41
42
  /**Build the message and reply to a button with this verifybar. */
42
43
  activate(responder: ODButtonResponderInstance): Promise<void>;
43
44
  }
45
+ /**## ODVerifyBarManagerIdConstraint `type`
46
+ * The constraint/layout for id mappings/interfaces of the `ODVerifyBarManager` class.
47
+ */
48
+ export type ODVerifyBarManagerIdConstraint = Record<string, {
49
+ successWorkerIds: string;
50
+ failureWorkerIds: string;
51
+ }>;
44
52
  /**## ODVerifyBarManager `class`
45
53
  * This is an Open Discord verifybar manager.
46
54
  *
@@ -49,6 +57,12 @@ export declare class ODVerifyBar extends ODManagerData {
49
57
  *
50
58
  * It doesn't contain the code which activates the verifybars! This should be implemented by your own.
51
59
  */
52
- export declare class ODVerifyBarManager extends ODManager<ODVerifyBar> {
60
+ export declare class ODVerifyBarManager<IdList extends ODVerifyBarManagerIdConstraint = ODVerifyBarManagerIdConstraint> extends ODManager<ODVerifyBar> {
53
61
  constructor(debug: ODDebugger);
62
+ get<VerifyBarId extends keyof IdList>(id: VerifyBarId): ODVerifyBar<IdList[VerifyBarId]["successWorkerIds"], IdList[VerifyBarId]["failureWorkerIds"]>;
63
+ get(id: ODValidId): ODVerifyBar | null;
64
+ remove<VerifyBarId extends keyof IdList>(id: VerifyBarId): ODVerifyBar<IdList[VerifyBarId]["successWorkerIds"], IdList[VerifyBarId]["failureWorkerIds"]>;
65
+ remove(id: ODValidId): ODVerifyBar | null;
66
+ exists(id: keyof IdList): boolean;
67
+ exists(id: ODValidId): boolean;
54
68
  }
@@ -56,5 +56,14 @@ class ODVerifyBarManager extends base_1.ODManager {
56
56
  constructor(debug) {
57
57
  super(debug, "verifybar");
58
58
  }
59
+ get(id) {
60
+ return super.get(id);
61
+ }
62
+ remove(id) {
63
+ return super.remove(id);
64
+ }
65
+ exists(id) {
66
+ return super.exists(id);
67
+ }
59
68
  }
60
69
  exports.ODVerifyBarManager = ODVerifyBarManager;
@@ -27,7 +27,7 @@ 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> extends ODManager<ODWorker<Instance, Source, Params>> {
30
+ export declare class ODWorkerManager<Instance, Source extends string, Params, WorkerIds extends string = string> extends ODManager<ODWorker<Instance, Source, 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<{
@@ -38,4 +38,10 @@ export declare class ODWorkerManager<Instance, Source extends string, Params> ex
38
38
  getSortedWorkers(priority: "ascending" | "descending"): ODWorker<Instance, Source, Params>[];
39
39
  /**Execute all workers on an instance using the given source & parameters. */
40
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;
45
+ exists(id: WorkerIds): boolean;
46
+ exists(id: ODValidId): boolean;
41
47
  }
@@ -89,5 +89,14 @@ class ODWorkerManager extends base_1.ODManager {
89
89
  }
90
90
  }
91
91
  }
92
+ get(id) {
93
+ return super.get(id);
94
+ }
95
+ remove(id) {
96
+ return super.remove(id);
97
+ }
98
+ exists(id) {
99
+ return super.exists(id);
100
+ }
92
101
  }
93
102
  exports.ODWorkerManager = ODWorkerManager;
@@ -99,6 +99,7 @@ function initialStartupLogs(opendiscord, project) {
99
99
  opendiscord.debug.debug("Using formatted-json-stringify " + packageJson.dependencies["formatted-json-stringify"] + "!");
100
100
  opendiscord.debug.debug("Using terminal-kit " + packageJson.dependencies["terminal-kit"] + "!");
101
101
  opendiscord.debug.debug("Using typescript " + packageJson.dependencies["typescript"] + "!");
102
+ opendiscord.debug.debug("Using @open-discord-bots/framework " + packageJson.dependencies["@open-discord-bots/framework"] + "!");
102
103
  }
103
104
  catch {
104
105
  opendiscord.debug.debug("Failed to fetch module versions!");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-discord-bots/framework",
3
3
  "author": "DJj123dj",
4
- "version": "0.1.2",
4
+ "version": "0.2.0",
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",
package/src/api/main.ts CHANGED
@@ -1,26 +1,26 @@
1
1
  //BASE MODULES
2
- import { ODEnvHelper, ODProjectType, ODVersion, ODVersionManager } from "./modules/base"
3
- import { ODConsoleManager, ODConsoleMessage, ODConsoleMessageParam, ODConsoleMessageTypes, ODDebugFileManager, ODDebugger, ODError, ODLiveStatusManager } from "./modules/console"
4
- import { ODCheckerManager } from "./modules/checker"
2
+ import { ODEnvHelper, ODProjectType, ODVersion, ODVersionManager, ODVersionManagerIdConstraint } from "./modules/base"
3
+ import { ODConsoleManager, ODConsoleMessage, ODConsoleMessageParam, ODConsoleMessageTypes, ODDebugFileManager, ODDebugger, ODError, ODLiveStatusManager, ODLiveStatusManagerIdConstraint } from "./modules/console"
4
+ import { ODCheckerFunctionManagerIdConstraint, ODCheckerManager, ODCheckerManagerIdConstraint, ODCheckerRenderer } from "./modules/checker"
5
5
  import { ODEventManager } from "./modules/event"
6
6
  import { ODPluginManager } from "./modules/plugin"
7
7
  import { ODFlagManager } from "./modules/flag"
8
8
  import { ODProgressBarManager } from "./modules/progressbar"
9
- import { ODConfigManager } from "./modules/config"
10
- import { ODDatabaseManager } from "./modules/database"
9
+ import { ODConfigManager, ODConfigManagerIdConstraint } from "./modules/config"
10
+ import { ODDatabaseManager, ODDatabaseManagerIdConstraint } from "./modules/database"
11
11
  import { ODSessionManager } from "./modules/session"
12
12
  import { ODLanguageManager } from "./modules/language"
13
- import { ODBuilderManager } from "./modules/builder"
13
+ import { ODBuilderManager, ODButtonManagerIdConstraint, ODDropdownManagerIdConstraint, ODEmbedManagerIdConstraint, ODFileManagerIdConstraint, ODMessageManagerIdConstraint, ODModalManagerIdConstraint } from "./modules/builder"
14
14
  import { ODResponderManager } from "./modules/responder"
15
- import { ODActionManager } from "./modules/action"
15
+ import { ODActionManager, ODActionManagerIdConstraint } from "./modules/action"
16
16
  import { ODVerifyBarManager } from "./modules/verifybar"
17
17
  import { ODPermissionManager } from "./modules/permission"
18
- import { ODCooldownManager } from "./modules/cooldown"
18
+ import { ODCooldownManager, ODCooldownManagerIdConstraint } from "./modules/cooldown"
19
19
  import { ODHelpMenuManager } from "./modules/helpmenu"
20
20
  import { ODStatsManager } from "./modules/stat"
21
- import { ODCodeManager } from "./modules/code"
21
+ import { ODCodeManager, ODCodeManagerIdConstraint } from "./modules/code"
22
22
  import { ODPostManager } from "./modules/post"
23
- import { ODClientManager } from "./modules/client"
23
+ import { ODClientManager, ODContextMenuManagerIdConstraint, ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint } from "./modules/client"
24
24
  import { ODSharedFuseManager } from "./modules/fuse"
25
25
  import { ODStartScreenManager } from "./modules/startscreen"
26
26
 
@@ -12,9 +12,9 @@ import { ODDebugger } from "./console"
12
12
  *
13
13
  * This class can't be used stand-alone & needs to be extended from!
14
14
  */
15
- export class ODActionImplementation<Source extends string,Params extends object,Result extends object> extends ODManagerData {
15
+ export class ODActionImplementation<Source extends string,Params extends object,Result extends object,WorkerIds extends string = string> extends ODManagerData {
16
16
  /**The manager that has all workers of this implementation */
17
- workers: ODWorkerManager<object,Source,Params>
17
+ workers: ODWorkerManager<object,Source,Params,WorkerIds>
18
18
 
19
19
  constructor(id:ODValidId, callback?:ODWorkerCallback<object,Source,Params>, priority?:number, callbackId?:ODValidId){
20
20
  super(id)
@@ -27,6 +27,11 @@ export class ODActionImplementation<Source extends string,Params extends object,
27
27
  }
28
28
  }
29
29
 
30
+ /**## ODActionManagerIdConstraint `type`
31
+ * The constraint/layout for id mappings/interfaces of the `ODActionManager` class.
32
+ */
33
+ export type ODActionManagerIdConstraint = Record<string,{source:string,params:object,result:object,workers:string}>
34
+
30
35
  /**## ODActionManager `class`
31
36
  * This is an Open Discord action manager.
32
37
  *
@@ -37,13 +42,41 @@ export class ODActionImplementation<Source extends string,Params extends object,
37
42
  *
38
43
  * It's recommended to use this system in combination with Open Discord responders!
39
44
  */
40
- export class ODActionManager extends ODManager<ODAction<string,{},{}>> {
45
+ export class ODActionManager<IdList extends ODActionManagerIdConstraint = ODActionManagerIdConstraint> extends ODManager<ODAction<string,{},{},string>> {
41
46
  constructor(debug:ODDebugger){
42
47
  super(debug,"action")
43
48
  }
49
+
50
+ get<ActionId extends keyof IdList>(id:ActionId): ODAction<IdList[ActionId]["source"],IdList[ActionId]["params"],IdList[ActionId]["result"],IdList[ActionId]["workers"]>
51
+ get(id:ODValidId): ODAction<string,{},{},string>|null
52
+
53
+ get(id:ODValidId): ODAction<string,{},{},string>|null {
54
+ return super.get(id)
55
+ }
56
+
57
+ remove<ActionId extends keyof IdList>(id:ActionId): ODAction<IdList[ActionId]["source"],IdList[ActionId]["params"],IdList[ActionId]["result"],IdList[ActionId]["workers"]>
58
+ remove(id:ODValidId): ODAction<string,{},{},string>|null
59
+
60
+ remove(id:ODValidId): ODAction<string,{},{},string>|null {
61
+ return super.remove(id)
62
+ }
63
+
64
+ exists(id:keyof IdList): boolean
65
+ exists(id:ODValidId): boolean
66
+
67
+ exists(id:ODValidId): boolean {
68
+ return super.exists(id)
69
+ }
44
70
  }
45
71
 
46
- export class ODAction<Source extends string,Params extends object,Result extends object> extends ODActionImplementation<Source,Params,Result> {
72
+ /**## ODAction `class`
73
+ * This is an Open Discord action.
74
+ *
75
+ * It is a collection of functions/workers to execute a complex workflow (e.g. creating a ticket, banning a user, ...).
76
+ *
77
+ * Can be used standalone.
78
+ */
79
+ export class ODAction<Source extends string,Params extends object,Result extends object,WorkerIds extends string = string> extends ODActionImplementation<Source,Params,Result,WorkerIds> {
47
80
  /**Run this action */
48
81
  async run(source:Source, params:Params): Promise<Partial<Result>> {
49
82
  //create instance
@@ -31,7 +31,7 @@ export type ODProjectType = "openticket"|"openmoderation"
31
31
  *
32
32
  * You will see this type in many functions from Open Discord.
33
33
  */
34
- export type ODValidId = string|ODId
34
+ export type ODValidId = string|number|symbol|ODId
35
35
 
36
36
  /**## ODValidJsonType `type`
37
37
  * This is a collection of all types that can be stored in a JSON file!
@@ -382,24 +382,51 @@ export class ODManagerWithSafety<DataType extends ODManagerData> extends ODManag
382
382
  * ### ⚠️ This should only be used when the data doesn't need to be written/edited
383
383
  */
384
384
  getSafe(id:ODValidId): DataType {
385
+ const newId = new ODId(id)
385
386
  const data = super.get(id)
386
387
  if (!data){
387
- process.emit("uncaughtException",new ODSystemError("ODManagerWithSafety:getSafe(\""+id+"\") => Unknown Id => Used backup data ("+this.#debugname+" manager)"))
388
+ process.emit("uncaughtException",new ODSystemError("ODManagerWithSafety:getSafe(\""+newId.value+"\") => Unknown Id => Used backup data ("+this.#debugname+" manager)"))
388
389
  return this.#backupCreator()
389
390
  }
390
391
  else return data
391
392
  }
392
393
  }
393
394
 
395
+ /**## ODVersionManagerIdConstraint `type`
396
+ * The constraint/layout for id mappings/interfaces of the `ODVersionManager` class.
397
+ */
398
+ export type ODVersionManagerIdConstraint = Record<string,ODVersion>
399
+
394
400
  /**## ODVersionManager `class`
395
401
  * A Open Discord version manager.
396
402
  *
397
403
  * It is used to manage different `ODVersion`'s from the bot. You will use it to check which version of the bot is used.
398
404
  */
399
- export class ODVersionManager extends ODManager<ODVersion> {
405
+ export class ODVersionManager<IdList extends ODVersionManagerIdConstraint = ODVersionManagerIdConstraint> extends ODManager<ODVersion> {
400
406
  constructor(){
401
407
  super()
402
408
  }
409
+
410
+ get<VersionId extends keyof IdList>(id:VersionId): IdList[VersionId]
411
+ get(id:ODValidId): ODVersion|null
412
+
413
+ get(id:ODValidId): ODVersion|null {
414
+ return super.get(id)
415
+ }
416
+
417
+ remove<VersionId extends keyof IdList>(id:VersionId): IdList[VersionId]
418
+ remove(id:ODValidId): ODVersion|null
419
+
420
+ remove(id:ODValidId): ODVersion|null {
421
+ return super.remove(id)
422
+ }
423
+
424
+ exists(id:keyof IdList): boolean
425
+ exists(id:ODValidId): boolean
426
+
427
+ exists(id:ODValidId): boolean {
428
+ return super.exists(id)
429
+ }
403
430
  }
404
431
 
405
432
  /**## ODVersion `class`