@mostfeatured/dbi 0.0.63 → 0.0.65

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 (57) hide show
  1. package/dist/DBI.d.ts +20 -5
  2. package/dist/DBI.d.ts.map +1 -1
  3. package/dist/DBI.js +48 -17
  4. package/dist/DBI.js.map +1 -1
  5. package/dist/index.d.ts +16 -6
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +29 -16
  8. package/dist/index.js.map +1 -1
  9. package/dist/methods/hookEventListeners.d.ts.map +1 -1
  10. package/dist/methods/hookEventListeners.js +97 -87
  11. package/dist/methods/hookEventListeners.js.map +1 -1
  12. package/dist/methods/hookInteractionListeners.d.ts.map +1 -1
  13. package/dist/methods/hookInteractionListeners.js +129 -125
  14. package/dist/methods/hookInteractionListeners.js.map +1 -1
  15. package/dist/methods/publishInteractions.d.ts +8 -7
  16. package/dist/methods/publishInteractions.d.ts.map +1 -1
  17. package/dist/methods/publishInteractions.js +26 -21
  18. package/dist/methods/publishInteractions.js.map +1 -1
  19. package/dist/types/Button.js +1 -1
  20. package/dist/types/Button.js.map +1 -1
  21. package/dist/types/CustomEvent.js +19 -19
  22. package/dist/types/CustomEvent.js.map +1 -1
  23. package/dist/types/Event.d.ts +265 -263
  24. package/dist/types/Event.d.ts.map +1 -1
  25. package/dist/types/Event.js +24 -22
  26. package/dist/types/Event.js.map +1 -1
  27. package/dist/types/Interaction.d.ts +49 -47
  28. package/dist/types/Interaction.d.ts.map +1 -1
  29. package/dist/types/Interaction.js +26 -24
  30. package/dist/types/Interaction.js.map +1 -1
  31. package/dist/types/Modal.js +1 -1
  32. package/dist/types/Modal.js.map +1 -1
  33. package/dist/types/SelectMenu.js +1 -1
  34. package/dist/types/SelectMenu.js.map +1 -1
  35. package/dist/utils/customId.d.ts +1 -1
  36. package/dist/utils/customId.d.ts.map +1 -1
  37. package/dist/utils/customId.js +8 -4
  38. package/dist/utils/customId.js.map +1 -1
  39. package/dist/utils/recursiveImport.d.ts +5 -4
  40. package/dist/utils/recursiveImport.d.ts.map +1 -1
  41. package/dist/utils/recursiveImport.js +27 -26
  42. package/dist/utils/recursiveImport.js.map +1 -1
  43. package/generated/namespaceData.d.ts +2 -1
  44. package/package.json +2 -1
  45. package/src/DBI.ts +75 -23
  46. package/src/index.ts +18 -2
  47. package/src/methods/hookEventListeners.ts +21 -7
  48. package/src/methods/hookInteractionListeners.ts +6 -2
  49. package/src/methods/publishInteractions.ts +30 -25
  50. package/src/types/Button.ts +2 -2
  51. package/src/types/CustomEvent.ts +1 -1
  52. package/src/types/Event.ts +4 -2
  53. package/src/types/Interaction.ts +5 -2
  54. package/src/types/Modal.ts +2 -2
  55. package/src/types/SelectMenu.ts +2 -2
  56. package/src/utils/customId.ts +4 -2
  57. package/src/utils/recursiveImport.ts +4 -3
