@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
@@ -26,7 +26,7 @@ export type ODClientPermissions = ("CreateInstantInvite" | "KickMembers" | "BanM
26
26
  *
27
27
  * If you want, you can also listen for custom events on the `ODClientManager.client` variable (`discord.Client`)
28
28
  */
29
- export declare class ODClientManager {
29
+ export declare class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstraint = ODSlashCommandManagerIdConstraint, TextIdList extends ODTextCommandManagerIdConstraint = ODTextCommandManagerIdConstraint, ContextMenuIdList extends ODContextMenuManagerIdConstraint = ODContextMenuManagerIdConstraint> {
30
30
  #private;
31
31
  /**List of required bot intents. Add intents to this list using the `onClientLoad` event. */
32
32
  intents: ODClientIntents[];
@@ -56,11 +56,11 @@ export declare class ODClientManager {
56
56
  /**The status manager is responsible for setting the bot status. */
57
57
  activity: ODClientActivityManager;
58
58
  /**The slash command manager is responsible for all slash commands & their events inside the bot. */
59
- slashCommands: ODSlashCommandManager;
59
+ slashCommands: ODSlashCommandManager<SlashIdList>;
60
60
  /**The text command manager is responsible for all text commands & their events inside the bot. */
61
- textCommands: ODTextCommandManager;
61
+ textCommands: ODTextCommandManager<TextIdList>;
62
62
  /**The context menu manager is responsible for all context menus & their events inside the bot. */
63
- contextMenus: ODContextMenuManager;
63
+ contextMenus: ODContextMenuManager<ContextMenuIdList>;
64
64
  /**The autocomplete manager is responsible for all autocomplete events inside the bot. */
65
65
  autocompletes: ODAutocompleteManager;
66
66
  constructor(debug: ODDebugger);
@@ -113,8 +113,6 @@ export type ODClientActivityMode = ("online" | "invisible" | "idle" | "dnd");
113
113
  */
114
114
  export declare class ODClientActivityManager {
115
115
  #private;
116
- /**Copy of discord.js client */
117
- manager: ODClientManager;
118
116
  /**The current status type */
119
117
  type: ODClientActivityType;
120
118
  /**The current status text */
@@ -129,7 +127,7 @@ export declare class ODClientActivityManager {
129
127
  refreshInterval: number;
130
128
  /**Is the status already initiated? */
131
129
  initiated: boolean;
132
- constructor(debug: ODDebugger, manager: ODClientManager);
130
+ constructor(debug: ODDebugger, manager: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
133
131
  /**Update the status. When already initiated, it can take up to 10min to see the updated status in discord. */
134
132
  setStatus(type: ODClientActivityType, text: string, mode: ODClientActivityMode, state: string, forceUpdate?: boolean): void;
135
133
  /**When initiating the status, the bot starts updating the status using `discord.js`. Returns `true` when successfull. */
@@ -286,6 +284,10 @@ export type ODSlashCommandRegisteredResult = {
286
284
  requiresUpdate: false;
287
285
  }[];
288
286
  };
287
+ /**## ODSlashCommandManagerIdConstraint `type`
288
+ * The constraint/layout for id mappings/interfaces of the `ODSlashCommandManager` class.
289
+ */
290
+ export type ODSlashCommandManagerIdConstraint = Record<string, ODSlashCommand>;
289
291
  /**## ODSlashCommandManager `class`
290
292
  * This is an Open Discord client slash manager.
291
293
  *
@@ -293,17 +295,15 @@ export type ODSlashCommandRegisteredResult = {
293
295
  *
294
296
  * Here, you can add & remove slash commands & the bot will do the (de)registering.
295
297
  */
296
- export declare class ODSlashCommandManager extends ODManager<ODSlashCommand> {
298
+ export declare class ODSlashCommandManager<IdList extends ODSlashCommandManagerIdConstraint = ODSlashCommandManagerIdConstraint> extends ODManager<ODSlashCommand> {
297
299
  #private;
298
- /**Refrerence to discord.js client. */
299
- manager: ODClientManager;
300
300
  /**Discord.js application commands manager. */
301
301
  commandManager: discord.ApplicationCommandManager | null;
302
302
  /**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
303
303
  listenerLimit: number;
304
304
  /**A utility class used to compare 2 slash commands with each other. */
305
305
  comparator: ODSlashCommandComparator;
306
- constructor(debug: ODDebugger, manager: ODClientManager);
306
+ constructor(debug: ODDebugger, manager: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
307
307
  /**Get all registered & unregistered slash commands. */
308
308
  getAllRegisteredCommands(guildId?: string): Promise<ODSlashCommandRegisteredResult>;
309
309
  /**Create all commands that are not registered yet.*/
@@ -317,7 +317,14 @@ export declare class ODSlashCommandManager extends ODManager<ODSlashCommand> {
317
317
  /**Start listening to the discord.js client `interactionCreate` event. */
318
318
  startListeningToInteractions(): void;
319
319
  /**Callback on interaction from one or multiple slash commands. */
320
+ onInteraction(commandName: Extract<keyof IdList, string>, callback: ODSlashCommandInteractionCallback): void;
320
321
  onInteraction(commandName: string | RegExp, callback: ODSlashCommandInteractionCallback): void;
322
+ get<SlashCommandId extends keyof IdList>(id: SlashCommandId): IdList[SlashCommandId];
323
+ get(id: ODValidId): ODSlashCommand | null;
324
+ remove<SlashCommandId extends keyof IdList>(id: SlashCommandId): IdList[SlashCommandId];
325
+ remove(id: ODValidId): ODSlashCommand | null;
326
+ exists(id: keyof IdList): boolean;
327
+ exists(id: ODValidId): boolean;
321
328
  }
322
329
  /**## ODSlashCommandUpdateFunction `type`
323
330
  * The function responsible for updating slash commands when they already exist.
@@ -567,6 +574,10 @@ export type ODTextCommandError = (ODTextCommandErrorUnknownPrefix | ODTextComman
567
574
  * Callback for the text command error listener.
568
575
  */
569
576
  export type ODTextCommandErrorCallback = (error: ODTextCommandError) => void;
577
+ /**## ODTextCommandManagerIdConstraint `type`
578
+ * The constraint/layout for id mappings/interfaces of the `ODTextCommandManager` class.
579
+ */
580
+ export type ODTextCommandManagerIdConstraint = Record<string, ODTextCommand>;
570
581
  /**## ODTextCommandManager `class`
571
582
  * This is an Open Discord client text manager.
572
583
  *
@@ -574,19 +585,24 @@ export type ODTextCommandErrorCallback = (error: ODTextCommandError) => void;
574
585
  *
575
586
  * Here, you can add & remove text commands & the bot will do the (de)registering.
576
587
  */
577
- export declare class ODTextCommandManager extends ODManager<ODTextCommand> {
588
+ export declare class ODTextCommandManager<IdList extends ODTextCommandManagerIdConstraint = ODTextCommandManagerIdConstraint> extends ODManager<ODTextCommand> {
578
589
  #private;
579
- /**Copy of discord.js client. */
580
- manager: ODClientManager;
581
590
  /**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
582
591
  listenerLimit: number;
583
- constructor(debug: ODDebugger, manager: ODClientManager);
592
+ constructor(debug: ODDebugger, manager: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
584
593
  /**Start listening to the discord.js client `messageCreate` event. */
585
594
  startListeningToInteractions(): void;
586
595
  /**Callback on interaction from one of the registered text commands */
596
+ onInteraction(commandPrefix: string, commandName: Extract<keyof IdList, string>, callback: ODTextCommandInteractionCallback): void;
587
597
  onInteraction(commandPrefix: string, commandName: string | RegExp, callback: ODTextCommandInteractionCallback): void;
588
598
  /**Callback on error from all the registered text commands */
589
599
  onError(callback: ODTextCommandErrorCallback): void;
600
+ get<TextCommandId extends keyof IdList>(id: TextCommandId): IdList[TextCommandId];
601
+ get(id: ODValidId): ODTextCommand | null;
602
+ remove<TextCommandId extends keyof IdList>(id: TextCommandId): IdList[TextCommandId];
603
+ remove(id: ODValidId): ODTextCommand | null;
604
+ exists(id: keyof IdList): boolean;
605
+ exists(id: ODValidId): boolean;
590
606
  add(data: ODTextCommand, overwrite?: boolean): boolean;
591
607
  }
592
608
  /**## ODContextMenuUniversalMenu `interface`
@@ -683,6 +699,10 @@ export type ODContextMenuRegisteredResult = {
683
699
  requiresUpdate: false;
684
700
  }[];
685
701
  };
702
+ /**## ODContextMenuManagerIdConstraint `type`
703
+ * The constraint/layout for id mappings/interfaces of the `ODContextMenuManager` class.
704
+ */
705
+ export type ODContextMenuManagerIdConstraint = Record<string, ODContextMenu>;
686
706
  /**## ODContextMenuManager `class`
687
707
  * This is an Open Discord client context menu manager.
688
708
  *
@@ -690,17 +710,15 @@ export type ODContextMenuRegisteredResult = {
690
710
  *
691
711
  * Here, you can add & remove context interactions & the bot will do the (de)registering.
692
712
  */
693
- export declare class ODContextMenuManager extends ODManager<ODContextMenu> {
713
+ export declare class ODContextMenuManager<IdList extends ODContextMenuManagerIdConstraint = ODContextMenuManagerIdConstraint> extends ODManager<ODContextMenu> {
694
714
  #private;
695
- /**Refrerence to discord.js client. */
696
- manager: ODClientManager;
697
715
  /**Discord.js application commands manager. */
698
716
  commandManager: discord.ApplicationCommandManager | null;
699
717
  /**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
700
718
  listenerLimit: number;
701
719
  /**A utility class used to compare 2 context menus with each other. */
702
720
  comparator: ODContextMenuComparator;
703
- constructor(debug: ODDebugger, manager: ODClientManager);
721
+ constructor(debug: ODDebugger, manager: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
704
722
  /**Get all registered & unregistered message context menu commands. */
705
723
  getAllRegisteredMenus(guildId?: string): Promise<ODContextMenuRegisteredResult>;
706
724
  /**Create all context menus that are not registered yet.*/
@@ -714,7 +732,14 @@ export declare class ODContextMenuManager extends ODManager<ODContextMenu> {
714
732
  /**Start listening to the discord.js client `interactionCreate` event. */
715
733
  startListeningToInteractions(): void;
716
734
  /**Callback on interaction from one or multiple context menu's. */
735
+ onInteraction(menuName: Extract<keyof IdList, string>, callback: ODContextMenuInteractionCallback): void;
717
736
  onInteraction(menuName: string | RegExp, callback: ODContextMenuInteractionCallback): void;
737
+ get<ContextMenuId extends keyof IdList>(id: ContextMenuId): IdList[ContextMenuId];
738
+ get(id: ODValidId): ODContextMenu | null;
739
+ remove<ContextMenuId extends keyof IdList>(id: ContextMenuId): IdList[ContextMenuId];
740
+ remove(id: ODValidId): ODContextMenu | null;
741
+ exists(id: keyof IdList): boolean;
742
+ exists(id: ODValidId): boolean;
718
743
  }
719
744
  /**## ODContextMenuUpdateFunction `type`
720
745
  * The function responsible for updating context menu's when they already exist.
@@ -754,13 +779,11 @@ export type ODAutocompleteInteractionCallback = (interaction: discord.Autocomple
754
779
  */
755
780
  export declare class ODAutocompleteManager {
756
781
  #private;
757
- /**Refrerence to discord.js client. */
758
- manager: ODClientManager;
759
782
  /**Discord.js application commands manager. */
760
783
  commandManager: discord.ApplicationCommandManager | null;
761
784
  /**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
762
785
  listenerLimit: number;
763
- constructor(debug: ODDebugger, manager: ODClientManager);
786
+ constructor(debug: ODDebugger, manager: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
764
787
  /**Start listening to the discord.js client `interactionCreate` event. */
765
788
  startListeningToInteractions(): void;
766
789
  /**Callback on interaction from one or multiple autocompletes. */
@@ -395,7 +395,7 @@ class ODClientActivityManager {
395
395
  /**Alias to Open Discord debugger. */
396
396
  #debug;
397
397
  /**Copy of discord.js client */
398
- manager;
398
+ #manager;
399
399
  /**The current status type */
400
400
  type = false;
401
401
  /**The current status text */
@@ -412,7 +412,7 @@ class ODClientActivityManager {
412
412
  initiated = false;
413
413
  constructor(debug, manager) {
414
414
  this.#debug = debug;
415
- this.manager = manager;
415
+ this.#manager = manager;
416
416
  }
417
417
  /**Update the status. When already initiated, it can take up to 10min to see the updated status in discord. */
418
418
  setStatus(type, text, mode, state, forceUpdate) {
@@ -425,7 +425,7 @@ class ODClientActivityManager {
425
425
  }
426
426
  /**When initiating the status, the bot starts updating the status using `discord.js`. Returns `true` when successfull. */
427
427
  initStatus() {
428
- if (this.initiated || !this.manager.ready)
428
+ if (this.initiated || !this.#manager.ready)
429
429
  return false;
430
430
  this.#updateClientActivity(this.type, this.text);
431
431
  this.interval = setInterval(() => {
@@ -438,13 +438,13 @@ class ODClientActivityManager {
438
438
  }
439
439
  /**Update the client status */
440
440
  #updateClientActivity(type, text) {
441
- if (!this.manager.client.user)
441
+ if (!this.#manager.client.user)
442
442
  throw new base_1.ODSystemError("Couldn't set client status: client.user == undefined");
443
443
  if (type == false) {
444
- this.manager.client.user.setActivity();
444
+ this.#manager.client.user.setActivity();
445
445
  return;
446
446
  }
447
- this.manager.client.user.setPresence({
447
+ this.#manager.client.user.setPresence({
448
448
  activities: [{
449
449
  type: this.#getStatusTypeEnum(type),
450
450
  state: this.state ? this.state : undefined,
@@ -727,7 +727,7 @@ class ODSlashCommandManager extends base_1.ODManager {
727
727
  /**Alias to Open Discord debugger. */
728
728
  #debug;
729
729
  /**Refrerence to discord.js client. */
730
- manager;
730
+ #manager;
731
731
  /**Discord.js application commands manager. */
732
732
  commandManager;
733
733
  /**Collection of all interaction listeners. */
@@ -739,7 +739,7 @@ class ODSlashCommandManager extends base_1.ODManager {
739
739
  constructor(debug, manager) {
740
740
  super(debug, "slash command");
741
741
  this.#debug = debug;
742
- this.manager = manager;
742
+ this.#manager = manager;
743
743
  this.commandManager = (manager.client.application) ? manager.client.application.commands : null;
744
744
  }
745
745
  /**Get all registered & unregistered slash commands. */
@@ -782,7 +782,7 @@ class ODSlashCommandManager extends base_1.ODManager {
782
782
  }
783
783
  /**Create all commands that are not registered yet.*/
784
784
  async createNewCommands(instances, progress) {
785
- if (!this.manager.ready)
785
+ if (!this.#manager.ready)
786
786
  throw new base_1.ODSystemError("Client isn't ready yet! Unable to register slash commands!");
787
787
  if (instances.length > 0 && progress) {
788
788
  progress.max = instances.length;
@@ -800,7 +800,7 @@ class ODSlashCommandManager extends base_1.ODManager {
800
800
  }
801
801
  /**Update all commands that are already registered. */
802
802
  async updateExistingCommands(instances, progress) {
803
- if (!this.manager.ready)
803
+ if (!this.#manager.ready)
804
804
  throw new base_1.ODSystemError("Client isn't ready yet! Unable to register slash commands!");
805
805
  if (instances.length > 0 && progress) {
806
806
  progress.max = instances.length;
@@ -815,7 +815,7 @@ class ODSlashCommandManager extends base_1.ODManager {
815
815
  }
816
816
  /**Remove all commands that are registered but unused by Open Discord. */
817
817
  async removeUnusedCommands(instances, guildId, progress) {
818
- if (!this.manager.ready)
818
+ if (!this.#manager.ready)
819
819
  throw new base_1.ODSystemError("Client isn't ready yet! Unable to register slash commands!");
820
820
  if (!this.commandManager)
821
821
  throw new base_1.ODSystemError("Couldn't get client application to register slash commands!");
@@ -854,9 +854,9 @@ class ODSlashCommandManager extends base_1.ODManager {
854
854
  }
855
855
  /**Start listening to the discord.js client `interactionCreate` event. */
856
856
  startListeningToInteractions() {
857
- this.manager.client.on("interactionCreate", (interaction) => {
857
+ this.#manager.client.on("interactionCreate", (interaction) => {
858
858
  //return when not in main server or DM
859
- if (!this.manager.mainServer || (interaction.guild && interaction.guild.id != this.manager.mainServer.id))
859
+ if (!this.#manager.mainServer || (interaction.guild && interaction.guild.id != this.#manager.mainServer.id))
860
860
  return;
861
861
  if (!interaction.isChatInputCommand())
862
862
  return;
@@ -873,7 +873,6 @@ class ODSlashCommandManager extends base_1.ODManager {
873
873
  });
874
874
  });
875
875
  }
876
- /**Callback on interaction from one or multiple slash commands. */
877
876
  onInteraction(commandName, callback) {
878
877
  this.#interactionListeners.push({
879
878
  name: commandName,
@@ -885,6 +884,15 @@ class ODSlashCommandManager extends base_1.ODManager {
885
884
  ]));
886
885
  }
887
886
  }
887
+ get(id) {
888
+ return super.get(id);
889
+ }
890
+ remove(id) {
891
+ return super.remove(id);
892
+ }
893
+ exists(id) {
894
+ return super.exists(id);
895
+ }
888
896
  }
889
897
  exports.ODSlashCommandManager = ODSlashCommandManager;
890
898
  /**## ODSlashCommand `class`
@@ -957,7 +965,7 @@ class ODTextCommandManager extends base_1.ODManager {
957
965
  /**Alias to Open Discord debugger. */
958
966
  #debug;
959
967
  /**Copy of discord.js client. */
960
- manager;
968
+ #manager;
961
969
  /**Collection of all interaction listeners. */
962
970
  #interactionListeners = [];
963
971
  /**Collection of all error listeners. */
@@ -967,11 +975,11 @@ class ODTextCommandManager extends base_1.ODManager {
967
975
  constructor(debug, manager) {
968
976
  super(debug, "text command");
969
977
  this.#debug = debug;
970
- this.manager = manager;
978
+ this.#manager = manager;
971
979
  }
972
980
  /*Check if a message is a registered command. */
973
981
  async #checkMessage(msg) {
974
- if (this.manager.client.user && msg.author.id == this.manager.client.user.id)
982
+ if (this.#manager.client.user && msg.author.id == this.#manager.client.user.id)
975
983
  return false;
976
984
  //filter commands for correct prefix
977
985
  const validPrefixCommands = [];
@@ -1356,7 +1364,7 @@ class ODTextCommandManager extends base_1.ODManager {
1356
1364
  tempContent = tempContent.substring(value.length + 1);
1357
1365
  const userId = res[1];
1358
1366
  try {
1359
- const user = await this.manager.client.users.fetch(userId);
1367
+ const user = await this.#manager.client.users.fetch(userId);
1360
1368
  if (!user) {
1361
1369
  optionError("invalid_option", option, location, value, "user_not_found");
1362
1370
  }
@@ -1416,7 +1424,7 @@ class ODTextCommandManager extends base_1.ODManager {
1416
1424
  }
1417
1425
  else if (type == "user") {
1418
1426
  try {
1419
- const user = await this.manager.client.users.fetch(mentionableId);
1427
+ const user = await this.#manager.client.users.fetch(mentionableId);
1420
1428
  if (!user) {
1421
1429
  optionError("invalid_option", option, location, value, "mentionable_not_found");
1422
1430
  }
@@ -1449,9 +1457,9 @@ class ODTextCommandManager extends base_1.ODManager {
1449
1457
  }
1450
1458
  /**Start listening to the discord.js client `messageCreate` event. */
1451
1459
  startListeningToInteractions() {
1452
- this.manager.client.on("messageCreate", (msg) => {
1460
+ this.#manager.client.on("messageCreate", (msg) => {
1453
1461
  //return when not in main server or DM
1454
- if (!this.manager.mainServer || (msg.guild && msg.guild.id != this.manager.mainServer.id))
1462
+ if (!this.#manager.mainServer || (msg.guild && msg.guild.id != this.#manager.mainServer.id))
1455
1463
  return;
1456
1464
  this.#checkMessage(msg);
1457
1465
  });
@@ -1477,7 +1485,6 @@ class ODTextCommandManager extends base_1.ODManager {
1477
1485
  });
1478
1486
  return { valid, reason };
1479
1487
  }
1480
- /**Callback on interaction from one of the registered text commands */
1481
1488
  onInteraction(commandPrefix, commandName, callback) {
1482
1489
  this.#interactionListeners.push({
1483
1490
  prefix: commandPrefix,
@@ -1494,6 +1501,15 @@ class ODTextCommandManager extends base_1.ODManager {
1494
1501
  onError(callback) {
1495
1502
  this.#errorListeners.push(callback);
1496
1503
  }
1504
+ get(id) {
1505
+ return super.get(id);
1506
+ }
1507
+ remove(id) {
1508
+ return super.remove(id);
1509
+ }
1510
+ exists(id) {
1511
+ return super.exists(id);
1512
+ }
1497
1513
  add(data, overwrite) {
1498
1514
  const checkResult = this.#checkBuilderOptions(data.builder);
1499
1515
  if (!checkResult.valid && checkResult.reason == "required_after_optional")
@@ -1597,7 +1613,7 @@ class ODContextMenuManager extends base_1.ODManager {
1597
1613
  /**Alias to Open Discord debugger. */
1598
1614
  #debug;
1599
1615
  /**Refrerence to discord.js client. */
1600
- manager;
1616
+ #manager;
1601
1617
  /**Discord.js application commands manager. */
1602
1618
  commandManager;
1603
1619
  /**Collection of all interaction listeners. */
@@ -1609,7 +1625,7 @@ class ODContextMenuManager extends base_1.ODManager {
1609
1625
  constructor(debug, manager) {
1610
1626
  super(debug, "context menu");
1611
1627
  this.#debug = debug;
1612
- this.manager = manager;
1628
+ this.#manager = manager;
1613
1629
  this.commandManager = (manager.client.application) ? manager.client.application.commands : null;
1614
1630
  }
1615
1631
  /**Get all registered & unregistered message context menu commands. */
@@ -1652,7 +1668,7 @@ class ODContextMenuManager extends base_1.ODManager {
1652
1668
  }
1653
1669
  /**Create all context menus that are not registered yet.*/
1654
1670
  async createNewMenus(instances, progress) {
1655
- if (!this.manager.ready)
1671
+ if (!this.#manager.ready)
1656
1672
  throw new base_1.ODSystemError("Client isn't ready yet! Unable to register context menus!");
1657
1673
  if (instances.length > 0 && progress) {
1658
1674
  progress.max = instances.length;
@@ -1671,7 +1687,7 @@ class ODContextMenuManager extends base_1.ODManager {
1671
1687
  }
1672
1688
  /**Update all context menus that are already registered. */
1673
1689
  async updateExistingMenus(instances, progress) {
1674
- if (!this.manager.ready)
1690
+ if (!this.#manager.ready)
1675
1691
  throw new base_1.ODSystemError("Client isn't ready yet! Unable to register context menus!");
1676
1692
  if (instances.length > 0 && progress) {
1677
1693
  progress.max = instances.length;
@@ -1690,7 +1706,7 @@ class ODContextMenuManager extends base_1.ODManager {
1690
1706
  }
1691
1707
  /**Remove all context menus that are registered but unused by Open Discord. */
1692
1708
  async removeUnusedMenus(instances, guildId, progress) {
1693
- if (!this.manager.ready)
1709
+ if (!this.#manager.ready)
1694
1710
  throw new base_1.ODSystemError("Client isn't ready yet! Unable to register context menus!");
1695
1711
  if (!this.commandManager)
1696
1712
  throw new base_1.ODSystemError("Couldn't get client application to register context menus!");
@@ -1733,9 +1749,9 @@ class ODContextMenuManager extends base_1.ODManager {
1733
1749
  }
1734
1750
  /**Start listening to the discord.js client `interactionCreate` event. */
1735
1751
  startListeningToInteractions() {
1736
- this.manager.client.on("interactionCreate", (interaction) => {
1752
+ this.#manager.client.on("interactionCreate", (interaction) => {
1737
1753
  //return when not in main server or DM
1738
- if (!this.manager.mainServer || (interaction.guild && interaction.guild.id != this.manager.mainServer.id))
1754
+ if (!this.#manager.mainServer || (interaction.guild && interaction.guild.id != this.#manager.mainServer.id))
1739
1755
  return;
1740
1756
  if (!interaction.isContextMenuCommand())
1741
1757
  return;
@@ -1752,7 +1768,6 @@ class ODContextMenuManager extends base_1.ODManager {
1752
1768
  });
1753
1769
  });
1754
1770
  }
1755
- /**Callback on interaction from one or multiple context menu's. */
1756
1771
  onInteraction(menuName, callback) {
1757
1772
  this.#interactionListeners.push({
1758
1773
  name: menuName,
@@ -1764,6 +1779,15 @@ class ODContextMenuManager extends base_1.ODManager {
1764
1779
  ]);
1765
1780
  }
1766
1781
  }
1782
+ get(id) {
1783
+ return super.get(id);
1784
+ }
1785
+ remove(id) {
1786
+ return super.remove(id);
1787
+ }
1788
+ exists(id) {
1789
+ return super.exists(id);
1790
+ }
1767
1791
  }
1768
1792
  exports.ODContextMenuManager = ODContextMenuManager;
1769
1793
  /**## ODContextMenu `class`
@@ -1810,7 +1834,7 @@ class ODAutocompleteManager {
1810
1834
  /**Alias to Open Discord debugger. */
1811
1835
  #debug;
1812
1836
  /**Refrerence to discord.js client. */
1813
- manager;
1837
+ #manager;
1814
1838
  /**Discord.js application commands manager. */
1815
1839
  commandManager;
1816
1840
  /**Collection of all interaction listeners. */
@@ -1819,14 +1843,14 @@ class ODAutocompleteManager {
1819
1843
  listenerLimit = 100;
1820
1844
  constructor(debug, manager) {
1821
1845
  this.#debug = debug;
1822
- this.manager = manager;
1846
+ this.#manager = manager;
1823
1847
  this.commandManager = (manager.client.application) ? manager.client.application.commands : null;
1824
1848
  }
1825
1849
  /**Start listening to the discord.js client `interactionCreate` event. */
1826
1850
  startListeningToInteractions() {
1827
- this.manager.client.on("interactionCreate", (interaction) => {
1851
+ this.#manager.client.on("interactionCreate", (interaction) => {
1828
1852
  //return when not in main server or DM
1829
- if (!this.manager.mainServer || (interaction.guild && interaction.guild.id != this.manager.mainServer.id))
1853
+ if (!this.#manager.mainServer || (interaction.guild && interaction.guild.id != this.#manager.mainServer.id))
1830
1854
  return;
1831
1855
  if (!interaction.isAutocomplete())
1832
1856
  return;
@@ -19,6 +19,10 @@ export declare class ODCode extends ODManagerData {
19
19
  func: () => void | Promise<void>;
20
20
  constructor(id: ODValidId, priority: number, func: () => void | Promise<void>);
21
21
  }
22
+ /**## ODCodeManagerIdConstraint `type`
23
+ * The constraint/layout for id mappings/interfaces of the `ODCodeManager` class.
24
+ */
25
+ export type ODCodeManagerIdConstraint = Record<string, ODCode>;
22
26
  /**## ODCodeManager `class`
23
27
  * This is an Open Discord code manager.
24
28
  *
@@ -26,8 +30,14 @@ export declare class ODCode extends ODManagerData {
26
30
  *
27
31
  * Use this to register a function/code which executes just before the startup screen. (90% is already loaded)
28
32
  */
29
- export declare class ODCodeManager extends ODManager<ODCode> {
33
+ export declare class ODCodeManager<IdList extends ODCodeManagerIdConstraint = ODCodeManagerIdConstraint> extends ODManager<ODCode> {
30
34
  constructor(debug: ODDebugger);
31
35
  /**Execute all `ODCode` functions in order of their priority (high to low). */
32
36
  execute(): Promise<void>;
37
+ get<CodeId extends keyof IdList>(id: CodeId): IdList[CodeId];
38
+ get(id: ODValidId): ODCode | null;
39
+ remove<CodeId extends keyof IdList>(id: CodeId): IdList[CodeId];
40
+ remove(id: ODValidId): ODCode | null;
41
+ exists(id: keyof IdList): boolean;
42
+ exists(id: ODValidId): boolean;
33
43
  }
@@ -53,5 +53,14 @@ class ODCodeManager extends base_1.ODManager {
53
53
  }
54
54
  }
55
55
  }
56
+ get(id) {
57
+ return super.get(id);
58
+ }
59
+ remove(id) {
60
+ return super.remove(id);
61
+ }
62
+ exists(id) {
63
+ return super.exists(id);
64
+ }
56
65
  }
57
66
  exports.ODCodeManager = ODCodeManager;
@@ -1,6 +1,10 @@
1
1
  import { ODManager, ODManagerData, ODPromiseVoid, ODValidId } from "./base";
2
2
  import { ODDebugger } from "./console";
3
3
  import * as fjs from "formatted-json-stringify";
4
+ /**## ODConfigManagerIdConstraint `type`
5
+ * The constraint/layout for id mappings/interfaces of the `ODConfigManager` class.
6
+ */
7
+ export type ODConfigManagerIdConstraint = Record<string, ODConfig<any>>;
4
8
  /**## ODConfigManager `class`
5
9
  * This is an Open Discord config manager.
6
10
  *
@@ -8,12 +12,18 @@ import * as fjs from "formatted-json-stringify";
8
12
  *
9
13
  * You can use this class to get/change/add a config file (`ODConfig`) in your plugin!
10
14
  */
11
- export declare class ODConfigManager extends ODManager<ODConfig> {
15
+ export declare class ODConfigManager<IdList extends ODConfigManagerIdConstraint = ODConfigManagerIdConstraint> extends ODManager<ODConfig<any>> {
12
16
  #private;
13
17
  constructor(debug: ODDebugger);
14
- add(data: ODConfig | ODConfig[], overwrite?: boolean): boolean;
18
+ add(data: ODConfig<any> | ODConfig<any>[], overwrite?: boolean): boolean;
15
19
  /**Init all config files. */
16
20
  init(): Promise<void>;
21
+ get<ConfigId extends keyof IdList>(id: ConfigId): IdList[ConfigId];
22
+ get(id: ODValidId): ODConfig<any> | null;
23
+ remove<ConfigId extends keyof IdList>(id: ConfigId): IdList[ConfigId];
24
+ remove(id: ODValidId): ODConfig<any> | null;
25
+ exists(id: keyof IdList): boolean;
26
+ exists(id: ODValidId): boolean;
17
27
  }
18
28
  /**## ODConfig `class`
19
29
  * This is an Open Discord config helper.
@@ -21,13 +31,13 @@ export declare class ODConfigManager extends ODManager<ODConfig> {
21
31
  *
22
32
  * You can use this class if you want to create your own config implementation (e.g. `yml`, `xml`,...)!
23
33
  */
24
- export declare class ODConfig extends ODManagerData {
34
+ export declare class ODConfig<Data extends any> extends ODManagerData {
25
35
  /**The name of the file with extension. */
26
36
  file: string;
27
37
  /**The path to the file relative to the main directory. */
28
38
  path: string;
29
39
  /**An object/array of the entire config file! Variables inside it can be edited while the bot is running! */
30
- data: any;
40
+ data: Data;
31
41
  /**Is this config already initiated? */
32
42
  initiated: boolean;
33
43
  /**An array of listeners to run when the config gets reloaded. These are not executed on the initial loading. */
@@ -58,7 +68,7 @@ export declare class ODConfig extends ODManagerData {
58
68
  * //create a config with custom dir: ./plugins/testplugin/test.json
59
69
  * const config = new api.ODJsonConfig("plugin-config","test.json","./plugins/testplugin/")
60
70
  */
61
- export declare class ODJsonConfig extends ODConfig {
71
+ export declare class ODJsonConfig<Data extends any> extends ODConfig<Data> {
62
72
  formatter: fjs.custom.BaseFormatter;
63
73
  constructor(id: ODValidId, file: string, customPath?: string, formatter?: fjs.custom.BaseFormatter);
64
74
  /**Init the config. */
@@ -76,6 +76,15 @@ class ODConfigManager extends base_1.ODManager {
76
76
  }
77
77
  }
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.ODConfigManager = ODConfigManager;
81
90
  /**## ODConfig `class`
@@ -276,6 +276,10 @@ export declare class ODLiveStatusUrlSource extends ODLiveStatusSource {
276
276
  constructor(main: ODMain, id: ODValidId, url: string);
277
277
  getMessages(main: ODMain): Promise<ODLiveStatusSourceData[]>;
278
278
  }
279
+ /**## ODLiveStatusManagerIdConstraint `type`
280
+ * The constraint/layout for id mappings/interfaces of the `ODLiveStatusManager` class.
281
+ */
282
+ export type ODLiveStatusManagerIdConstraint = Record<string, ODLiveStatusSource>;
279
283
  /**## ODLiveStatusManager `class`
280
284
  * This is the Open Discord livestatus manager.
281
285
  *
@@ -284,7 +288,7 @@ export declare class ODLiveStatusUrlSource extends ODLiveStatusSource {
284
288
  * You can use this to customise or add stuff to the LiveStatus system.
285
289
  * Access it in the global `opendiscord.startscreen.livestatus` variable!
286
290
  */
287
- export declare class ODLiveStatusManager extends ODManager<ODLiveStatusSource> {
291
+ export declare class ODLiveStatusManager<IdList extends ODLiveStatusManagerIdConstraint = ODLiveStatusManagerIdConstraint> extends ODManager<ODLiveStatusSource> {
288
292
  #private;
289
293
  /**The class responsible for rendering the livestatus messages. */
290
294
  renderer: ODLiveStatusRenderer;
@@ -293,6 +297,12 @@ export declare class ODLiveStatusManager extends ODManager<ODLiveStatusSource> {
293
297
  getAllMessages(): Promise<ODLiveStatusSourceData[]>;
294
298
  /**Set the opendiscord `ODMain` class to use for fetching message filters. */
295
299
  useMain(main: ODMain): void;
300
+ get<LiveStatusId extends keyof IdList>(id: LiveStatusId): IdList[LiveStatusId];
301
+ get(id: ODValidId): ODLiveStatusSource | null;
302
+ remove<LiveStatusId extends keyof IdList>(id: LiveStatusId): IdList[LiveStatusId];
303
+ remove(id: ODValidId): ODLiveStatusSource | null;
304
+ exists(id: keyof IdList): boolean;
305
+ exists(id: ODValidId): boolean;
296
306
  }
297
307
  /**## ODLiveStatusRenderer `class`
298
308
  * This is the Open Discord livestatus renderer.
@@ -548,6 +548,15 @@ class ODLiveStatusManager extends base_1.ODManager {
548
548
  useMain(main) {
549
549
  this.#main = main;
550
550
  }
551
+ get(id) {
552
+ return super.get(id);
553
+ }
554
+ remove(id) {
555
+ return super.remove(id);
556
+ }
557
+ exists(id) {
558
+ return super.exists(id);
559
+ }
551
560
  }
552
561
  exports.ODLiveStatusManager = ODLiveStatusManager;
553
562
  /**## ODLiveStatusRenderer `class`