@@ -1,48 +1,50 @@
1
- import Discord from "discord.js";
2
- import { NamespaceEnums } from "../../generated/namespaceData";
3
- import { DBI } from "../DBI";
4
- import { DBIButton } from "./Button";
5
- import { DBIChatInput } from "./ChatInput/ChatInput";
6
- import { DBILocale } from "./Locale";
7
- import { DBIMessageContextMenu } from "./MessageContextMenu";
8
- import { DBIModal } from "./Modal";
9
- import { DBISelectMenu } from "./SelectMenu";
10
- import { DBIUserContextMenu } from "./UserContextMenu";
11
- export declare type TDBIInteractions<TNamespace extends NamespaceEnums> = DBIChatInput<TNamespace> | DBIButton<TNamespace> | DBISelectMenu<TNamespace> | DBIMessageContextMenu<TNamespace> | DBIUserContextMenu<TNamespace> | DBIModal<TNamespace>;
12
- export interface IDBIBaseExecuteCtx<TNamespace extends NamespaceEnums> {
13
- interaction: Discord.ChatInputCommandInteraction | Discord.UserContextMenuCommandInteraction | Discord.MessageContextMenuCommandInteraction | Discord.ModalSubmitInteraction | Discord.AutocompleteInteraction | Discord.SelectMenuInteraction | Discord.ButtonInteraction;
14
- locale: {
15
- user: DBILocale<TNamespace>;
16
- guild?: DBILocale<TNamespace>;
17
- };
18
- dbi: DBI<TNamespace>;
19
- dbiInteraction: TDBIInteractions<TNamespace>;
20
- setRateLimit(type: TDBIRateLimitTypes, duration: number): Promise<any>;
21
- other: Record<string, any>;
22
- }
23
- export declare type TDBIReferencedData = ({
24
- [key: string]: any;
25
- $ref: string;
26
- $unRef(): boolean;
27
- } | string | number);
28
- export declare type TDBIInteractionTypes = "ChatInput" | "UserContextMenu" | "MessageContextMenu" | "Modal" | "Autocomplete" | "SelectMenu" | "Button";
29
- export declare type TDBIRateLimitTypes = "User" | "Channel" | "Guild" | "Member" | "Message";
30
- export declare type DBIRateLimit = {
31
- type: TDBIRateLimitTypes;
32
- /**
33
- * Duration in milliseconds.
34
- */
35
- duration: number;
36
- };
37
- export declare class DBIBaseInteraction<TNamespace extends NamespaceEnums> {
38
- constructor(dbi: DBI<TNamespace>, cfg: Omit<DBIBaseInteraction<TNamespace>, "dbi">);
39
- dbi: DBI<TNamespace>;
40
- name: string;
41
- description: string;
42
- readonly type: TDBIInteractionTypes;
43
- options?: any | any[];
44
- other?: Record<string, any>;
45
- rateLimits?: DBIRateLimit[];
46
- onExecute(ctx: IDBIBaseExecuteCtx<TNamespace>): Promise<void> | void;
47
- }
1
+ import Discord from "discord.js";
2
+ import { NamespaceEnums, NamespaceData } from "../../generated/namespaceData";
3
+ import { DBI } from "../DBI";
4
+ import { DBIButton } from "./Button";
5
+ import { DBIChatInput } from "./ChatInput/ChatInput";
6
+ import { DBILocale } from "./Locale";
7
+ import { DBIMessageContextMenu } from "./MessageContextMenu";
8
+ import { DBIModal } from "./Modal";
9
+ import { DBISelectMenu } from "./SelectMenu";
10
+ import { DBIUserContextMenu } from "./UserContextMenu";
11
+ export declare type TDBIInteractions<TNamespace extends NamespaceEnums> = DBIChatInput<TNamespace> | DBIButton<TNamespace> | DBISelectMenu<TNamespace> | DBIMessageContextMenu<TNamespace> | DBIUserContextMenu<TNamespace> | DBIModal<TNamespace>;
12
+ export interface IDBIBaseExecuteCtx<TNamespace extends NamespaceEnums> {
13
+ interaction: Discord.ChatInputCommandInteraction | Discord.UserContextMenuCommandInteraction | Discord.MessageContextMenuCommandInteraction | Discord.ModalSubmitInteraction | Discord.AutocompleteInteraction | Discord.SelectMenuInteraction | Discord.ButtonInteraction;
14
+ locale: {
15
+ user: DBILocale<TNamespace>;
16
+ guild?: DBILocale<TNamespace>;
17
+ };
18
+ dbi: DBI<TNamespace>;
19
+ dbiInteraction: TDBIInteractions<TNamespace>;
20
+ setRateLimit(type: TDBIRateLimitTypes, duration: number): Promise<any>;
21
+ other: Record<string, any>;
22
+ clientNamespace: NamespaceData[TNamespace]["clientNamespaces"];
23
+ }
24
+ export declare type TDBIReferencedData = ({
25
+ [key: string]: any;
26
+ $ref: string;
27
+ $unRef(): boolean;
28
+ } | string | number);
29
+ export declare type TDBIInteractionTypes = "ChatInput" | "UserContextMenu" | "MessageContextMenu" | "Modal" | "Autocomplete" | "SelectMenu" | "Button";
30
+ export declare type TDBIRateLimitTypes = "User" | "Channel" | "Guild" | "Member" | "Message";
31
+ export declare type DBIRateLimit = {
32
+ type: TDBIRateLimitTypes;
33
+ /**
34
+ * Duration in milliseconds.
35
+ */
36
+ duration: number;
37
+ };
38
+ export declare class DBIBaseInteraction<TNamespace extends NamespaceEnums> {
39
+ constructor(dbi: DBI<TNamespace>, cfg: Omit<DBIBaseInteraction<TNamespace>, "dbi">);
40
+ publish?: NamespaceData[TNamespace]["clientNamespaces"];
41
+ dbi: DBI<TNamespace>;
42
+ name: string;
43
+ description: string;
44
+ readonly type: TDBIInteractionTypes;
45
+ options?: any | any[];
46
+ other?: Record<string, any>;
47
+ rateLimits?: DBIRateLimit[];
48
+ onExecute(ctx: IDBIBaseExecuteCtx<TNamespace>): Promise<void> | void;
49
+ }
48
50
  //# sourceMappingURL=Interaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Interaction.d.ts","sourceRoot":"","sources":["../../src/types/Interaction.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAA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AAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;IAC5B,SAAS,CAAC,GAAG,EAAE,kBAAkB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CAGrE"}
@@ -1,25 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DBIBaseInteraction = void 0;
4
- class DBIBaseInteraction {
5
- constructor(dbi, cfg) {
6
- this.dbi = dbi;
7
- this.name = cfg.name;
8
- this.description = cfg.description;
9
- this.onExecute = cfg.onExecute;
10
- this.type = cfg.type;
11
- this.options = cfg.options;
12
- this.other = cfg.other;
13
- }
14
- dbi;
15
- name;
16
- description;
17
- type;
18
- options;
19
- other;
20
- rateLimits;
21
- onExecute(ctx) {
22
- }
23
- }
24
- exports.DBIBaseInteraction = DBIBaseInteraction;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DBIBaseInteraction = void 0;
4
+ class DBIBaseInteraction {
5
+ constructor(dbi, cfg) {
6
+ this.dbi = dbi;
7
+ this.name = cfg.name;
8
+ this.description = cfg.description;
9
+ this.onExecute = cfg.onExecute;
10
+ this.type = cfg.type;
11
+ this.options = cfg.options;
12
+ this.other = cfg.other;
13
+ this.publish = cfg.publish ?? dbi.data.clients.first()?.namespace;
14
+ }
15
+ publish;
16
+ dbi;
17
+ name;
18
+ description;
19
+ type;
20
+ options;
21
+ other;
22
+ rateLimits;
23
+ onExecute(ctx) {
24
+ }
25
+ }
26
+ exports.DBIBaseInteraction = DBIBaseInteraction;
25
27
  //# sourceMappingURL=Interaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Interaction.js","sourceRoot":"","sources":["../../src/types/Interaction.ts"],"names":[],"mappings":";;;AA2DA,MAAa,kBAAkB;IAC7B,YAAY,GAAoB,EAAE,GAAgD;QAChF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,GAAG,CAAkB;IACrB,IAAI,CAAS;IACb,WAAW,CAAS;IACX,IAAI,CAAuB;IACpC,OAAO,CAAe;IACtB,KAAK,CAAuB;IAC5B,UAAU,CAAkB;IAC5B,SAAS,CAAC,GAAmC;IAE7C,CAAC;CACF;AArBD,gDAqBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIButton } from \"./Button\";\r\nimport { DBIChatInput } from \"./ChatInput/ChatInput\";\r\nimport { DBILocale } from \"./Locale\";\r\nimport { DBIMessageContextMenu } from \"./MessageContextMenu\";\r\nimport { DBIModal } from \"./Modal\";\r\nimport { DBISelectMenu } from \"./SelectMenu\";\r\nimport { DBIUserContextMenu } from \"./UserContextMenu\";\r\n\r\nexport type TDBIInteractions<TNamespace extends NamespaceEnums> = DBIChatInput<TNamespace> | DBIButton<TNamespace> | DBISelectMenu<TNamespace> | DBIMessageContextMenu<TNamespace> | DBIUserContextMenu<TNamespace> | DBIModal<TNamespace>;\r\n\r\nexport interface IDBIBaseExecuteCtx<TNamespace extends NamespaceEnums> {\r\n interaction:\r\n | Discord.ChatInputCommandInteraction\r\n | Discord.UserContextMenuCommandInteraction\r\n | Discord.MessageContextMenuCommandInteraction\r\n | Discord.ModalSubmitInteraction\r\n | Discord.AutocompleteInteraction\r\n | Discord.SelectMenuInteraction\r\n | Discord.ButtonInteraction;\r\n locale: {\r\n user: DBILocale<TNamespace>,\r\n guild?: DBILocale<TNamespace>\r\n }\r\n dbi: DBI<TNamespace>;\r\n dbiInteraction: TDBIInteractions<TNamespace>;\r\n setRateLimit(type: TDBIRateLimitTypes, duration: number): Promise<any>;\r\n other: Record<string, any>;\r\n}\r\n\r\nexport type TDBIReferencedData = ({ [key: string]: any, $ref: string, $unRef(): boolean } | string | number);\r\n\r\nexport type TDBIInteractionTypes =\r\n | \"ChatInput\"\r\n | \"UserContextMenu\"\r\n | \"MessageContextMenu\"\r\n | \"Modal\"\r\n | \"Autocomplete\"\r\n | \"SelectMenu\"\r\n | \"Button\";\r\n\r\nexport type TDBIRateLimitTypes =\r\n | \"User\"\r\n | \"Channel\"\r\n | \"Guild\"\r\n | \"Member\"\r\n | \"Message\";\r\n\r\n\r\nexport type DBIRateLimit = {\r\n type: TDBIRateLimitTypes;\r\n /**\r\n * Duration in milliseconds.\r\n */\r\n duration: number;\r\n}\r\n\r\nexport class DBIBaseInteraction<TNamespace extends NamespaceEnums> {\r\n constructor(dbi: DBI<TNamespace>, cfg: Omit<DBIBaseInteraction<TNamespace>, \"dbi\">) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this.description = cfg.description;\r\n this.onExecute = cfg.onExecute;\r\n this.type = cfg.type;\r\n this.options = cfg.options;\r\n this.other = cfg.other;\r\n }\r\n\r\n dbi: DBI<TNamespace>;\r\n name: string;\r\n description: string;\r\n readonly type: TDBIInteractionTypes;\r\n options?: any | any[];\r\n other?: Record<string, any>;\r\n rateLimits?: DBIRateLimit[];\r\n onExecute(ctx: IDBIBaseExecuteCtx<TNamespace>): Promise<void> | void {\r\n\r\n }\r\n}"]}
1
+ {"version":3,"file":"Interaction.js","sourceRoot":"","sources":["../../src/types/Interaction.ts"],"names":[],"mappings":";;;AA4DA,MAAa,kBAAkB;IAC7B,YAAY,GAAoB,EAAE,GAAgD;QAChF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC;IACpE,CAAC;IAED,OAAO,CAAiD;IACxD,GAAG,CAAkB;IACrB,IAAI,CAAS;IACb,WAAW,CAAS;IACX,IAAI,CAAuB;IACpC,OAAO,CAAe;IACtB,KAAK,CAAuB;IAC5B,UAAU,CAAkB;IAC5B,SAAS,CAAC,GAAmC;IAE7C,CAAC;CACF;AAvBD,gDAuBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { NamespaceEnums, NamespaceData } from \"../../generated/namespaceData\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIButton } from \"./Button\";\r\nimport { DBIChatInput } from \"./ChatInput/ChatInput\";\r\nimport { DBILocale } from \"./Locale\";\r\nimport { DBIMessageContextMenu } from \"./MessageContextMenu\";\r\nimport { DBIModal } from \"./Modal\";\r\nimport { DBISelectMenu } from \"./SelectMenu\";\r\nimport { DBIUserContextMenu } from \"./UserContextMenu\";\r\n\r\nexport type TDBIInteractions<TNamespace extends NamespaceEnums> = DBIChatInput<TNamespace> | DBIButton<TNamespace> | DBISelectMenu<TNamespace> | DBIMessageContextMenu<TNamespace> | DBIUserContextMenu<TNamespace> | DBIModal<TNamespace>;\r\n\r\nexport interface IDBIBaseExecuteCtx<TNamespace extends NamespaceEnums> {\r\n interaction:\r\n | Discord.ChatInputCommandInteraction\r\n | Discord.UserContextMenuCommandInteraction\r\n | Discord.MessageContextMenuCommandInteraction\r\n | Discord.ModalSubmitInteraction\r\n | Discord.AutocompleteInteraction\r\n | Discord.SelectMenuInteraction\r\n | Discord.ButtonInteraction;\r\n locale: {\r\n user: DBILocale<TNamespace>,\r\n guild?: DBILocale<TNamespace>\r\n }\r\n dbi: DBI<TNamespace>;\r\n dbiInteraction: TDBIInteractions<TNamespace>;\r\n setRateLimit(type: TDBIRateLimitTypes, duration: number): Promise<any>;\r\n other: Record<string, any>;\r\n clientNamespace: NamespaceData[TNamespace][\"clientNamespaces\"];\r\n}\r\n\r\nexport type TDBIReferencedData = ({ [key: string]: any, $ref: string, $unRef(): boolean } | string | number);\r\n\r\nexport type TDBIInteractionTypes =\r\n | \"ChatInput\"\r\n | \"UserContextMenu\"\r\n | \"MessageContextMenu\"\r\n | \"Modal\"\r\n | \"Autocomplete\"\r\n | \"SelectMenu\"\r\n | \"Button\";\r\n\r\nexport type TDBIRateLimitTypes =\r\n | \"User\"\r\n | \"Channel\"\r\n | \"Guild\"\r\n | \"Member\"\r\n | \"Message\";\r\n\r\n\r\nexport type DBIRateLimit = {\r\n type: TDBIRateLimitTypes;\r\n /**\r\n * Duration in milliseconds.\r\n */\r\n duration: number;\r\n}\r\n\r\nexport class DBIBaseInteraction<TNamespace extends NamespaceEnums> {\r\n constructor(dbi: DBI<TNamespace>, cfg: Omit<DBIBaseInteraction<TNamespace>, \"dbi\">) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this.description = cfg.description;\r\n this.onExecute = cfg.onExecute;\r\n this.type = cfg.type;\r\n this.options = cfg.options;\r\n this.other = cfg.other;\r\n this.publish = cfg.publish ?? dbi.data.clients.first()?.namespace;\r\n }\r\n \r\n publish?: NamespaceData[TNamespace][\"clientNamespaces\"];\r\n dbi: DBI<TNamespace>;\r\n name: string;\r\n description: string;\r\n readonly type: TDBIInteractionTypes;\r\n options?: any | any[];\r\n other?: Record<string, any>;\r\n rateLimits?: DBIRateLimit[];\r\n onExecute(ctx: IDBIBaseExecuteCtx<TNamespace>): Promise<void> | void {\r\n\r\n }\r\n}"]}
@@ -18,7 +18,7 @@ class DBIModal extends Interaction_1.DBIBaseInteraction {
18
18
  toJSON(arg = {}) {
19
19
  return {
20
20
  ...stuffs_1.default.defaultify((arg?.overrides || {}), this.options || {}, true),
21
- customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl)
21
+ customId: (0, customId_1.buildCustomId)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl)
22
22
  };
23
23
  }
24
24
  ;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;;AACA,+CAA2F;AAE3F,gDAAoD;AAGpD,4DAA4B;AAC5B,iDAAoE;AAgBpE,MAAa,QAA4C,SAAQ,gCAA8B;IAC7F,YAAY,GAAoB,EAAE,IAAkC;QAClE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAoC,IAA0B,CAAC;IAAA,CAAC;IAEnF,MAAM,CAAC,MAAyC,EAAE;QAChD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;SAChG,CAAC;IACX,CAAC;IAAA,CAAC;IAEF,aAAa,CAAC,MAAyC,EAAE;QACvD,OAAO,IAAI,8BAAe,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;CAEF;AAvBD,4BAuBC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\nimport { customIdBuilder } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBIModalBuilder, DBIModalOverrides } from \"./ModalBuilder\";\r\n\r\n\r\nexport interface IDBIModalExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ModalSubmitInteraction<\"cached\">;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport interface ModalComponentData {\r\n title: string;\r\n components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];\r\n}\r\n\r\nexport type TDBIModalOmitted<TNamespace extends NamespaceEnums> = Omit<DBIModal<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBIModal<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBIModalOmitted<TNamespace>) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Modal\"\r\n });\r\n }\r\n\r\n declare options: ModalComponentData;\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx<TNamespace>): Promise<void> | void { };\r\n\r\n toJSON(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): Discord.ModalComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: customIdBuilder(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl)\r\n } as any;\r\n };\r\n\r\n createBuilder(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): DBIModalBuilder<TNamespace> {\r\n return new DBIModalBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
1
+ {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;;AACA,+CAA2F;AAE3F,gDAAkD;AAGlD,4DAA4B;AAC5B,iDAAoE;AAgBpE,MAAa,QAA4C,SAAQ,gCAA8B;IAC7F,YAAY,GAAoB,EAAE,IAAkC;QAClE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAoC,IAA0B,CAAC;IAAA,CAAC;IAEnF,MAAM,CAAC,MAAyC,EAAE;QAChD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,wBAAa,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;SAC9F,CAAC;IACX,CAAC;IAAA,CAAC;IAEF,aAAa,CAAC,MAAyC,EAAE;QACvD,OAAO,IAAI,8BAAe,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;CAEF;AAvBD,4BAuBC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\nimport { buildCustomId } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBIModalBuilder, DBIModalOverrides } from \"./ModalBuilder\";\r\n\r\n\r\nexport interface IDBIModalExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ModalSubmitInteraction<\"cached\">;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport interface ModalComponentData {\r\n title: string;\r\n components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];\r\n}\r\n\r\nexport type TDBIModalOmitted<TNamespace extends NamespaceEnums> = Omit<DBIModal<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBIModal<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBIModalOmitted<TNamespace>) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Modal\"\r\n });\r\n }\r\n\r\n declare options: ModalComponentData;\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx<TNamespace>): Promise<void> | void { };\r\n\r\n toJSON(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): Discord.ModalComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl)\r\n } as any;\r\n };\r\n\r\n createBuilder(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): DBIModalBuilder<TNamespace> {\r\n return new DBIModalBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
@@ -19,7 +19,7 @@ class DBISelectMenu extends Interaction_1.DBIBaseInteraction {
19
19
  toJSON(arg = {}) {
20
20
  return {
21
21
  ...stuffs_1.default.defaultify((arg?.overrides || {}), this.options || {}, true),
22
- customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
22
+ customId: (0, customId_1.buildCustomId)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
23
23
  type: discord_js_1.default.ComponentType.SelectMenu,
24
24
  };
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAoD;AAGpD,4DAA4B;AAC5B,2DAAmF;AAUnF,MAAa,aAAiD,SAAQ,gCAA8B;IAClG,YAAY,GAAoB,EAAE,IAAuC;QACvE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAyC,IAA0B,CAAC;IAAA,CAAC;IAExF,MAAM,CAAC,MAA8C,EAAE;QACrD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;YACtG,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,UAAU;SAChC,CAAC;IACX,CAAC;IAAA,CAAC;IAEF,aAAa,CAAC,MAA8C,EAAE;QAC5D,OAAO,IAAI,wCAAoB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IAC9D,CAAC;CAEF;AAxBD,sCAwBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport { customIdBuilder } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBISelectMenuBuilder, DBISelectMenuOverrides } from \"./SelectMenuBuilder\";\r\n\r\n\r\nexport interface IDBISelectMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBISelectMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBISelectMenu<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBISelectMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBISelectMenuOmitted<TNamespace>) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"SelectMenu\",\r\n });\r\n }\r\n\r\n declare options: Omit<Discord.BaseSelectMenuComponentData, \"customId\" | \"type\">;\r\n\r\n override onExecute(ctx: IDBISelectMenuExecuteCtx<TNamespace>): Promise<void> | void { };\r\n\r\n toJSON(arg: IDBIToJSONArgs<DBISelectMenuOverrides> = {}): Discord.BaseSelectMenuComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: customIdBuilder(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),\r\n type: Discord.ComponentType.SelectMenu,\r\n } as any;\r\n };\r\n\r\n createBuilder(arg: IDBIToJSONArgs<DBISelectMenuOverrides> = {}): DBISelectMenuBuilder<TNamespace> {\r\n return new DBISelectMenuBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
1
+ {"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAkD;AAGlD,4DAA4B;AAC5B,2DAAmF;AAUnF,MAAa,aAAiD,SAAQ,gCAA8B;IAClG,YAAY,GAAoB,EAAE,IAAuC;QACvE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAyC,IAA0B,CAAC;IAAA,CAAC;IAExF,MAAM,CAAC,MAA8C,EAAE;QACrD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,wBAAa,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;YACpG,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,UAAU;SAChC,CAAC;IACX,CAAC;IAAA,CAAC;IAEF,aAAa,CAAC,MAA8C,EAAE;QAC5D,OAAO,IAAI,wCAAoB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IAC9D,CAAC;CAEF;AAxBD,sCAwBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport { buildCustomId } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBISelectMenuBuilder, DBISelectMenuOverrides } from \"./SelectMenuBuilder\";\r\n\r\n\r\nexport interface IDBISelectMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBISelectMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBISelectMenu<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBISelectMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBISelectMenuOmitted<TNamespace>) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"SelectMenu\",\r\n });\r\n }\r\n\r\n declare options: Omit<Discord.BaseSelectMenuComponentData, \"customId\" | \"type\">;\r\n\r\n override onExecute(ctx: IDBISelectMenuExecuteCtx<TNamespace>): Promise<void> | void { };\r\n\r\n toJSON(arg: IDBIToJSONArgs<DBISelectMenuOverrides> = {}): Discord.BaseSelectMenuComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),\r\n type: Discord.ComponentType.SelectMenu,\r\n } as any;\r\n };\r\n\r\n createBuilder(arg: IDBIToJSONArgs<DBISelectMenuOverrides> = {}): DBISelectMenuBuilder<TNamespace> {\r\n return new DBISelectMenuBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
@@ -1,6 +1,6 @@
1
1
  import { DBI } from "../DBI";
2
2
  import { NamespaceEnums } from "../../generated/namespaceData";
3
- export declare function customIdBuilder(dbi: DBI<NamespaceEnums>, name: string, customData: any[], ttl?: number): string;
3
+ export declare function buildCustomId(dbi: DBI<NamespaceEnums>, name: string, data: any[], ttl?: number): string;
4
4
  export declare function parseCustomId(dbi: DBI<NamespaceEnums>, customId: string): {
5
5
  name: string;
6
6
  data: any[];
@@ -1 +1 @@
1
- {"version":3,"file":"customId.d.ts","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,EAAC,MAAM,GAAG,MAAM,CAkB9G;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAA;CAAC,CAYrG"}
1
+ {"version":3,"file":"customId.d.ts","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,EAAC,MAAM,GAAG,MAAM,CAmBtG;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAA;CAAC,CAarG"}
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseCustomId = exports.customIdBuilder = void 0;
3
+ exports.parseCustomId = exports.buildCustomId = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const stuffs = tslib_1.__importStar(require("stuffs"));
6
- function customIdBuilder(dbi, name, customData, ttl) {
6
+ function buildCustomId(dbi, name, data, ttl) {
7
7
  let customId = [
8
8
  name,
9
- ...customData.map(value => {
9
+ ...data.map(value => {
10
10
  if (typeof value == "string")
11
11
  return value;
12
12
  if (typeof value == "number")
13
13
  return `π${value}`;
14
+ if (typeof value == "boolean")
15
+ return `𝞫${value ? 1 : 0}`;
14
16
  let id = stuffs.randomString(8);
15
17
  Object.assign(value, {
16
18
  $ref: id,
@@ -26,13 +28,15 @@ function customIdBuilder(dbi, name, customData, ttl) {
26
28
  throw new Error("Custom id cannot be longer than 100 characters.");
27
29
  return customId;
28
30
  }
29
- exports.customIdBuilder = customIdBuilder;
31
+ exports.buildCustomId = buildCustomId;
30
32
  function parseCustomId(dbi, customId) {
31
33
  let splitted = customId.split("—");
32
34
  let name = splitted.shift();
33
35
  let data = splitted.map(value => {
34
36
  if (value.startsWith("π"))
35
37
  return Number(value.slice(1));
38
+ if (value.startsWith("𝞫"))
39
+ return !!Number(value.slice(1));
36
40
  if (value.startsWith("¤"))
37
41
  return dbi.data.refs.get(value.slice(1))?.value;
38
42
  return value;
@@ -1 +1 @@
1
- {"version":3,"file":"customId.js","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AAGjC,SAAgB,eAAe,CAAC,GAAwB,EAAE,IAAY,EAAE,UAAiB,EAAE,GAAW;IACpG,IAAI,QAAQ,GAAG;QACb,IAAI;QACJ,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACxB,IAAI,OAAO,KAAK,IAAI,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAC3C,IAAI,OAAO,KAAK,IAAI,QAAQ;gBAAE,OAAO,IAAI,KAAK,EAAE,CAAC;YACjD,IAAI,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;gBACnB,IAAI,EAAE,EAAE;gBACR,MAAM,KAAK,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;aAC9C,CAAC,CAAA;YACF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACtD,OAAO,IAAI,EAAE,EAAE,CAAC;QAClB,CAAC,CAAC;KACH,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM;QAAE,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;IAC7F,OAAO,QAAQ,CAAC;AAClB,CAAC;AAlBD,0CAkBC;AAED,SAAgB,aAAa,CAAC,GAAwB,EAAE,QAAgB;IACtE,IAAI,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,IAAI,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC5B,IAAI,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAC9B,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO;QACL,IAAI;QACJ,IAAI;KACL,CAAA;AACH,CAAC;AAZD,sCAYC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport * as stuffs from \"stuffs\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\n\r\nexport function customIdBuilder(dbi: DBI<NamespaceEnums>, name: string, customData: any[], ttl?:number): string {\r\n let customId = [\r\n name,\r\n ...customData.map(value => {\r\n if (typeof value == \"string\") return value;\r\n if (typeof value == \"number\") return `π${value}`;\r\n let id = stuffs.randomString(8);\r\n Object.assign(value, {\r\n $ref: id,\r\n $unRef() { return dbi.data.refs.delete(id); },\r\n })\r\n dbi.data.refs.set(id, { at: Date.now(), value, ttl });\r\n return `¤${id}`;\r\n })\r\n ].join(\"—\");\r\n if (!dbi.config.strict) customId = customId.slice(0, 100);\r\n if (customId.length > 100) throw new Error(\"Custom id cannot be longer than 100 characters.\")\r\n return customId;\r\n}\r\n\r\nexport function parseCustomId(dbi: DBI<NamespaceEnums>, customId: string): {name: string, data: any[]} {\r\n let splitted = customId.split(\"—\");\r\n let name = splitted.shift();\r\n let data = splitted.map(value => {\r\n if (value.startsWith(\"π\")) return Number(value.slice(1));\r\n if (value.startsWith(\"¤\")) return dbi.data.refs.get(value.slice(1))?.value;\r\n return value;\r\n });\r\n return {\r\n name,\r\n data\r\n }\r\n}"]}
1
+ {"version":3,"file":"customId.js","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AAGjC,SAAgB,aAAa,CAAC,GAAwB,EAAE,IAAY,EAAE,IAAW,EAAE,GAAW;IAC5F,IAAI,QAAQ,GAAG;QACb,IAAI;QACJ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAClB,IAAI,OAAO,KAAK,IAAI,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAC3C,IAAI,OAAO,KAAK,IAAI,QAAQ;gBAAE,OAAO,IAAI,KAAK,EAAE,CAAC;YACjD,IAAI,OAAO,KAAK,IAAI,SAAS;gBAAE,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3D,IAAI,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,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,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO;QACL,IAAI;QACJ,IAAI;KACL,CAAA;AACH,CAAC;AAbD,sCAaC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport * as stuffs from \"stuffs\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\n\r\nexport function buildCustomId(dbi: DBI<NamespaceEnums>, name: string, data: any[], ttl?:number): string {\r\n let customId = [\r\n name,\r\n ...data.map(value => {\r\n if (typeof value == \"string\") return value;\r\n if (typeof value == \"number\") return `π${value}`;\r\n if (typeof value == \"boolean\") return `𝞫${value ? 1 : 0}`;\r\n let id = stuffs.randomString(8);\r\n Object.assign(value, {\r\n $ref: id,\r\n $unRef() { return dbi.data.refs.delete(id); },\r\n })\r\n dbi.data.refs.set(id, { at: Date.now(), value, ttl });\r\n return `¤${id}`;\r\n })\r\n ].join(\"—\");\r\n if (!dbi.config.strict) customId = customId.slice(0, 100);\r\n if (customId.length > 100) throw new Error(\"Custom id cannot be longer than 100 characters.\")\r\n return customId;\r\n}\r\n\r\nexport function parseCustomId(dbi: DBI<NamespaceEnums>, customId: string): {name: string, data: any[]} {\r\n let splitted = customId.split(\"—\");\r\n let name = splitted.shift();\r\n let data = splitted.map(value => {\r\n if (value.startsWith(\"π\")) return Number(value.slice(1));\r\n if (value.startsWith(\"𝞫\")) return !!Number(value.slice(1));\r\n if (value.startsWith(\"¤\")) return dbi.data.refs.get(value.slice(1))?.value;\r\n return value;\r\n });\r\n return {\r\n name,\r\n data\r\n }\r\n}"]}
@@ -1,5 +1,6 @@
1
- /**
2
- * Usage: `await recursiveImport("./src", [".js", ".ts"])`
3
- */
4
- export declare function recursiveImport(folderPath: string, exts?: string[]): Promise<any>;
1
+ /**
2
+ * @example
3
+ * await recursiveImport("./src", [".js"], [".d.ts"])
4
+ */
5
+ export declare function recursiveImport(folderPath: string, exts?: string[], ignore?: string[]): Promise<any>;
5
6
  //# sourceMappingURL=recursiveImport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"recursiveImport.d.ts","sourceRoot":"","sources":["../../src/utils/recursiveImport.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,CAevG"}
1
+ {"version":3,"file":"recursiveImport.d.ts","sourceRoot":"","sources":["../../src/utils/recursiveImport.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAY,EAAE,MAAM,GAAE,MAAM,EAAoC,GAAG,OAAO,CAAC,GAAG,CAAC,CAepJ"}
@@ -1,27 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recursiveImport = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
6
- const path_1 = tslib_1.__importDefault(require("path"));
7
- /**
8
- * Usage: `await recursiveImport("./src", [".js", ".ts"])`
9
- */
10
- async function recursiveImport(folderPath, exts = [".js", ".ts"]) {
11
- let files = await fs_1.default.promises.readdir(folderPath, { withFileTypes: true });
12
- let dirName = __dirname;
13
- for (const file of files) {
14
- let filePath = path_1.default.resolve(folderPath, file.name);
15
- let relative = path_1.default.relative(dirName, filePath);
16
- if (!relative.includes(`${path_1.default.sep}-`)) {
17
- if (file.isDirectory()) {
18
- await recursiveImport(filePath, exts);
19
- }
20
- else if (exts.some(i => file.name.endsWith(i))) {
21
- await Promise.resolve().then(() => tslib_1.__importStar(require(filePath)));
22
- }
23
- }
24
- }
25
- }
26
- exports.recursiveImport = recursiveImport;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.recursiveImport = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
+ /**
8
+ * @example
9
+ * await recursiveImport("./src", [".js"], [".d.ts"])
10
+ */
11
+ async function recursiveImport(folderPath, exts = [".js"], ignore = [".d.ts", ".js.map", ".d.ts.map"]) {
12
+ let files = await fs_1.default.promises.readdir(folderPath, { withFileTypes: true });
13
+ let dirName = __dirname;
14
+ for (const file of files) {
15
+ let filePath = path_1.default.resolve(folderPath, file.name);
16
+ let relative = path_1.default.relative(dirName, filePath);
17
+ if (!relative.includes(`${path_1.default.sep}-`)) {
18
+ if (file.isDirectory()) {
19
+ await recursiveImport(filePath, exts);
20
+ }
21
+ else if (exts.some(i => file.name.endsWith(i)) && !ignore.some(i => file.name.endsWith(i))) {
22
+ await Promise.resolve().then(() => tslib_1.__importStar(require(filePath)));
23
+ }
24
+ }
25
+ }
26
+ }
27
+ exports.recursiveImport = recursiveImport;
27
28
  //# sourceMappingURL=recursiveImport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"recursiveImport.js","sourceRoot":"","sources":["../../src/utils/recursiveImport.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AACpB,wDAAwB;AAExB;;GAEG;AACI,KAAK,UAAU,eAAe,CAAC,UAAkB,EAAE,OAAiB,CAAC,KAAK,EAAE,KAAK,CAAC;IACvF,IAAI,KAAK,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,IAAI,OAAO,GAAG,SAAS,CAAC;IAExB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,cAAI,CAAC,GAAG,GAAG,CAAC,EAAE;YACtC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;gBACtB,MAAM,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;aACtC;iBAAM,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;gBAChD,gEAAa,QAAQ,GAAC,CAAA;aACvB;SACF;KACF;AACH,CAAC;AAfD,0CAeC","sourcesContent":["import fs from \"fs\";\r\nimport path from \"path\";\r\n\r\n/**\r\n * Usage: `await recursiveImport(\"./src\", [\".js\", \".ts\"])`\r\n */\r\nexport async function recursiveImport(folderPath: string, exts: string[] = [\".js\", \".ts\"]): Promise<any> {\r\n let files = await fs.promises.readdir(folderPath, { withFileTypes: true });\r\n let dirName = __dirname;\r\n \r\n for (const file of files) {\r\n let filePath = path.resolve(folderPath, file.name);\r\n let relative = path.relative(dirName, filePath);\r\n if (!relative.includes(`${path.sep}-`)) {\r\n if (file.isDirectory()) {\r\n await recursiveImport(filePath, exts)\r\n } else if (exts.some(i => file.name.endsWith(i))) {\r\n await import(filePath)\r\n }\r\n }\r\n }\r\n}"]}
1
+ {"version":3,"file":"recursiveImport.js","sourceRoot":"","sources":["../../src/utils/recursiveImport.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AACpB,wDAAwB;AAExB;;;GAGG;AACI,KAAK,UAAU,eAAe,CAAC,UAAkB,EAAE,OAAiB,CAAC,KAAK,CAAC,EAAE,SAAmB,CAAC,OAAO,EAAC,SAAS,EAAC,WAAW,CAAC;IACpI,IAAI,KAAK,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,IAAI,OAAO,GAAG,SAAS,CAAC;IAExB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,cAAI,CAAC,GAAG,GAAG,CAAC,EAAE;YACtC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;gBACtB,MAAM,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;aACtC;iBAAM,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;gBAC5F,gEAAa,QAAQ,GAAC,CAAA;aACvB;SACF;KACF;AACH,CAAC;AAfD,0CAeC","sourcesContent":["import fs from \"fs\";\r\nimport path from \"path\";\r\n\r\n/**\r\n * @example\r\n * await recursiveImport(\"./src\", [\".js\"], [\".d.ts\"])\r\n */\r\nexport async function recursiveImport(folderPath: string, exts: string[] = [\".js\"], ignore: string[] = [\".d.ts\",\".js.map\",\".d.ts.map\"]): Promise<any> {\r\n let files = await fs.promises.readdir(folderPath, { withFileTypes: true });\r\n let dirName = __dirname;\r\n \r\n for (const file of files) {\r\n let filePath = path.resolve(folderPath, file.name);\r\n let relative = path.relative(dirName, filePath);\r\n if (!relative.includes(`${path.sep}-`)) {\r\n if (file.isDirectory()) {\r\n await recursiveImport(filePath, exts)\r\n } else if (exts.some(i => file.name.endsWith(i)) && !ignore.some(i => file.name.endsWith(i))) {\r\n await import(filePath)\r\n }\r\n }\r\n }\r\n}"]}
@@ -7,7 +7,8 @@ export interface NamespaceData {
7
7
  interactionMapping: { [k: string]: TDBIInteractions<NamespaceEnums> };
8
8
  eventNames: string;
9
9
  localeNames: TDBILocaleString;
10
- customEvents: { }
10
+ customEvents: { },
11
+ clientNamespaces: string;
11
12
  }
12
13
  }
13
14
 
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@discordjs/rest": "^1.0.1",
4
+ "async-and-quick": "^1.0.2",
4
5
  "discord-api-types": "^0.37.0",
5
6
  "discord-hybrid-sharding": "^1.7.4",
6
7
  "discord.js": "^14.7.0",
@@ -9,7 +10,7 @@
9
10
  "stuffs": "^0.1.21"
10
11
  },
11
12
  "name": "@mostfeatured/dbi",
12
- "version": "0.0.63",
13
+ "version": "0.0.65",
13
14
  "main": "dist/index.js",
14
15
  "type": "commonjs",
15
16
  "private": false,
package/src/DBI.ts CHANGED
@@ -20,6 +20,7 @@ import { DBIInteractionLocale, TDBIInteractionLocaleOmitted } from "./types/Inte
20
20
  import { TDBIInteractions } from "./types/Interaction";
21
21
  import { NamespaceData, NamespaceEnums } from "../generated/namespaceData";
22
22
  import { DBICustomEvent, TDBICustomEventOmitted } from "./types/CustomEvent";
23
+ import aaq from "async-and-quick";
23
24
 
24
25
  export interface DBIStore {
25
26
  get(key: string, defaultValue?: any): Promise<any>;
@@ -28,6 +29,8 @@ export interface DBIStore {
28
29
  has(key: string): Promise<boolean>;
29
30
  }
30
31
 
32
+ export type DBIClientData<TNamespace extends NamespaceEnums> = { namespace: NamespaceData[TNamespace]["clientNamespaces"], token: string, options: Discord.Options, client: Discord.Client<true> };
33
+
31
34
  export interface DBIConfig {
32
35
  discord: {
33
36
  token: string;
@@ -59,7 +62,12 @@ export interface DBIConfigConstructor {
59
62
  discord: {
60
63
  token: string;
61
64
  options: Discord.ClientOptions
62
- }
65
+ } | {
66
+ namespace: string,
67
+ token: string,
68
+ options: Discord.ClientOptions,
69
+ }[];
70
+
63
71
  defaults?: {
64
72
  locale?: TDBILocaleString,
65
73
  directMessages?: boolean,
@@ -105,7 +113,6 @@ export interface DBIRegisterAPI<TNamespace extends NamespaceEnums> {
105
113
  export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string, any>> {
106
114
  namespace: TNamespace;
107
115
  config: DBIConfig;
108
- client: Discord.Client<true>;
109
116
  data: {
110
117
  interactions: Discord.Collection<string, TDBIInteractions<TNamespace>>;
111
118
  events: Discord.Collection<string, DBIEvent<TNamespace>>;
@@ -118,6 +125,15 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
118
125
  registers: Set<(...args: any[]) => any>;
119
126
  registerUnloaders: Set<(...args: any[]) => any>;
120
127
  refs: Map<string, { at: number, value: any, ttl?: number }>;
128
+ clients:
129
+ & DBIClientData<TNamespace>[]
130
+ & {
131
+ next(key?: string): DBIClientData<TNamespace>,
132
+ random(): DBIClientData<TNamespace>,
133
+ first(): DBIClientData<TNamespace>,
134
+ get(namespace: NamespaceData[TNamespace]["clientNamespaces"]): DBIClientData<TNamespace>,
135
+ indexes: Record<string, number>
136
+ }
121
137
  };
122
138
  events: Events<TNamespace>;
123
139
  cluster?: Sharding.Client;
@@ -125,6 +141,7 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
125
141
  private _hooked: boolean;
126
142
  constructor(namespace: TNamespace, config: DBIConfigConstructor) {
127
143
  this.namespace = namespace as any;
144
+ const self = this;
128
145
 
129
146
  config.store = config.store as any || new MemoryStore();
130
147
  config.defaults = {
@@ -154,18 +171,50 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
154
171
  unloaders: new Set(),
155
172
  registers: new Set(),
156
173
  registerUnloaders: new Set(),
157
- refs: config.data?.refs ?? new Map()
174
+ refs: config.data?.refs ?? new Map(),
175
+ clients: Object.assign([], {
176
+ next(key = "global") {
177
+ this.indexes[key] = (((this.indexes[key] ?? -1) + 1) % this.length);
178
+ return this[this.indexes[key]];
179
+ },
180
+ random() {
181
+ return this[Math.floor(Math.random() * this.length)];
182
+ },
183
+ first() {
184
+ return this[0];
185
+ },
186
+ get(namespace: string) {
187
+ return this.find((i: any) => i.namespace === namespace);
188
+ },
189
+ indexes: {}
190
+ }) as any
158
191
  }
159
192
 
160
193
  this.events = new Events(this as any);
161
- this.client = new Discord.Client({
162
- ...(config.discord?.options || {}) as any,
163
- ...(config.sharding == "hybrid" ? {
164
- shards: (Sharding as any).data.SHARD_LIST,
165
- shardCount: (Sharding as any).data.TOTAL_SHARDS
166
- } : {})
167
- });
168
- this.cluster = config.sharding == "hybrid" ? new Sharding.Client(this.client) : undefined;
194
+
195
+ this.data.clients.push(...(
196
+ (
197
+ Array.isArray(config.discord) ?
198
+ config.discord :
199
+ [{ token: config.discord.token, options: config.discord.options, namespace: "default" }]
200
+ ) as any
201
+ ));
202
+ for (let clientContext of this.data.clients) {
203
+ let client = new Discord.Client({
204
+ ...(clientContext.options || {}) as any,
205
+ ...(config.sharding == "hybrid" ? {
206
+ shards: (Sharding as any).data.SHARD_LIST,
207
+ shardCount: (Sharding as any).data.TOTAL_SHARDS
208
+ } : {})
209
+ });
210
+ clientContext.client = client;
211
+ }
212
+
213
+ if (this.data.clients.length === 0) throw new Error("No clients provided.");
214
+ if (this.data.clients.length !== 1 && !(config.sharding && config.sharding === "off"))
215
+ throw new Error("Sharding only supports 1 client.");
216
+
217
+ this.cluster = config.sharding == "hybrid" ? new Sharding.Client(this.data.clients[0].client) : undefined;
169
218
  this._loaded = false;
170
219
  this._hooked = false;
171
220
  }
@@ -290,7 +339,7 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
290
339
  };
291
340
  CustomEvent = Object.assign(CustomEvent, class { constructor(...args: any[]) { return CustomEvent.apply(this, args as any); } });
292
341
 
293
- let InteractionLocale = function(cfg: TDBIInteractionLocaleOmitted) {
342
+ let InteractionLocale = function (cfg: TDBIInteractionLocaleOmitted) {
294
343
  let dbiInteractionLocale = new DBIInteractionLocale(self, cfg);
295
344
  if (self.config.strict && self.data.interactionLocales.has(dbiInteractionLocale.name)) throw new Error(`DBIInteractionLocale "${dbiInteractionLocale.name}" already loaded!`);
296
345
  self.data.interactionLocales.set(dbiInteractionLocale.name, dbiInteractionLocale);
@@ -324,16 +373,17 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
324
373
  return this.data.interactions.get(name as any) as any;
325
374
  }
326
375
 
327
- emit<TEventName extends keyof (NamespaceData[TNamespace]["customEvents"] & ClientEvents)>(name: TEventName, args: (NamespaceData[TNamespace]["customEvents"] & ClientEvents)[TEventName] ): void {
328
- this.client.emit(name as any, { ...args, _DIRECT_: true } as any);
376
+ emit<TEventName extends keyof (NamespaceData[TNamespace]["customEvents"] & ClientEvents)>(name: TEventName, args: (NamespaceData[TNamespace]["customEvents"] & ClientEvents)[TEventName]): void {
377
+ this.data.clients.forEach((d) => d.client.emit(name as any, { ...args, _DIRECT_: true } as any));
329
378
  }
330
379
 
331
- /**
332
- *
333
- * ((NamespaceData[TNamespace]["customEvents"] & ClientEvents)[K] as const)
334
- * typeof ((NamespaceData[TNamespace]["customEvents"] & ClientEvents)[K])[keyof typeof ((NamespaceData[TNamespace]["customEvents"] & ClientEvents)[K])]
335
- */
336
-
380
+ /**
381
+ * @deprecated
382
+ */
383
+ get client() {
384
+ console.log("[DEPRECTED] dbi.client is a deprected api. Please use dbi.data.clients.first().client instead.", Error().stack);
385
+ return this.data.clients[0]?.client;
386
+ }
337
387
  /**
338
388
  * this.data.events.get(name)
339
389
  */
@@ -381,7 +431,9 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
381
431
  }
382
432
 
383
433
  async login(): Promise<any> {
384
- await this.client.login(this.config.sharding == "default" ? undefined : this.config.discord.token);
434
+ await aaq.quickForEach(this.data.clients, async (clientContext) => {
435
+ await clientContext.client.login(this.config.sharding == "default" ? null : clientContext.token);
436
+ });
385
437
  }
386
438
 
387
439
  async register(cb: (api: DBIRegisterAPI<TNamespace>) => void): Promise<any> {
@@ -416,7 +468,7 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
416
468
  switch (args[0]) {
417
469
  case "Global": {
418
470
  return await publishInteractions(
419
- this.config.discord.token,
471
+ this.data.clients,
420
472
  args[1] ? new Discord.Collection() : interactions,
421
473
  this.data.interactionLocales,
422
474
  args[0]
@@ -424,7 +476,7 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
424
476
  }
425
477
  case "Guild": {
426
478
  return await publishInteractions(
427
- this.config.discord.token,
479
+ this.data.clients,
428
480
  args[2] ? new Discord.Collection() : interactions,
429
481
  this.data.interactionLocales,
430
482
  args[0],