@mostfeatured/dbi 0.0.25 → 0.0.28

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 (42) hide show
  1. package/dist/DBI.d.ts +10 -6
  2. package/dist/DBI.d.ts.map +1 -1
  3. package/dist/DBI.js +29 -1
  4. package/dist/DBI.js.map +1 -1
  5. package/dist/index.d.ts +2 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/methods/publishInteractions.d.ts.map +1 -1
  9. package/dist/methods/publishInteractions.js +27 -12
  10. package/dist/methods/publishInteractions.js.map +1 -1
  11. package/dist/types/Button.d.ts +1 -1
  12. package/dist/types/Button.d.ts.map +1 -1
  13. package/dist/types/Button.js +1 -1
  14. package/dist/types/Button.js.map +1 -1
  15. package/dist/types/ChatInput/ChatInputOptions.d.ts +6 -0
  16. package/dist/types/ChatInput/ChatInputOptions.d.ts.map +1 -1
  17. package/dist/types/ChatInput/ChatInputOptions.js +8 -0
  18. package/dist/types/ChatInput/ChatInputOptions.js.map +1 -1
  19. package/dist/types/InteractionLocale.d.ts +3 -0
  20. package/dist/types/InteractionLocale.d.ts.map +1 -1
  21. package/dist/types/InteractionLocale.js.map +1 -1
  22. package/dist/types/Locale.d.ts +4 -4
  23. package/dist/types/Locale.d.ts.map +1 -1
  24. package/dist/types/Locale.js.map +1 -1
  25. package/dist/types/Modal.d.ts +1 -1
  26. package/dist/types/Modal.d.ts.map +1 -1
  27. package/dist/types/Modal.js +1 -1
  28. package/dist/types/Modal.js.map +1 -1
  29. package/dist/types/SelectMenu.d.ts +1 -1
  30. package/dist/types/SelectMenu.d.ts.map +1 -1
  31. package/dist/types/SelectMenu.js +1 -1
  32. package/dist/types/SelectMenu.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/DBI.ts +43 -12
  35. package/src/index.ts +3 -2
  36. package/src/methods/publishInteractions.ts +24 -9
  37. package/src/types/Button.ts +2 -2
  38. package/src/types/ChatInput/ChatInputOptions.ts +9 -0
  39. package/src/types/InteractionLocale.ts +3 -0
  40. package/src/types/Locale.ts +6 -6
  41. package/src/types/Modal.ts +2 -2
  42. package/src/types/SelectMenu.ts +2 -2
package/dist/DBI.d.ts CHANGED
@@ -3,7 +3,7 @@ import { DBIChatInput, TDBIChatInputOmitted } from "./types/ChatInput/ChatInput"
3
3
  import { DBIChatInputOptions } from "./types/ChatInput/ChatInputOptions";
4
4
  import { DBIEvent, TDBIEventOmitted } from "./types/Event";
5
5
  import { Events } from "./Events";
6
- import { DBILocale, TDBILocaleConstructor, TDBILocaleString } from "./types/Locale";
6
+ import { DBILocale, LangConstructorObject, TDBILocaleConstructor, TDBILocaleString } from "./types/Locale";
7
7
  import { DBIButton, TDBIButtonOmitted } from "./types/Button";
8
8
  import { DBISelectMenu, TDBISelectMenuOmitted } from "./types/SelectMenu";
9
9
  import { DBIMessageContextMenu, TDBIMessageContextMenuOmitted } from "./types/MessageContextMenu";
@@ -32,6 +32,7 @@ export interface DBIConfig {
32
32
  * Persist store. (Default to MemoryStore thats not persis tho.)
33
33
  */
34
34
  store: DBIStore;
35
+ clearRefsAfter?: number;
35
36
  }
36
37
  export interface DBIConfigConstructor {
37
38
  discord: {
@@ -48,12 +49,13 @@ export interface DBIConfigConstructor {
48
49
  * Persist store. (Default to MemoryStore thats not persis tho.)
49
50
  */
50
51
  store?: DBIStore;
52
+ clearRefsAfter?: number;
51
53
  }
52
- export interface DBIRegisterAPI {
54
+ export interface DBIRegisterAPI<TLocaleFormat> {
53
55
  ChatInput(cfg: TDBIChatInputOmitted): DBIChatInput;
54
56
  ChatInputOptions: typeof DBIChatInputOptions;
55
57
  Event(cfg: TDBIEventOmitted): DBIEvent;
56
- Locale(cfg: TDBILocaleConstructor): DBILocale;
58
+ Locale(cfg: TDBILocaleConstructor<TLocaleFormat>): DBILocale;
57
59
  Button(cfg: TDBIButtonOmitted): DBIButton;
58
60
  SelectMenu(cfg: TDBISelectMenuOmitted): DBISelectMenu;
59
61
  MessageContextMenu(cfg: TDBIMessageContextMenuOmitted): DBIMessageContextMenu;
@@ -62,7 +64,7 @@ export interface DBIRegisterAPI {
62
64
  Modal(cfg: TDBIModalOmitted): DBIModal;
63
65
  onUnload(cb: () => Promise<any> | any): any;
64
66
  }
65
- export declare class DBI<TOtherData = Record<string, any>> {
67
+ export declare class DBI<TOtherData = Record<string, any>, TLocaleFormat = LangConstructorObject> {
66
68
  namespace: string;
67
69
  config: DBIConfig;
68
70
  client: Discord.Client<true>;
@@ -70,7 +72,7 @@ export declare class DBI<TOtherData = Record<string, any>> {
70
72
  interactions: Discord.Collection<string, DBIChatInput | DBIButton | DBISelectMenu | DBIMessageContextMenu | DBIUserContextMenu | DBIModal>;
71
73
  events: Discord.Collection<string, DBIEvent>;
72
74
  plugins: Discord.Collection<string, any>;
73
- locales: Discord.Collection<string, DBILocale>;
75
+ locales: Discord.Collection<string, DBILocale<TLocaleFormat>>;
74
76
  interactionLocales: Discord.Collection<string, DBIInteractionLocale>;
75
77
  other: TOtherData;
76
78
  eventMap: Record<string, string[]>;
@@ -85,8 +87,10 @@ export declare class DBI<TOtherData = Record<string, any>> {
85
87
  events: Events;
86
88
  cluster?: Sharding.Client;
87
89
  private _loaded;
90
+ private _hooked;
88
91
  constructor(namespace: string, config: DBIConfigConstructor);
89
92
  private _hookListeners;
93
+ private _unhookListeners;
90
94
  private _unregisterAll;
91
95
  private _registerAll;
92
96
  /**
@@ -106,7 +110,7 @@ export declare class DBI<TOtherData = Record<string, any>> {
106
110
  */
107
111
  delete(k: string): boolean;
108
112
  login(): Promise<any>;
109
- register(cb: (api: DBIRegisterAPI) => void): Promise<any>;
113
+ register(cb: (api: DBIRegisterAPI<TLocaleFormat>) => void): Promise<any>;
110
114
  load(): Promise<boolean>;
111
115
  unload(): Promise<boolean>;
112
116
  get loaded(): boolean;
package/dist/DBI.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"DBI.d.ts","sourceRoot":"","sources":["../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AAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;CA0B7E"}
package/dist/DBI.js CHANGED
@@ -29,6 +29,7 @@ class DBI {
29
29
  events;
30
30
  cluster;
31
31
  _loaded;
32
+ _hooked;
32
33
  constructor(namespace, config) {
33
34
  this.namespace = namespace;
34
35
  config.store = config.store || new MemoryStore_1.MemoryStore();
@@ -63,12 +64,37 @@ class DBI {
63
64
  } : {})
64
65
  });
65
66
  this.cluster = config.sharding ? new Sharding.Client(this.client) : undefined;
66
- this._hookListeners();
67
67
  this._loaded = false;
68
+ this._hooked = false;
68
69
  }
69
70
  async _hookListeners() {
71
+ if (this._hooked)
72
+ return;
73
+ this._hooked = true;
70
74
  this.data.unloaders.add((0, hookInteractionListeners_1.hookInteractionListeners)(this));
71
75
  this.data.unloaders.add((0, hookEventListeners_1.hookEventListeners)(this));
76
+ if (typeof this.config.clearRefsAfter == "number") {
77
+ this.data.unloaders.add((() => {
78
+ let interval = setInterval(() => {
79
+ this.data.refs.forEach(({ at }, key) => {
80
+ if (Date.now() > (at + this.config.clearRefsAfter)) {
81
+ this.data.refs.delete(key);
82
+ }
83
+ });
84
+ }, 60000);
85
+ return () => {
86
+ clearInterval(interval);
87
+ };
88
+ })());
89
+ }
90
+ }
91
+ async _unhookListeners() {
92
+ if (!this._hooked)
93
+ return;
94
+ this._hooked = false;
95
+ this.data.unloaders.forEach(f => {
96
+ f();
97
+ });
72
98
  }
73
99
  async _unregisterAll() {
74
100
  for await (const cb of this.data.registerUnloaders) {
@@ -226,6 +252,7 @@ class DBI {
226
252
  if (this._loaded)
227
253
  return false;
228
254
  await this._registerAll();
255
+ await this._hookListeners();
229
256
  this._loaded = true;
230
257
  return true;
231
258
  }
@@ -233,6 +260,7 @@ class DBI {
233
260
  if (!this._loaded)
234
261
  return false;
235
262
  await this._unregisterAll();
263
+ await this._unhookListeners();
236
264
  this._loaded = false;
237
265
  return true;
238
266
  }
package/dist/DBI.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"DBI.js","sourceRoot":"","sources":["../src/DBI.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AACjC,2DAAiF;AACjF,yEAAyE;AACzE,uEAAoE;AACpE,yCAA2D;AAC3D,qDAAkD;AAClD,iFAA8E;AAC9E,qCAAkC;AAClC,2CAAoF;AACpF,2CAA8D;AAC9D,mDAA0E;AAC1E,mEAAkG;AAClG,6DAAyF;AACzF,qEAAkE;AAClE,iFAA4C;AAC5C,yCAA2D;AAC3D,0EAAoD;AACpD,4DAAuB;AACvB,iEAA+F;AA2D/F,MAAa,GAAG;IACd,SAAS,CAAS;IAClB,MAAM,CAAY;IAClB,MAAM,CAAuB;IAC7B,IAAI,CAYF;IACF,MAAM,CAAS;IACf,OAAO,CAAmB;IAClB,OAAO,CAAU;IACzB,YAAY,SAAiB,EAAE,MAA4B;QACzD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAY,IAAI,IAAI,yBAAW,EAAE,CAAC;QACxD,MAAM,CAAC,QAAQ,GAAG;YAChB,MAAM,EAAE,IAAI;YACZ,wBAAwB,EAAE,EAAE;YAC5B,cAAc,EAAE,KAAK;YACrB,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;SAC3B,CAAC;QACF,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC;QAE3C,aAAa;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,IAAI,GAAG;YACV,YAAY,EAAE,IAAI,oBAAO,CAAC,UAAU,EAAE;YACtC,MAAM,EAAE,IAAI,oBAAO,CAAC,UAAU,EAAE;YAChC,OAAO,EAAE,IAAI,oBAAO,CAAC,UAAU,EAAE;YACjC,OAAO,EAAE,IAAI,oBAAO,CAAC,UAAU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;gBACb,OAAO,MAAM,IAAA,yCAAmB,EAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EACzB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,oBAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,YAAY,EACjD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAC5B,IAAI,CAAC,CAAC,CAAC,CACR,CAAC;aACH;YACD,KAAK,OAAO,CAAC,CAAC;gBACZ,OAAO,MAAM,IAAA,yCAAmB,EAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EACzB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,oBAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,YAAY,EACjD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAC5B,IAAI,CAAC,CAAC,CAAC,EACP,IAAI,CAAC,CAAC,CAAC,CACR,CAAC;aACH;SACF;IACH,CAAC;CAGF;AA/PD,kBA+PC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput, TDBIChatInputOmitted } from \"./types/ChatInput/ChatInput\";\r\nimport { DBIChatInputOptions } from \"./types/ChatInput/ChatInputOptions\";\r\nimport { publishInteractions } from \"./methods/publishInteractions\";\r\nimport { DBIEvent, TDBIEventOmitted } from \"./types/Event\";\r\nimport { MemoryStore } from \"./utils/MemoryStore\";\r\nimport { hookInteractionListeners } from \"./methods/hookInteractionListeners\";\r\nimport { Events } from \"./Events\";\r\nimport { DBILocale, TDBILocaleConstructor, TDBILocaleString } from \"./types/Locale\";\r\nimport { DBIButton, TDBIButtonOmitted } from \"./types/Button\";\r\nimport { DBISelectMenu, TDBISelectMenuOmitted } from \"./types/SelectMenu\";\r\nimport { DBIMessageContextMenu, TDBIMessageContextMenuOmitted } from \"./types/MessageContextMenu\";\r\nimport { DBIUserContextMenu, TDBIUserContextMenuOmitted } from \"./types/UserContextMenu\";\r\nimport { hookEventListeners } from \"./methods/hookEventListeners\";\r\nimport eventMap from \"./data/eventMap.json\";\r\nimport { DBIModal, TDBIModalOmitted } from \"./types/Modal\";\r\nimport * as Sharding from \"discord-hybrid-sharding\";\r\nimport _ from \"lodash\";\r\nimport { DBIInteractionLocale, TDBIInteractionLocaleOmitted } from \"./types/InteractionLocale\";\r\n\r\nexport interface DBIStore {\r\n get(key: string, defaultValue?: any): Promise<any>;\r\n set(key: string, value: any): Promise<void>;\r\n delete(key: string): Promise<void>;\r\n has(key: string): Promise<boolean>;\r\n}\r\n\r\nexport interface DBIConfig {\r\n discord: {\r\n token: string;\r\n options: Discord.ClientOptions\r\n }\r\n defaults: {\r\n locale: TDBILocaleString,\r\n directMessages: boolean,\r\n defaultMemberPermissions: Discord.PermissionsString[]\r\n };\r\n\r\n sharding: boolean;\r\n /**\r\n * Persist store. (Default to MemoryStore thats not persis tho.)\r\n */\r\n store: DBIStore;\r\n}\r\n\r\nexport interface DBIConfigConstructor {\r\n discord: {\r\n token: string;\r\n options: Discord.ClientOptions\r\n }\r\n defaults?: {\r\n locale?: TDBILocaleString,\r\n directMessages?: boolean,\r\n defaultMemberPermissions?: Discord.PermissionsString[]\r\n };\r\n\r\n sharding?: boolean;\r\n /**\r\n * Persist store. (Default to MemoryStore thats not persis tho.)\r\n */\r\n store?: DBIStore;\r\n}\r\n\r\nexport interface DBIRegisterAPI {\r\n ChatInput(cfg: TDBIChatInputOmitted): DBIChatInput;\r\n ChatInputOptions: typeof DBIChatInputOptions;\r\n Event(cfg: TDBIEventOmitted): DBIEvent;\r\n Locale(cfg: TDBILocaleConstructor): DBILocale;\r\n Button(cfg: TDBIButtonOmitted): DBIButton;\r\n SelectMenu(cfg: TDBISelectMenuOmitted): DBISelectMenu;\r\n MessageContextMenu(cfg: TDBIMessageContextMenuOmitted): DBIMessageContextMenu;\r\n UserContextMenu(cfg: TDBIUserContextMenuOmitted): DBIUserContextMenu;\r\n InteractionLocale(cfg: TDBIInteractionLocaleOmitted): DBIInteractionLocale;\r\n Modal(cfg: TDBIModalOmitted): DBIModal;\r\n onUnload(cb: () => Promise<any> | any): any;\r\n}\r\n\r\nexport class DBI<TOtherData = Record<string, any>> {\r\n namespace: string;\r\n config: DBIConfig;\r\n client: Discord.Client<true>;\r\n data: {\r\n interactions: Discord.Collection<string, DBIChatInput | DBIButton | DBISelectMenu | DBIMessageContextMenu | DBIUserContextMenu | DBIModal>;\r\n events: Discord.Collection<string, DBIEvent>;\r\n plugins: Discord.Collection<string, any>;\r\n locales: Discord.Collection<string, DBILocale>;\r\n interactionLocales: Discord.Collection<string, DBIInteractionLocale>;\r\n other: TOtherData;\r\n eventMap: Record<string, string[]>;\r\n unloaders: Set<() => void>;\r\n registers: Set<(...args: any[]) => any>;\r\n registerUnloaders: Set<(...args: any[]) => any>;\r\n refs: Map<string, { at: number, value: any }>;\r\n };\r\n events: Events;\r\n cluster?: Sharding.Client;\r\n private _loaded: boolean;\r\n constructor(namespace: string, config: DBIConfigConstructor) {\r\n this.namespace = namespace;\r\n\r\n config.store = config.store as any || new MemoryStore();\r\n config.defaults = {\r\n locale: \"en\",\r\n defaultMemberPermissions: [],\r\n directMessages: false,\r\n ...(config.defaults || {})\r\n };\r\n config.sharding = config.sharding ?? false;\r\n\r\n // @ts-ignore\r\n this.config = config;\r\n\r\n this.data = {\r\n interactions: new Discord.Collection(),\r\n events: new Discord.Collection(),\r\n plugins: new Discord.Collection(),\r\n locales: new Discord.Collection(),\r\n interactionLocales: new Discord.Collection(),\r\n other: {} as TOtherData,\r\n eventMap,\r\n unloaders: new Set(),\r\n registers: new Set(),\r\n registerUnloaders: new Set(),\r\n refs: new Map()\r\n }\r\n\r\n this.events = new Events(this);\r\n this.client = new Discord.Client({\r\n ...(config.discord?.options || {}) as any,\r\n ...(config.sharding ? {\r\n shards: (Sharding as any).data.SHARD_LIST,\r\n shardCount: (Sharding as any).data.TOTAL_SHARDS\r\n } : {})\r\n });\r\n this.cluster = config.sharding ? new Sharding.Client(this.client) : undefined;\r\n this._hookListeners();\r\n this._loaded = false;\r\n }\r\n\r\n private async _hookListeners() {\r\n this.data.unloaders.add(hookInteractionListeners(this));\r\n this.data.unloaders.add(hookEventListeners(this));\r\n }\r\n\r\n private async _unregisterAll() {\r\n for await (const cb of this.data.registerUnloaders) {\r\n await cb();\r\n }\r\n this.data.events.clear();\r\n this.data.interactions.clear();\r\n this.data.plugins.clear();\r\n }\r\n\r\n private async _registerAll() {\r\n const self = this;\r\n\r\n for await (const cb of this.data.registers) {\r\n let ChatInput = function(cfg: DBIChatInput) {\r\n let dbiChatInput = new DBIChatInput(self, cfg);\r\n if (self.data.interactions.has(dbiChatInput.name)) throw new Error(`DBIChatInput \"${dbiChatInput.name}\" already loaded as \"${self.data.interactions.get(dbiChatInput.name)?.type}\"!`);\r\n self.data.interactions.set(dbiChatInput.name, dbiChatInput);\r\n return dbiChatInput;\r\n };\r\n ChatInput = Object.assign(ChatInput, class { constructor(...args: any[]) { return ChatInput.apply(this, args as any); } });\r\n\r\n let Event = function(cfg: TDBIEventOmitted) {\r\n let dbiEvent = new DBIEvent(self, cfg);\r\n if (self.data.events.has(dbiEvent.id || dbiEvent.name)) throw new Error(`DBIEvent \"${dbiEvent.id || dbiEvent.name}\" already loaded!`);\r\n self.data.events.set(dbiEvent.id || dbiEvent.name, dbiEvent);\r\n return dbiEvent;\r\n };\r\n Event = Object.assign(Event, class { constructor(...args: any[]) { return Event.apply(this, args as any); } });\r\n\r\n let Button = function(cfg: TDBIButtonOmitted) {\r\n let dbiButton = new DBIButton(self, cfg);\r\n if (self.data.interactions.has(dbiButton.name)) throw new Error(`DBIButton \"${dbiButton.name}\" already loaded as \"${self.data.interactions.get(dbiButton.name)?.type}\"!`);\r\n self.data.interactions.set(dbiButton.name, dbiButton);\r\n return dbiButton;\r\n };\r\n Button = Object.assign(Button, class { constructor(...args: any[]) { return Button.apply(this, args as any); } });\r\n\r\n let SelectMenu = function(cfg: TDBISelectMenuOmitted) {\r\n let dbiSelectMenu = new DBISelectMenu(self, cfg);\r\n if (self.data.interactions.has(dbiSelectMenu.name)) throw new Error(`DBISelectMenu \"${dbiSelectMenu.name}\" already loaded as \"${self.data.interactions.get(dbiSelectMenu.name)?.type}\"!`);\r\n self.data.interactions.set(dbiSelectMenu.name, dbiSelectMenu);\r\n return dbiSelectMenu;\r\n };\r\n SelectMenu = Object.assign(SelectMenu, class { constructor(...args: any[]) { return SelectMenu.apply(this, args as any); } });\r\n\r\n let MessageContextMenu = function(cfg: TDBIMessageContextMenuOmitted) {\r\n let dbiMessageContextMenu = new DBIMessageContextMenu(self, cfg);\r\n if (self.data.interactions.has(dbiMessageContextMenu.name)) throw new Error(`DBIMessageContextMenu \"${dbiMessageContextMenu.name}\" already loaded as \"${self.data.interactions.get(dbiMessageContextMenu.name)?.type}\"!`);\r\n self.data.interactions.set(dbiMessageContextMenu.name, dbiMessageContextMenu);\r\n return dbiMessageContextMenu;\r\n };\r\n MessageContextMenu = Object.assign(MessageContextMenu, class { constructor(...args: any[]) { return MessageContextMenu.apply(this, args as any); } });\r\n\r\n let UserContextMenu = function(cfg: TDBIUserContextMenuOmitted) {\r\n let dbiUserContextMenu = new DBIUserContextMenu(self, cfg);\r\n if (self.data.interactions.has(dbiUserContextMenu.name)) throw new Error(`DBIUserContextMenu \"${dbiUserContextMenu.name}\" already loaded as \"${self.data.interactions.get(dbiUserContextMenu.name)?.type}\"!`);\r\n self.data.interactions.set(dbiUserContextMenu.name, dbiUserContextMenu);\r\n return dbiUserContextMenu;\r\n };\r\n UserContextMenu = Object.assign(UserContextMenu, class { constructor(...args: any[]) { return UserContextMenu.apply(this, args as any); } });\r\n\r\n let Modal = function(cfg: TDBIModalOmitted) {\r\n let dbiModal = new DBIModal(self, cfg);\r\n if (self.data.interactions.has(dbiModal.name)) throw new Error(`DBIModal \"${dbiModal.name}\" already loaded as \"${self.data.interactions.get(dbiModal.name)?.type}\"!`);\r\n self.data.interactions.set(dbiModal.name, dbiModal);\r\n return dbiModal;\r\n };\r\n Modal = Object.assign(Modal, class { constructor(...args: any[]) { return Modal.apply(this, args as any); } });\r\n\r\n let Locale = function(cfg: TDBILocaleConstructor) {\r\n let dbiLocale = new DBILocale(self, cfg);\r\n if (self.data.locales.has(dbiLocale.name)) throw new Error(`DBILocale \"${dbiLocale.name}\" already loaded!`);\r\n self.data.locales.set(dbiLocale.name, dbiLocale);\r\n return dbiLocale;\r\n };\r\n Locale = Object.assign(Locale, class { constructor(...args: any[]) { return Locale.apply(this, args as any); } });\r\n\r\n let InteractionLocale = function(cfg: TDBIInteractionLocaleOmitted) {\r\n let dbiInteractionLocale = new DBIInteractionLocale(self, cfg);\r\n if (self.data.interactionLocales.has(dbiInteractionLocale.name)) throw new Error(`DBIInteractionLocale \"${dbiInteractionLocale.name}\" already loaded!`);\r\n self.data.interactionLocales.set(dbiInteractionLocale.name, dbiInteractionLocale);\r\n return dbiInteractionLocale;\r\n };\r\n InteractionLocale = Object.assign(InteractionLocale, class { constructor(...args: any[]) { return InteractionLocale.apply(this, args as any); } });\r\n\r\n await cb({\r\n ChatInput,\r\n Event,\r\n ChatInputOptions: DBIChatInputOptions,\r\n Locale,\r\n Button,\r\n SelectMenu,\r\n MessageContextMenu,\r\n UserContextMenu,\r\n Modal,\r\n InteractionLocale,\r\n onUnload(cb: ()=> Promise<any> | any) {\r\n self.data.registerUnloaders.add(cb);\r\n },\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Shorthands for modifying `dbi.data.other`\r\n */\r\n get<K extends keyof TOtherData>(k: K, defaultValue?: TOtherData[K]): TOtherData[K] {\r\n if (defaultValue && !this.has(k as any)) {\r\n this.set(k, defaultValue);\r\n return defaultValue;\r\n }\r\n return _.get(this.data.other, k);\r\n }\r\n\r\n /**\r\n * Shorthands for modifying `dbi.data.other`\r\n */\r\n set<K extends keyof TOtherData>(k: K, v: TOtherData[K]): any {\r\n this.data.other = _.set(this.data.other as any, k, v);\r\n }\r\n\r\n /**\r\n * Shorthands for modifying `dbi.data.other`\r\n */\r\n has(k: string): boolean {\r\n return _.has(this.data.other, k as any);\r\n }\r\n\r\n /**\r\n * Shorthands for modifying `dbi.data.other`\r\n */\r\n delete(k: string): boolean {\r\n return _.unset(this.data.other, k);\r\n }\r\n\r\n async login(): Promise<any> {\r\n await this.client.login(this.config.discord.token);\r\n }\r\n\r\n async register(cb: (api: DBIRegisterAPI) => void): Promise<any> {\r\n this.data.registers.add(cb);\r\n }\r\n\r\n async load(): Promise<boolean> {\r\n if (this._loaded) return false;\r\n await this._registerAll();\r\n this._loaded = true;\r\n return true;\r\n }\r\n\r\n async unload(): Promise<boolean> {\r\n if (!this._loaded) return false;\r\n await this._unregisterAll();\r\n this._loaded = false;\r\n return true;\r\n }\r\n\r\n get loaded(): boolean {\r\n return this._loaded;\r\n }\r\n\r\n async publish(type: \"Global\", clear?: boolean): Promise<any>;\r\n async publish(type: \"Guild\", guildId: string, clear?: boolean): Promise<any>;\r\n\r\n async publish(...args: any[]) {\r\n let interactions = this.data.interactions.filter(i => i.type == \"ChatInput\" || i.type == \"MessageContextMenu\" || i.type == \"UserContextMenu\") as any;\r\n switch (args[0]) {\r\n case \"Global\": {\r\n return await publishInteractions(\r\n this.config.discord.token,\r\n args[1] ? new Discord.Collection() : interactions,\r\n this.data.interactionLocales,\r\n args[0]\r\n );\r\n }\r\n case \"Guild\": {\r\n return await publishInteractions(\r\n this.config.discord.token,\r\n args[2] ? new Discord.Collection() : interactions,\r\n this.data.interactionLocales,\r\n args[0],\r\n args[1]\r\n );\r\n }\r\n }\r\n }\r\n\r\n \r\n}"]}
1
+ {"version":3,"file":"DBI.js","sourceRoot":"","sources":["../src/DBI.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AACjC,2DAAiF;AACjF,yEAAyE;AACzE,uEAAoE;AACpE,yCAA2D;AAC3D,qDAAkD;AAClD,iFAA8E;AAC9E,qCAAkC;AAClC,2CAA2G;AAC3G,2CAA8D;AAC9D,mDAA0E;AAC1E,mEAAkG;AAClG,6DAAyF;AACzF,qE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U,EAAE,CAAC,CAAC,CAAC,YAAY,EACjD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAC5B,IAAI,CAAC,CAAC,CAAC,EACP,IAAI,CAAC,CAAC,CAAC,CACR,CAAC;aACH;SACF;IACH,CAAC;CAGF;AA1RD,kBA0RC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput, TDBIChatInputOmitted } from \"./types/ChatInput/ChatInput\";\r\nimport { DBIChatInputOptions } from \"./types/ChatInput/ChatInputOptions\";\r\nimport { publishInteractions } from \"./methods/publishInteractions\";\r\nimport { DBIEvent, TDBIEventOmitted } from \"./types/Event\";\r\nimport { MemoryStore } from \"./utils/MemoryStore\";\r\nimport { hookInteractionListeners } from \"./methods/hookInteractionListeners\";\r\nimport { Events } from \"./Events\";\r\nimport { DBILocale, LangConstructorObject, TDBILocaleConstructor, TDBILocaleString } from \"./types/Locale\";\r\nimport { DBIButton, TDBIButtonOmitted } from \"./types/Button\";\r\nimport { DBISelectMenu, TDBISelectMenuOmitted } from \"./types/SelectMenu\";\r\nimport { DBIMessageContextMenu, TDBIMessageContextMenuOmitted } from \"./types/MessageContextMenu\";\r\nimport { DBIUserContextMenu, TDBIUserContextMenuOmitted } from \"./types/UserContextMenu\";\r\nimport { hookEventListeners } from \"./methods/hookEventListeners\";\r\nimport eventMap from \"./data/eventMap.json\";\r\nimport { DBIModal, TDBIModalOmitted } from \"./types/Modal\";\r\nimport * as Sharding from \"discord-hybrid-sharding\";\r\nimport _ from \"lodash\";\r\nimport { DBIInteractionLocale, TDBIInteractionLocaleOmitted } from \"./types/InteractionLocale\";\r\n\r\nexport interface DBIStore {\r\n get(key: string, defaultValue?: any): Promise<any>;\r\n set(key: string, value: any): Promise<void>;\r\n delete(key: string): Promise<void>;\r\n has(key: string): Promise<boolean>;\r\n}\r\n\r\nexport interface DBIConfig {\r\n discord: {\r\n token: string;\r\n options: Discord.ClientOptions\r\n }\r\n defaults: {\r\n locale: TDBILocaleString,\r\n directMessages: boolean,\r\n defaultMemberPermissions: Discord.PermissionsString[]\r\n };\r\n\r\n sharding: boolean;\r\n /**\r\n * Persist store. (Default to MemoryStore thats not persis tho.)\r\n */\r\n store: DBIStore;\r\n\r\n clearRefsAfter?: number;\r\n}\r\n\r\nexport interface DBIConfigConstructor {\r\n discord: {\r\n token: string;\r\n options: Discord.ClientOptions\r\n }\r\n defaults?: {\r\n locale?: TDBILocaleString,\r\n directMessages?: boolean,\r\n defaultMemberPermissions?: Discord.PermissionsString[]\r\n };\r\n\r\n sharding?: boolean;\r\n /**\r\n * Persist store. (Default to MemoryStore thats not persis tho.)\r\n */\r\n store?: DBIStore;\r\n\r\n clearRefsAfter?: number;\r\n}\r\n\r\nexport interface DBIRegisterAPI<TLocaleFormat> {\r\n ChatInput(cfg: TDBIChatInputOmitted): DBIChatInput;\r\n ChatInputOptions: typeof DBIChatInputOptions;\r\n Event(cfg: TDBIEventOmitted): DBIEvent;\r\n Locale(cfg: TDBILocaleConstructor<TLocaleFormat>): DBILocale;\r\n Button(cfg: TDBIButtonOmitted): DBIButton;\r\n SelectMenu(cfg: TDBISelectMenuOmitted): DBISelectMenu;\r\n MessageContextMenu(cfg: TDBIMessageContextMenuOmitted): DBIMessageContextMenu;\r\n UserContextMenu(cfg: TDBIUserContextMenuOmitted): DBIUserContextMenu;\r\n InteractionLocale(cfg: TDBIInteractionLocaleOmitted): DBIInteractionLocale;\r\n Modal(cfg: TDBIModalOmitted): DBIModal;\r\n onUnload(cb: () => Promise<any> | any): any;\r\n}\r\n\r\nexport class DBI<TOtherData = Record<string, any>, TLocaleFormat = LangConstructorObject> {\r\n namespace: string;\r\n config: DBIConfig;\r\n client: Discord.Client<true>;\r\n data: {\r\n interactions: Discord.Collection<string, DBIChatInput | DBIButton | DBISelectMenu | DBIMessageContextMenu | DBIUserContextMenu | DBIModal>;\r\n events: Discord.Collection<string, DBIEvent>;\r\n plugins: Discord.Collection<string, any>;\r\n locales: Discord.Collection<string, DBILocale<TLocaleFormat>>;\r\n interactionLocales: Discord.Collection<string, DBIInteractionLocale>;\r\n other: TOtherData;\r\n eventMap: Record<string, string[]>;\r\n unloaders: Set<() => void>;\r\n registers: Set<(...args: any[]) => any>;\r\n registerUnloaders: Set<(...args: any[]) => any>;\r\n refs: Map<string, { at: number, value: any }>;\r\n };\r\n events: Events;\r\n cluster?: Sharding.Client;\r\n private _loaded: boolean;\r\n private _hooked: boolean;\r\n constructor(namespace: string, config: DBIConfigConstructor) {\r\n this.namespace = namespace;\r\n\r\n config.store = config.store as any || new MemoryStore();\r\n config.defaults = {\r\n locale: \"en\",\r\n defaultMemberPermissions: [],\r\n directMessages: false,\r\n ...(config.defaults || {})\r\n };\r\n config.sharding = config.sharding ?? false;\r\n\r\n // @ts-ignore\r\n this.config = config;\r\n\r\n this.data = {\r\n interactions: new Discord.Collection(),\r\n events: new Discord.Collection(),\r\n plugins: new Discord.Collection(),\r\n locales: new Discord.Collection(),\r\n interactionLocales: new Discord.Collection(),\r\n other: {} as TOtherData,\r\n eventMap,\r\n unloaders: new Set(),\r\n registers: new Set(),\r\n registerUnloaders: new Set(),\r\n refs: new Map()\r\n }\r\n\r\n this.events = new Events(this as any);\r\n this.client = new Discord.Client({\r\n ...(config.discord?.options || {}) as any,\r\n ...(config.sharding ? {\r\n shards: (Sharding as any).data.SHARD_LIST,\r\n shardCount: (Sharding as any).data.TOTAL_SHARDS\r\n } : {})\r\n });\r\n this.cluster = config.sharding ? new Sharding.Client(this.client) : undefined;\r\n this._loaded = false;\r\n this._hooked = false;\r\n }\r\n\r\n private async _hookListeners() {\r\n if (this._hooked) return;\r\n this._hooked = true;\r\n this.data.unloaders.add(hookInteractionListeners(this as any));\r\n this.data.unloaders.add(hookEventListeners(this as any));\r\n if (typeof this.config.clearRefsAfter == \"number\") {\r\n this.data.unloaders.add((() => {\r\n let interval = setInterval(() => {\r\n this.data.refs.forEach(({ at }, key) => {\r\n if (Date.now() > (at + this.config.clearRefsAfter)) {\r\n this.data.refs.delete(key);\r\n }\r\n });\r\n }, 60000);\r\n return () => {\r\n clearInterval(interval);\r\n }\r\n })());\r\n }\r\n }\r\n\r\n private async _unhookListeners() {\r\n if (!this._hooked) return;\r\n this._hooked = false;\r\n this.data.unloaders.forEach(f => {\r\n f();\r\n });\r\n }\r\n\r\n private async _unregisterAll() {\r\n for await (const cb of this.data.registerUnloaders) {\r\n await cb();\r\n }\r\n this.data.events.clear();\r\n this.data.interactions.clear();\r\n this.data.plugins.clear();\r\n }\r\n\r\n private async _registerAll() {\r\n const self = this as any;\r\n\r\n for await (const cb of this.data.registers) {\r\n let ChatInput = function(cfg: DBIChatInput) {\r\n let dbiChatInput = new DBIChatInput(self, cfg);\r\n if (self.data.interactions.has(dbiChatInput.name)) throw new Error(`DBIChatInput \"${dbiChatInput.name}\" already loaded as \"${self.data.interactions.get(dbiChatInput.name)?.type}\"!`);\r\n self.data.interactions.set(dbiChatInput.name, dbiChatInput);\r\n return dbiChatInput;\r\n };\r\n ChatInput = Object.assign(ChatInput, class { constructor(...args: any[]) { return ChatInput.apply(this, args as any); } });\r\n\r\n let Event = function(cfg: TDBIEventOmitted) {\r\n let dbiEvent = new DBIEvent(self, cfg);\r\n if (self.data.events.has(dbiEvent.id || dbiEvent.name)) throw new Error(`DBIEvent \"${dbiEvent.id || dbiEvent.name}\" already loaded!`);\r\n self.data.events.set(dbiEvent.id || dbiEvent.name, dbiEvent);\r\n return dbiEvent;\r\n };\r\n Event = Object.assign(Event, class { constructor(...args: any[]) { return Event.apply(this, args as any); } });\r\n\r\n let Button = function(cfg: TDBIButtonOmitted) {\r\n let dbiButton = new DBIButton(self, cfg);\r\n if (self.data.interactions.has(dbiButton.name)) throw new Error(`DBIButton \"${dbiButton.name}\" already loaded as \"${self.data.interactions.get(dbiButton.name)?.type}\"!`);\r\n self.data.interactions.set(dbiButton.name, dbiButton);\r\n return dbiButton;\r\n };\r\n Button = Object.assign(Button, class { constructor(...args: any[]) { return Button.apply(this, args as any); } });\r\n\r\n let SelectMenu = function(cfg: TDBISelectMenuOmitted) {\r\n let dbiSelectMenu = new DBISelectMenu(self, cfg);\r\n if (self.data.interactions.has(dbiSelectMenu.name)) throw new Error(`DBISelectMenu \"${dbiSelectMenu.name}\" already loaded as \"${self.data.interactions.get(dbiSelectMenu.name)?.type}\"!`);\r\n self.data.interactions.set(dbiSelectMenu.name, dbiSelectMenu);\r\n return dbiSelectMenu;\r\n };\r\n SelectMenu = Object.assign(SelectMenu, class { constructor(...args: any[]) { return SelectMenu.apply(this, args as any); } });\r\n\r\n let MessageContextMenu = function(cfg: TDBIMessageContextMenuOmitted) {\r\n let dbiMessageContextMenu = new DBIMessageContextMenu(self, cfg);\r\n if (self.data.interactions.has(dbiMessageContextMenu.name)) throw new Error(`DBIMessageContextMenu \"${dbiMessageContextMenu.name}\" already loaded as \"${self.data.interactions.get(dbiMessageContextMenu.name)?.type}\"!`);\r\n self.data.interactions.set(dbiMessageContextMenu.name, dbiMessageContextMenu);\r\n return dbiMessageContextMenu;\r\n };\r\n MessageContextMenu = Object.assign(MessageContextMenu, class { constructor(...args: any[]) { return MessageContextMenu.apply(this, args as any); } });\r\n\r\n let UserContextMenu = function(cfg: TDBIUserContextMenuOmitted) {\r\n let dbiUserContextMenu = new DBIUserContextMenu(self, cfg);\r\n if (self.data.interactions.has(dbiUserContextMenu.name)) throw new Error(`DBIUserContextMenu \"${dbiUserContextMenu.name}\" already loaded as \"${self.data.interactions.get(dbiUserContextMenu.name)?.type}\"!`);\r\n self.data.interactions.set(dbiUserContextMenu.name, dbiUserContextMenu);\r\n return dbiUserContextMenu;\r\n };\r\n UserContextMenu = Object.assign(UserContextMenu, class { constructor(...args: any[]) { return UserContextMenu.apply(this, args as any); } });\r\n\r\n let Modal = function(cfg: TDBIModalOmitted) {\r\n let dbiModal = new DBIModal(self, cfg);\r\n if (self.data.interactions.has(dbiModal.name)) throw new Error(`DBIModal \"${dbiModal.name}\" already loaded as \"${self.data.interactions.get(dbiModal.name)?.type}\"!`);\r\n self.data.interactions.set(dbiModal.name, dbiModal);\r\n return dbiModal;\r\n };\r\n Modal = Object.assign(Modal, class { constructor(...args: any[]) { return Modal.apply(this, args as any); } });\r\n\r\n let Locale = function(cfg: TDBILocaleConstructor<TLocaleFormat>) {\r\n let dbiLocale = new DBILocale(self, cfg);\r\n if (self.data.locales.has(dbiLocale.name)) throw new Error(`DBILocale \"${dbiLocale.name}\" already loaded!`);\r\n self.data.locales.set(dbiLocale.name, dbiLocale);\r\n return dbiLocale;\r\n };\r\n Locale = Object.assign(Locale, class { constructor(...args: any[]) { return Locale.apply(this, args as any); } });\r\n\r\n let InteractionLocale = function(cfg: TDBIInteractionLocaleOmitted) {\r\n let dbiInteractionLocale = new DBIInteractionLocale(self, cfg);\r\n if (self.data.interactionLocales.has(dbiInteractionLocale.name)) throw new Error(`DBIInteractionLocale \"${dbiInteractionLocale.name}\" already loaded!`);\r\n self.data.interactionLocales.set(dbiInteractionLocale.name, dbiInteractionLocale);\r\n return dbiInteractionLocale;\r\n };\r\n InteractionLocale = Object.assign(InteractionLocale, class { constructor(...args: any[]) { return InteractionLocale.apply(this, args as any); } });\r\n\r\n await cb({\r\n ChatInput,\r\n Event,\r\n ChatInputOptions: DBIChatInputOptions,\r\n Locale,\r\n Button,\r\n SelectMenu,\r\n MessageContextMenu,\r\n UserContextMenu,\r\n Modal,\r\n InteractionLocale,\r\n onUnload(cb: ()=> Promise<any> | any) {\r\n self.data.registerUnloaders.add(cb);\r\n },\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Shorthands for modifying `dbi.data.other`\r\n */\r\n get<K extends keyof TOtherData>(k: K, defaultValue?: TOtherData[K]): TOtherData[K] {\r\n if (defaultValue && !this.has(k as any)) {\r\n this.set(k, defaultValue);\r\n return defaultValue;\r\n }\r\n return _.get(this.data.other, k);\r\n }\r\n\r\n /**\r\n * Shorthands for modifying `dbi.data.other`\r\n */\r\n set<K extends keyof TOtherData>(k: K, v: TOtherData[K]): any {\r\n this.data.other = _.set(this.data.other as any, k, v);\r\n }\r\n\r\n /**\r\n * Shorthands for modifying `dbi.data.other`\r\n */\r\n has(k: string): boolean {\r\n return _.has(this.data.other, k as any);\r\n }\r\n\r\n /**\r\n * Shorthands for modifying `dbi.data.other`\r\n */\r\n delete(k: string): boolean {\r\n return _.unset(this.data.other, k);\r\n }\r\n\r\n async login(): Promise<any> {\r\n await this.client.login(this.config.discord.token);\r\n }\r\n\r\n async register(cb: (api: DBIRegisterAPI<TLocaleFormat>) => void): Promise<any> {\r\n this.data.registers.add(cb);\r\n }\r\n\r\n async load(): Promise<boolean> {\r\n if (this._loaded) return false;\r\n await this._registerAll();\r\n await this._hookListeners();\r\n this._loaded = true;\r\n return true;\r\n }\r\n\r\n async unload(): Promise<boolean> {\r\n if (!this._loaded) return false;\r\n await this._unregisterAll();\r\n await this._unhookListeners();\r\n this._loaded = false;\r\n return true;\r\n }\r\n\r\n get loaded(): boolean {\r\n return this._loaded;\r\n }\r\n\r\n async publish(type: \"Global\", clear?: boolean): Promise<any>;\r\n async publish(type: \"Guild\", guildId: string, clear?: boolean): Promise<any>;\r\n\r\n async publish(...args: any[]) {\r\n let interactions = this.data.interactions.filter(i => i.type == \"ChatInput\" || i.type == \"MessageContextMenu\" || i.type == \"UserContextMenu\") as any;\r\n switch (args[0]) {\r\n case \"Global\": {\r\n return await publishInteractions(\r\n this.config.discord.token,\r\n args[1] ? new Discord.Collection() : interactions,\r\n this.data.interactionLocales,\r\n args[0]\r\n );\r\n }\r\n case \"Guild\": {\r\n return await publishInteractions(\r\n this.config.discord.token,\r\n args[2] ? new Discord.Collection() : interactions,\r\n this.data.interactionLocales,\r\n args[0],\r\n args[1]\r\n );\r\n }\r\n }\r\n }\r\n\r\n \r\n}"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { DBI, DBIConfigConstructor } from "./DBI";
2
+ import { LangConstructorObject } from "./types/Locale";
2
3
  export { recursiveImport } from "./utils/recursiveImport";
3
4
  export { MemoryStore } from "./utils/MemoryStore";
4
- export declare function createDBI<TOtherType = Record<string, any>>(namespace: string, cfg: DBIConfigConstructor): DBI<TOtherType>;
5
+ export declare function createDBI<TOtherType = Record<string, any>, TDataFormat = LangConstructorObject>(namespace: string, cfg: DBIConfigConstructor): DBI<TOtherType, TDataFormat>;
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,wBAAgB,SAAS,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,GAAG,GAAG,CAAC,UAAU,CAAC,CAEzH"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,wBAAgB,SAAS,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,WAAW,GAAG,qBAAqB,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,GAAG,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAE3K"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAkD;AAClD,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB,SAAgB,SAAS,CAAmC,SAAiB,EAAE,GAAyB;IACtG,OAAO,IAAI,SAAG,CAAa,SAAS,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC;AAFD,8BAEC","sourcesContent":["import { DBI, DBIConfigConstructor } from \"./DBI\";\r\nexport { recursiveImport } from \"./utils/recursiveImport\";\r\nexport { MemoryStore } from \"./utils/MemoryStore\";\r\n\r\nexport function createDBI<TOtherType = Record<string, any>>(namespace: string, cfg: DBIConfigConstructor): DBI<TOtherType> {\r\n return new DBI<TOtherType>(namespace, cfg);\r\n}"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAkD;AAElD,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB,SAAgB,SAAS,CAAwE,SAAiB,EAAE,GAAyB;IAC3I,OAAO,IAAI,SAAG,CAA0B,SAAS,EAAE,GAAG,CAAC,CAAC;AAC1D,CAAC;AAFD,8BAEC","sourcesContent":["import { DBI, DBIConfigConstructor } from \"./DBI\";\r\nimport { LangConstructorObject } from \"./types/Locale\";\r\nexport { recursiveImport } from \"./utils/recursiveImport\";\r\nexport { MemoryStore } from \"./utils/MemoryStore\";\r\n\r\nexport function createDBI<TOtherType = Record<string, any>, TDataFormat = LangConstructorObject>(namespace: string, cfg: DBIConfigConstructor): DBI<TOtherType, TDataFormat> {\r\n return new DBI<TOtherType, TDataFormat>(namespace, cfg);\r\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"publishInteractions.d.ts","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAM5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAKlE,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,EACtD,mBAAmB,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACrE,WAAW,EAAE,OAAO,GAAG,QAAQ,EAC/B,OAAO,CAAC,EAAE,MAAM,iBAyKjB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,GAAG,GAAG,EAAE,CAOvE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,GAAG,CAsC9D"}
1
+ {"version":3,"file":"publishInteractions.d.ts","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAM5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAKlE,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,EACtD,mBAAmB,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACrE,WAAW,EAAE,OAAO,GAAG,QAAQ,EAC/B,OAAO,CAAC,EAAE,MAAM,iBAuKjB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,GAAG,GAAG,EAAE,CAcvE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,GAAG,CAgD9D"}
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatLocale = exports.localeifyOptions = exports.publishInteractions = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const rest_1 = require("@discordjs/rest");
6
5
  const v9_1 = require("discord-api-types/v9");
7
6
  const permissions_1 = require("../utils/permissions");
8
- const snakecase_keys_1 = tslib_1.__importDefault(require("snakecase-keys"));
9
7
  const PUBLISHABLE_TYPES = ["ChatInput", "UserContextMenu", "MessageContextMenu"];
10
8
  const ORIGINAL_LOCALES = ["da", "de", "en-GB", "en-US", "es-ES", "fr", "hr", "it", "lt", "hu", "nl", "no", "pl", "pt-BR", "ro", "fi", "sv-SE", "vi", "tr", "cs", "el", "bg", "ru", "uk", "hi", "th", "zh-CN", "ja", "zh-TW", "ko"];
11
9
  async function publishInteractions(clientToken, interactions, interactionsLocales, publishType, guildId) {
@@ -160,7 +158,6 @@ async function publishInteractions(clientToken, interactions, interactionsLocale
160
158
  }
161
159
  return all;
162
160
  }, []);
163
- body = (0, snakecase_keys_1.default)(body);
164
161
  switch (publishType) {
165
162
  case "Global": {
166
163
  await rest.put(v9_1.Routes.applicationGuildCommands(me.id, guildId), { body });
@@ -175,9 +172,16 @@ async function publishInteractions(clientToken, interactions, interactionsLocale
175
172
  exports.publishInteractions = publishInteractions;
176
173
  function localeifyOptions(options, localeData) {
177
174
  return options.map(i => {
178
- return localeData[i.name] ? Object.assign(i, {
179
- name_localizations: localeData[i.name].nameLocales,
180
- description_localizations: localeData[i.name].descriptionLocales,
175
+ let optionData = localeData[i.name];
176
+ return optionData ? Object.assign(i, {
177
+ name_localizations: optionData.nameLocales,
178
+ description_localizations: optionData.descriptionLocales,
179
+ choices: i.choices ? i.choices.map((j) => {
180
+ let choiceLocale = optionData.choiceLocales[j.name];
181
+ return choiceLocale ? Object.assign(j, {
182
+ name_localizations: choiceLocale
183
+ }) : j;
184
+ }) : undefined
181
185
  }) : i;
182
186
  });
183
187
  }
@@ -204,12 +208,23 @@ function formatLocale(locale) {
204
208
  Object.entries(localeData.options || []).forEach(([optionName, optionData]) => {
205
209
  if (!optionsLocales[optionName])
206
210
  optionsLocales[optionName] = {};
207
- if (!optionsLocales[optionName].nameLocales)
208
- optionsLocales[optionName].nameLocales = {};
209
- if (!optionsLocales[optionName].descriptionLocales)
210
- optionsLocales[optionName].descriptionLocales = {};
211
- optionsLocales[optionName].nameLocales[longLocale] = optionData.name;
212
- optionsLocales[optionName].descriptionLocales[longLocale] = optionData.description;
211
+ let optionLocale = optionsLocales[optionName];
212
+ if (!optionLocale.nameLocales)
213
+ optionLocale.nameLocales = {};
214
+ if (!optionLocale.descriptionLocales)
215
+ optionLocale.descriptionLocales = {};
216
+ if (!optionLocale.choiceLocales)
217
+ optionLocale.choiceLocales = {};
218
+ Object.entries(optionData.choices).forEach(([choiceOriginalName, choiceName]) => {
219
+ if (!optionLocale.choiceLocales)
220
+ optionLocale.choiceLocales = {};
221
+ if (!optionLocale.choiceLocales[choiceOriginalName])
222
+ optionLocale.choiceLocales[choiceOriginalName] = {};
223
+ let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];
224
+ choiceLocale[longLocale] = choiceName;
225
+ });
226
+ optionLocale.nameLocales[longLocale] = optionData.name;
227
+ optionLocale.descriptionLocales[longLocale] = optionData.description;
213
228
  });
214
229
  });
215
230
  });
@@ -1 +1 @@
1
- {"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AACzD,4EAA2C;AAI3C,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AACjF,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,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Ac,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;YAC7C,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACxD,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE;gBAC5E,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC;oBAAE,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;gBACjE,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,WAAW;oBAAE,cAAc,CAAC,UAAU,CAAC,CAAC,WAAW,GAAG,EAAE,CAAC;gBACzF,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,kBAAkB;oBAAE,cAAc,CAAC,UAAU,CAAC,CAAC,kBAAkB,GAAG,EAAE,CAAC;gBAEvG,cAAc,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;gBACrE,cAAc,CAAC,UAAU,CAAC,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACrF,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW;QACX,cAAc;QACd,kBAAkB;QAClB,cAAc;KACf,CAAA;AACH,CAAC;AAtCD,oCAsCC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput } from \"../types/ChatInput/ChatInput\";\r\nimport { REST } from \"@discordjs/rest\";\r\nimport { Routes, RESTGetAPIUserResult, RESTPutAPIApplicationCommandsJSONBody, ApplicationCommandType, ApplicationCommandOptionType } from \"discord-api-types/v9\";\r\nimport { reducePermissions } from \"../utils/permissions\";\r\nimport snakecaseKeys from \"snakecase-keys\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIInteractionLocale } from \"../types/InteractionLocale\";\r\n\r\nconst PUBLISHABLE_TYPES = [\"ChatInput\", \"UserContextMenu\", \"MessageContextMenu\"];\r\nconst ORIGINAL_LOCALES = [\"da\", \"de\", \"en-GB\", \"en-US\", \"es-ES\", \"fr\", \"hr\", \"it\", \"lt\", \"hu\", \"nl\", \"no\", \"pl\", \"pt-BR\", \"ro\", \"fi\", \"sv-SE\", \"vi\", \"tr\", \"cs\", \"el\", \"bg\", \"ru\", \"uk\", \"hi\", \"th\", \"zh-CN\", \"ja\", \"zh-TW\", \"ko\"];\r\n\r\nexport async function publishInteractions(\r\n clientToken: string,\r\n interactions: Discord.Collection<string, DBIChatInput>,\r\n interactionsLocales: Discord.Collection<string, DBIInteractionLocale>,\r\n publishType: \"Guild\" | \"Global\",\r\n guildId?: string\r\n) {\r\n interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));\r\n\r\n const rest = new REST({ version: \"9\" });\r\n rest.setToken(clientToken);\r\n\r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n interactions = interactions.sort((a, b) => b.name.split(\" \").length - a.name.split(\" \").length);\r\n\r\n let body: RESTPutAPIApplicationCommandsJSONBody =\r\n interactions.reduce((all, current) => {\r\n switch (current.type) {\r\n case \"ChatInput\": {\r\n let nameSplitted = current.name.split(\" \");\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n switch (nameSplitted.length) {\r\n case 1: {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n description: current.description,\r\n name: nameSplitted[0],\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(0),\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n break;\r\n }\r\n case 2: {\r\n let baseItem = all.find(i => i.name == current.name.split(\" \")[0] && i.type == ApplicationCommandType.ChatInput);\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n let option = {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[1],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(1),\r\n description_localizations: localeData.descriptionLocales,\r\n };\r\n if (!baseItem) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n description: \"...\",\r\n options: [\r\n option\r\n ]\r\n });\r\n } else {\r\n baseItem.options.push(option);\r\n }\r\n break;\r\n }\r\n case 3: {\r\n let level1Item = all.find(i => i.name == current.name.split(\" \")[0] && i.type == ApplicationCommandType.ChatInput);\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n if (!level1Item) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n name_localizations: localeData.nameLocales(1),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales,\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n } else {\r\n let level2Item = level1Item.options.find(i => i.name == current.name.split(\" \")[1]);\r\n if (!level2Item) {\r\n level1Item.options.push({\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n name_localizations: localeData.nameLocales(1),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales\r\n }\r\n ]\r\n })\r\n } else {\r\n level2Item.options.push({\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n case \"MessageContextMenu\": {\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n all.push({\r\n type: ApplicationCommandType.Message,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n name_localizations: localeData.allNameLocales,\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n break;\r\n }\r\n case \"UserContextMenu\": {\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n all.push({\r\n type: ApplicationCommandType.User,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n name_localizations: localeData.allNameLocales,\r\n description_localizations: localeData.descriptionLocales\r\n });\r\n break;\r\n }\r\n }\r\n\r\n return all;\r\n }, []);\r\n \r\n body = snakecaseKeys(body);\r\n \r\n switch (publishType) {\r\n case \"Global\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body });\r\n break;\r\n }\r\n }\r\n \r\n}\r\n\r\nexport function localeifyOptions(options: any[], localeData: any): any[] {\r\n return options.map(i => {\r\n return localeData[i.name] ? Object.assign(i, {\r\n name_localizations: localeData[i.name].nameLocales,\r\n description_localizations: localeData[i.name].descriptionLocales,\r\n }) : i;\r\n })\r\n}\r\n\r\nexport function formatLocale(locale: DBIInteractionLocale): any {\r\n let allNameLocales = {};\r\n let descriptionLocales = {};\r\n let optionsLocales = {};\r\n\r\n function nameLocales(index) {\r\n return Object.fromEntries(Object.entries(allNameLocales).map(i => [i[0], (i[1] as string).split(\" \").at(index)]));\r\n }\r\n\r\n if (!locale?.data) return {\r\n nameLocales,\r\n allNameLocales,\r\n descriptionLocales,\r\n optionsLocales\r\n };\r\n\r\n Object.entries(locale.data).forEach(([shortLocale, localeData]) => {\r\n let longAliases = ORIGINAL_LOCALES.filter(i => i.split(\"-\").at(0) == shortLocale);\r\n longAliases.forEach((longLocale) => {\r\n allNameLocales[longLocale] = localeData.name;\r\n descriptionLocales[longLocale] = localeData.description;\r\n Object.entries(localeData.options || []).forEach(([optionName, optionData]) => {\r\n if (!optionsLocales[optionName]) optionsLocales[optionName] = {};\r\n if (!optionsLocales[optionName].nameLocales) optionsLocales[optionName].nameLocales = {};\r\n if (!optionsLocales[optionName].descriptionLocales) optionsLocales[optionName].descriptionLocales = {};\r\n\r\n optionsLocales[optionName].nameLocales[longLocale] = optionData.name;\r\n optionsLocales[optionName].descriptionLocales[longLocale] = optionData.description;\r\n })\r\n });\r\n });\r\n \r\n return {\r\n nameLocales,\r\n allNameLocales,\r\n descriptionLocales,\r\n optionsLocales\r\n }\r\n}"]}
1
+ {"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AAKzD,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AACjF,MAAM,gBAAgB,GAAG,CAAC,IAAI,EA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,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAAE,EAAE;oBAC9E,IAAI,CAAC,YAAY,CAAC,aAAa;wBAAE,YAAY,CAAC,aAAa,GAAG,EAAE,CAAC;oBACjE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC;wBAAE,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC;oBACzG,IAAI,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;oBAElE,YAAY,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;gBACxC,CAAC,CAAC,CAAC;gBAEH,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;gBACvD,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACvE,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW;QACX,cAAc;QACd,kBAAkB;QAClB,cAAc;KACf,CAAA;AACH,CAAC;AAhDD,oCAgDC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput } from \"../types/ChatInput/ChatInput\";\r\nimport { REST } from \"@discordjs/rest\";\r\nimport { Routes, RESTGetAPIUserResult, RESTPutAPIApplicationCommandsJSONBody, ApplicationCommandType, ApplicationCommandOptionType } from \"discord-api-types/v9\";\r\nimport { reducePermissions } from \"../utils/permissions\";\r\nimport snakecaseKeys from \"snakecase-keys\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIInteractionLocale } from \"../types/InteractionLocale\";\r\n\r\nconst PUBLISHABLE_TYPES = [\"ChatInput\", \"UserContextMenu\", \"MessageContextMenu\"];\r\nconst ORIGINAL_LOCALES = [\"da\", \"de\", \"en-GB\", \"en-US\", \"es-ES\", \"fr\", \"hr\", \"it\", \"lt\", \"hu\", \"nl\", \"no\", \"pl\", \"pt-BR\", \"ro\", \"fi\", \"sv-SE\", \"vi\", \"tr\", \"cs\", \"el\", \"bg\", \"ru\", \"uk\", \"hi\", \"th\", \"zh-CN\", \"ja\", \"zh-TW\", \"ko\"];\r\n\r\nexport async function publishInteractions(\r\n clientToken: string,\r\n interactions: Discord.Collection<string, DBIChatInput>,\r\n interactionsLocales: Discord.Collection<string, DBIInteractionLocale>,\r\n publishType: \"Guild\" | \"Global\",\r\n guildId?: string\r\n) {\r\n interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));\r\n\r\n const rest = new REST({ version: \"9\" });\r\n rest.setToken(clientToken);\r\n\r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n interactions = interactions.sort((a, b) => b.name.split(\" \").length - a.name.split(\" \").length);\r\n\r\n let body: RESTPutAPIApplicationCommandsJSONBody =\r\n interactions.reduce((all, current) => {\r\n switch (current.type) {\r\n case \"ChatInput\": {\r\n let nameSplitted = current.name.split(\" \");\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n switch (nameSplitted.length) {\r\n case 1: {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n description: current.description,\r\n name: nameSplitted[0],\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(0),\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n break;\r\n }\r\n case 2: {\r\n let baseItem = all.find(i => i.name == current.name.split(\" \")[0] && i.type == ApplicationCommandType.ChatInput);\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n let option = {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[1],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(1),\r\n description_localizations: localeData.descriptionLocales,\r\n };\r\n if (!baseItem) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n description: \"...\",\r\n options: [\r\n option\r\n ]\r\n });\r\n } else {\r\n baseItem.options.push(option);\r\n }\r\n break;\r\n }\r\n case 3: {\r\n let level1Item = all.find(i => i.name == current.name.split(\" \")[0] && i.type == ApplicationCommandType.ChatInput);\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n if (!level1Item) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n name_localizations: localeData.nameLocales(1),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales,\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n } else {\r\n let level2Item = level1Item.options.find(i => i.name == current.name.split(\" \")[1]);\r\n if (!level2Item) {\r\n level1Item.options.push({\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n name_localizations: localeData.nameLocales(1),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales\r\n }\r\n ]\r\n })\r\n } else {\r\n level2Item.options.push({\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n case \"MessageContextMenu\": {\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n all.push({\r\n type: ApplicationCommandType.Message,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n name_localizations: localeData.allNameLocales,\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n break;\r\n }\r\n case \"UserContextMenu\": {\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n all.push({\r\n type: ApplicationCommandType.User,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n name_localizations: localeData.allNameLocales,\r\n description_localizations: localeData.descriptionLocales\r\n });\r\n break;\r\n }\r\n }\r\n\r\n return all;\r\n }, []);\r\n \r\n switch (publishType) {\r\n case \"Global\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body });\r\n break;\r\n }\r\n }\r\n \r\n}\r\n\r\nexport function localeifyOptions(options: any[], localeData: any): any[] {\r\n return options.map(i => {\r\n let optionData = localeData[i.name];\r\n return optionData ? Object.assign(i, {\r\n name_localizations: optionData.nameLocales,\r\n description_localizations: optionData.descriptionLocales,\r\n choices: i.choices ? i.choices.map((j) => {\r\n let choiceLocale = optionData.choiceLocales[j.name];\r\n return choiceLocale ? Object.assign(j, {\r\n name_localizations: choiceLocale\r\n }) : j;\r\n }) : undefined\r\n }) : i;\r\n })\r\n}\r\n\r\nexport function formatLocale(locale: DBIInteractionLocale): any {\r\n let allNameLocales = {};\r\n let descriptionLocales = {};\r\n let optionsLocales = {};\r\n\r\n function nameLocales(index) {\r\n return Object.fromEntries(Object.entries(allNameLocales).map(i => [i[0], (i[1] as string).split(\" \").at(index)]));\r\n }\r\n\r\n if (!locale?.data) return {\r\n nameLocales,\r\n allNameLocales,\r\n descriptionLocales,\r\n optionsLocales\r\n };\r\n\r\n Object.entries(locale.data).forEach(([shortLocale, localeData]) => {\r\n let longAliases = ORIGINAL_LOCALES.filter(i => i.split(\"-\").at(0) == shortLocale);\r\n longAliases.forEach((longLocale) => {\r\n allNameLocales[longLocale] = localeData.name;\r\n descriptionLocales[longLocale] = localeData.description;\r\n Object.entries(localeData.options || []).forEach(([optionName, optionData]) => {\r\n if (!optionsLocales[optionName]) optionsLocales[optionName] = {};\r\n let optionLocale = optionsLocales[optionName];\r\n if (!optionLocale.nameLocales) optionLocale.nameLocales = {};\r\n if (!optionLocale.descriptionLocales) optionLocale.descriptionLocales = {};\r\n if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};\r\n\r\n Object.entries(optionData.choices).forEach(([choiceOriginalName, choiceName]) => {\r\n if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};\r\n if (!optionLocale.choiceLocales[choiceOriginalName]) optionLocale.choiceLocales[choiceOriginalName] = {};\r\n let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];\r\n \r\n choiceLocale[longLocale] = choiceName;\r\n });\r\n\r\n optionLocale.nameLocales[longLocale] = optionData.name;\r\n optionLocale.descriptionLocales[longLocale] = optionData.description;\r\n })\r\n });\r\n });\r\n \r\n return {\r\n nameLocales,\r\n allNameLocales,\r\n descriptionLocales,\r\n optionsLocales\r\n }\r\n}"]}
@@ -8,7 +8,7 @@ export interface IDBIButtonExecuteCtx extends IDBIBaseExecuteCtx {
8
8
  export declare type TDBIButtonOmitted = Omit<DBIButton, "type" | "description" | "dbi" | "toJSON">;
9
9
  export declare class DBIButton extends DBIBaseInteraction {
10
10
  constructor(dbi: DBI, args: TDBIButtonOmitted);
11
- options: Omit<Discord.ButtonComponentData, "customId" | "type">;
11
+ options?: Omit<Discord.ButtonComponentData, "customId" | "type"> | ((data: (number | string | any)[]) => Omit<Discord.ButtonComponentData, "customId" | "type">);
12
12
  onExecute(ctx: IDBIButtonExecuteCtx): Promise<any> | any;
13
13
  toJSON(...customData: (string | number | object)[]): Discord.ButtonComponentData;
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3F,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,iBAAiB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAE3F,qBAAa,SAAU,SAAQ,kBAAkB;gBACnC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,iBAAiB;IAOrC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,GAAG,MAAM,CAAC,CAAC;IAE/D,SAAS,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAEjE,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,mBAAmB;CAOjF"}
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3F,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,iBAAiB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAE3F,qBAAa,SAAU,SAAQ,kBAAkB;gBACnC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,iBAAiB;IAOrC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC;IAEhK,SAAS,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAEjE,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,mBAAmB;CAOjF"}
@@ -16,7 +16,7 @@ class DBIButton extends Interaction_1.DBIBaseInteraction {
16
16
  ;
17
17
  toJSON(...customData) {
18
18
  return {
19
- ...this.options,
19
+ ...(typeof this.options == "function" ? this.options(customData) : this.options),
20
20
  customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, customData),
21
21
  type: discord_js_1.default.ComponentType.Button
22
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAoD;AASpD,MAAa,SAAU,SAAQ,gCAAkB;IAC/C,YAAY,GAAQ,EAAE,IAAuB;QAC3C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAyB,IAAwB,CAAC;IAAA,CAAC;IAEtE,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;YAC1D,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,MAAM;SAC5B,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AAnBD,8BAmBC","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\n\r\nexport interface IDBIButtonExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBIButtonOmitted = Omit<DBIButton, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBIButton extends DBIBaseInteraction {\r\n constructor(dbi: DBI, args: TDBIButtonOmitted) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Button\",\r\n });\r\n }\r\n\r\n declare options: Omit<Discord.ButtonComponentData, \"customId\" | \"type\">;\r\n\r\n override onExecute(ctx: IDBIButtonExecuteCtx): Promise<any> | any { };\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.ButtonComponentData {\r\n return {\r\n ...this.options,\r\n customId: customIdBuilder(this.dbi, this.name, customData),\r\n type: Discord.ComponentType.Button\r\n } as any;\r\n };\r\n}"]}
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAoD;AASpD,MAAa,SAAU,SAAQ,gCAAkB;IAC/C,YAAY,GAAQ,EAAE,IAAuB;QAC3C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAyB,IAAwB,CAAC;IAAA,CAAC;IAEtE,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;YAChF,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;YAC1D,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,MAAM;SAC5B,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AAnBD,8BAmBC","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\n\r\nexport interface IDBIButtonExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBIButtonOmitted = Omit<DBIButton, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBIButton extends DBIBaseInteraction {\r\n constructor(dbi: DBI, args: TDBIButtonOmitted) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Button\",\r\n });\r\n }\r\n\r\n declare options?: Omit<Discord.ButtonComponentData, \"customId\" | \"type\"> | ((data: (number | string | any)[]) => Omit<Discord.ButtonComponentData, \"customId\" | \"type\">);\r\n\r\n override onExecute(ctx: IDBIButtonExecuteCtx): Promise<any> | any { };\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.ButtonComponentData {\r\n return {\r\n ...(typeof this.options == \"function\" ? this.options(customData) : this.options),\r\n customId: customIdBuilder(this.dbi, this.name, customData),\r\n type: Discord.ComponentType.Button\r\n } as any;\r\n };\r\n}"]}
@@ -136,6 +136,12 @@ export declare class DBIChatInputOptions {
136
136
  channelTypes: Discord.ChannelType[];
137
137
  required: boolean;
138
138
  };
139
+ static role(cfg: TNameDescription): {
140
+ type: Discord.ApplicationCommandOptionType;
141
+ name: string;
142
+ description: string;
143
+ required: boolean;
144
+ };
139
145
  static mentionable(cfg: TNameDescription): {
140
146
  type: Discord.ApplicationCommandOptionType;
141
147
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ChatInputOptions.d.ts","sourceRoot":"","sources":["../../../src/types/ChatInput/ChatInputOptions.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,aAAK,UAAU,CAAC,CAAC,IAAI;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAChD,aAAK,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAElF,aAAK,aAAa,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MA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
+ type: discord_js_1.default.ApplicationCommandOptionType.Role,
134
+ name: cfg.name,
135
+ description: cfg.description,
136
+ required: cfg.required
137
+ };
138
+ }
131
139
  static mentionable(cfg) {
132
140
  return {
133
141
  type: discord_js_1.default.ApplicationCommandOptionType.Mentionable,
@@ -1 +1 @@
1
- {"version":3,"file":"ChatInputOptions.js","sourceRoot":"","sources":["../../../src/types/ChatInput/ChatInputOptions.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAcjC,MAAa,mBAAmB;IAC9B,MAAM,CAAC,kBAAkB,CAAC,GAAmH;QAC3I,OAAO;YACL,IAAI,EAAE,oBAAO,CAAC,4BAA4B,CAAC,MAAM;YACjD,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,aAAa,CAAC,GAAyE;QAC5F,OAAO;YACL,IAAI,EAAE,oBAAO,CAAC,4BAA4B,CAAC,MAAM;YACjD,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,GAAqC;QACjD,OAAO;YACL,IAAI,EAAE,oBAAO,CAAC,4BAA4B,CAAC,MAAM;YACjD,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,GAAG,CAAC,S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AAE,oBAAO,CAAC,4BAA4B,CAAC,UAAU;YACrD,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,GAA+D;QAC5E,OAAO;YACL,IAAI,EAAE,oBAAO,CAAC,4BAA4B,CAAC,OAAO;YAClD,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,YAAY,EAAE,GAAG,CAAC,YAAY;YAC9B,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,GAAqB;QACtC,OAAO;YACL,IAAI,EAAE,oBAAO,CAAC,4BAA4B,CAAC,WAAW;YACtD,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,GAAqB;QAC/B,OAAO;YACL,IAAI,EAAE,oBAAO,CAAC,4BAA4B,CAAC,IAAI;YAC/C,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;CACF;AAzJD,kDAyJC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { IDBIBaseExecuteCtx } from \"../Interaction\";\r\n\r\ntype TValueName<T> = { value: T, name: string };\r\ntype TNameDescription = { name: string, description: string, required?: boolean };\r\n\r\ntype TMinMaxLength = { maxLength?: number, minLength?: number };\r\ntype TMinMaxValue = { maxValue?: number, minValue?: number };\r\n\r\nexport interface IDBICompleteCtx<TValueType = string | number> extends IDBIBaseExecuteCtx {\r\n interaction: Discord.AutocompleteInteraction;\r\n value: TValueType;\r\n}\r\n\r\nexport class DBIChatInputOptions {\r\n static stringAutocomplete(cfg: TNameDescription & TMinMaxLength & { onComplete(ctx: IDBICompleteCtx<string>): Promise<TValueName<string>[]> }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.String,\r\n name: cfg.name,\r\n autocomplete: true,\r\n onComplete: cfg.onComplete,\r\n description: cfg.description,\r\n maxLength: cfg.maxLength,\r\n minLength: cfg.minLength,\r\n required: cfg.required\r\n };\r\n }\r\n static stringChoices(cfg: TNameDescription & TMinMaxLength & { choices: TValueName<string>[] }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.String,\r\n name: cfg.name,\r\n choices: cfg.choices,\r\n description: cfg.description,\r\n maxLength: cfg.maxLength,\r\n minLength: cfg.minLength,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static string(cfg: TNameDescription & TMinMaxLength) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.String,\r\n name: cfg.name,\r\n description: cfg.description,\r\n maxLength: cfg.maxLength,\r\n minLength: cfg.minLength,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static numberAutocomplete(cfg: TNameDescription & TMinMaxValue & { onComplete(ctx: IDBICompleteCtx<string>): Promise<TValueName<number>[]> }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Number,\r\n name: cfg.name,\r\n autocomplete: true,\r\n onComplete: cfg.onComplete,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static numberChoices(cfg: TNameDescription & TMinMaxValue & { choices: TValueName<number>[] }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Number,\r\n name: cfg.name,\r\n choices: cfg.choices,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static number(cfg: TNameDescription & TMinMaxValue) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Number,\r\n name: cfg.name,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static integerAutocomplete(cfg: TNameDescription & TMinMaxValue & { onComplete(ctx: IDBICompleteCtx<string>): Promise<TValueName<number>[]> }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Integer,\r\n name: cfg.name,\r\n autocomplete: true,\r\n onComplete: cfg.onComplete,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static integerChoices(cfg: TNameDescription & TMinMaxValue & { choices: TValueName<number>[] }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Integer,\r\n name: cfg.name,\r\n choices: cfg.choices,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static integer(cfg: TNameDescription & TMinMaxValue) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Integer,\r\n name: cfg.name,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static boolean(cfg: TNameDescription) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Boolean,\r\n name: cfg.name,\r\n description: cfg.description,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static attachment(cfg: TNameDescription) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Attachment,\r\n name: cfg.name,\r\n description: cfg.description,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static channel(cfg: TNameDescription & { channelTypes: Discord.ChannelType[] }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Channel,\r\n name: cfg.name,\r\n description: cfg.description,\r\n channelTypes: cfg.channelTypes,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static mentionable(cfg: TNameDescription) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Mentionable,\r\n name: cfg.name,\r\n description: cfg.description,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static user(cfg: TNameDescription) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.User,\r\n name: cfg.name,\r\n description: cfg.description,\r\n required: cfg.required\r\n };\r\n }\r\n}"]}
1
+ {"version":3,"file":"ChatInputOptions.js","sourceRoot":"","sources":["../../../src/types/ChatInput/ChatInputOptions.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAcjC,MAAa,mBAAmB;IAC9B,MAAM,CAAC,kBAAkB,CAAC,GAAmH;QAC3I,OAAO;YACL,IAAI,EAAE,oBAAO,CAAC,4BAA4B,CAAC,MAAM;YACjD,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,aAAa,CAAC,GAAyE;QAC5F,OAAO;YACL,IAAI,EAAE,oBAAO,CAAC,4BAA4B,CAAC,MAAM;YACjD,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,GAAqC;QACjD,OAAO;YACL,IAAI,EAAE,oBAAO,CAAC,4BAA4B,CAAC,MAAM;YACjD,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,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x } from \"../Interaction\";\r\n\r\ntype TValueName<T> = { value: T, name: string };\r\ntype TNameDescription = { name: string, description: string, required?: boolean };\r\n\r\ntype TMinMaxLength = { maxLength?: number, minLength?: number };\r\ntype TMinMaxValue = { maxValue?: number, minValue?: number };\r\n\r\nexport interface IDBICompleteCtx<TValueType = string | number> extends IDBIBaseExecuteCtx {\r\n interaction: Discord.AutocompleteInteraction;\r\n value: TValueType;\r\n}\r\n\r\nexport class DBIChatInputOptions {\r\n static stringAutocomplete(cfg: TNameDescription & TMinMaxLength & { onComplete(ctx: IDBICompleteCtx<string>): Promise<TValueName<string>[]> }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.String,\r\n name: cfg.name,\r\n autocomplete: true,\r\n onComplete: cfg.onComplete,\r\n description: cfg.description,\r\n maxLength: cfg.maxLength,\r\n minLength: cfg.minLength,\r\n required: cfg.required\r\n };\r\n }\r\n static stringChoices(cfg: TNameDescription & TMinMaxLength & { choices: TValueName<string>[] }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.String,\r\n name: cfg.name,\r\n choices: cfg.choices,\r\n description: cfg.description,\r\n maxLength: cfg.maxLength,\r\n minLength: cfg.minLength,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static string(cfg: TNameDescription & TMinMaxLength) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.String,\r\n name: cfg.name,\r\n description: cfg.description,\r\n maxLength: cfg.maxLength,\r\n minLength: cfg.minLength,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static numberAutocomplete(cfg: TNameDescription & TMinMaxValue & { onComplete(ctx: IDBICompleteCtx<string>): Promise<TValueName<number>[]> }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Number,\r\n name: cfg.name,\r\n autocomplete: true,\r\n onComplete: cfg.onComplete,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static numberChoices(cfg: TNameDescription & TMinMaxValue & { choices: TValueName<number>[] }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Number,\r\n name: cfg.name,\r\n choices: cfg.choices,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static number(cfg: TNameDescription & TMinMaxValue) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Number,\r\n name: cfg.name,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static integerAutocomplete(cfg: TNameDescription & TMinMaxValue & { onComplete(ctx: IDBICompleteCtx<string>): Promise<TValueName<number>[]> }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Integer,\r\n name: cfg.name,\r\n autocomplete: true,\r\n onComplete: cfg.onComplete,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static integerChoices(cfg: TNameDescription & TMinMaxValue & { choices: TValueName<number>[] }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Integer,\r\n name: cfg.name,\r\n choices: cfg.choices,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static integer(cfg: TNameDescription & TMinMaxValue) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Integer,\r\n name: cfg.name,\r\n description: cfg.description,\r\n maxValue: cfg.maxValue,\r\n minValue: cfg.minValue,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static boolean(cfg: TNameDescription) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Boolean,\r\n name: cfg.name,\r\n description: cfg.description,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static attachment(cfg: TNameDescription) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Attachment,\r\n name: cfg.name,\r\n description: cfg.description,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static channel(cfg: TNameDescription & { channelTypes: Discord.ChannelType[] }) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Channel,\r\n name: cfg.name,\r\n description: cfg.description,\r\n channelTypes: cfg.channelTypes,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static role(cfg: TNameDescription) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Role,\r\n name: cfg.name,\r\n description: cfg.description,\r\n required: cfg.required\r\n }\r\n }\r\n\r\n static mentionable(cfg: TNameDescription) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.Mentionable,\r\n name: cfg.name,\r\n description: cfg.description,\r\n required: cfg.required\r\n };\r\n }\r\n\r\n static user(cfg: TNameDescription) {\r\n return {\r\n type: Discord.ApplicationCommandOptionType.User,\r\n name: cfg.name,\r\n description: cfg.description,\r\n required: cfg.required\r\n };\r\n }\r\n}"]}
@@ -8,6 +8,9 @@ export declare type TDBIInteractionLocaleData = {
8
8
  [k: string]: {
9
9
  name: string;
10
10
  description: string;
11
+ choices?: {
12
+ [k: string]: string;
13
+ };
11
14
  };
12
15
  };
13
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"InteractionLocale.d.ts","sourceRoot":"","sources":["../../src/types/InteractionLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,oBAAY,yBAAyB,GAAG;KACrC,CAAC,IAAI,gBAAgB,CAAC,CAAC,EAAE;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE;YACR,CAAC,CAAC,EAAE,MAAM,GAAG;gBACX,IAAI,EAAE,MAAM,CAAC;gBACb,WAAW,EAAE,MAAM,CAAC;aACrB,CAAA;SACF,CAAA;KACF;CACF,CAAC;AAEF,oBAAY,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;AAE7E,qBAAa,oBAAoB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,yBAAyB,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;gBACG,GAAG,KAAA,EAAE,GAAG,EAAE,4BAA4B;CAKnD"}
1
+ {"version":3,"file":"InteractionLocale.d.ts","sourceRoot":"","sources":["../../src/types/InteractionLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,oBAAY,yBAAyB,GAAG;KACrC,CAAC,IAAI,gBAAgB,CAAC,CAAC,EAAE;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE;YACR,CAAC,CAAC,EAAE,MAAM,GAAG;gBACX,IAAI,EAAE,MAAM,CAAC;gBACb,WAAW,EAAE,MAAM,CAAC;gBACpB,OAAO,CAAC,EAAE;oBACR,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;iBACpB,CAAA;aACF,CAAA;SACF,CAAA;KACF;CACF,CAAC;AAEF,oBAAY,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;AAE7E,qBAAa,oBAAoB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,yBAAyB,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;gBACG,GAAG,KAAA,EAAE,GAAG,EAAE,4BAA4B;CAKnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"InteractionLocale.js","sourceRoot":"","sources":["../../src/types/InteractionLocale.ts"],"names":[],"mappings":";;;AAkBA,MAAa,oBAAoB;IAC/B,IAAI,CAAS;IACb,IAAI,CAA4B;IAChC,GAAG,CAAM;IACT,YAAY,GAAG,EAAE,GAAiC;QAChD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AATD,oDASC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { TDBILocaleString } from \"./Locale\";\r\n\r\nexport type TDBIInteractionLocaleData = {\r\n [K in TDBILocaleString]?: {\r\n name: string;\r\n description: string;\r\n options?: {\r\n [k: string]: {\r\n name: string;\r\n description: string;\r\n }\r\n }\r\n };\r\n};\r\n\r\nexport type TDBIInteractionLocaleOmitted = Omit<DBIInteractionLocale, \"dbi\">;\r\n\r\nexport class DBIInteractionLocale {\r\n name: string;\r\n data: TDBIInteractionLocaleData;\r\n dbi: DBI;\r\n constructor(dbi, cfg: TDBIInteractionLocaleOmitted) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this.data = cfg.data;\r\n }\r\n}"]}
1
+ {"version":3,"file":"InteractionLocale.js","sourceRoot":"","sources":["../../src/types/InteractionLocale.ts"],"names":[],"mappings":";;;AAqBA,MAAa,oBAAoB;IAC/B,IAAI,CAAS;IACb,IAAI,CAA4B;IAChC,GAAG,CAAM;IACT,YAAY,GAAG,EAAE,GAAiC;QAChD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AATD,oDASC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { TDBILocaleString } from \"./Locale\";\r\n\r\nexport type TDBIInteractionLocaleData = {\r\n [K in TDBILocaleString]?: {\r\n name: string;\r\n description: string;\r\n options?: {\r\n [k: string]: {\r\n name: string;\r\n description: string;\r\n choices?: {\r\n [k: string]: string\r\n }\r\n }\r\n }\r\n };\r\n};\r\n\r\nexport type TDBIInteractionLocaleOmitted = Omit<DBIInteractionLocale, \"dbi\">;\r\n\r\nexport class DBIInteractionLocale {\r\n name: string;\r\n data: TDBIInteractionLocaleData;\r\n dbi: DBI;\r\n constructor(dbi, cfg: TDBIInteractionLocaleOmitted) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this.data = cfg.data;\r\n }\r\n}"]}
@@ -6,15 +6,15 @@ export interface LangConstructorObject {
6
6
  [property: string]: LangConstructorObject | string;
7
7
  }
8
8
  export declare type TDBILocaleString = "en" | "bg" | "zh" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "no" | "pl" | "pt" | "ro" | "ru" | "es" | "sv" | "th" | "tr" | "uk" | "vi";
9
- export declare type TDBILocaleConstructor = Omit<DBILocale, "data" | "dbi"> & {
10
- data: LangConstructorObject;
9
+ export declare type TDBILocaleConstructor<TDataFormat> = Omit<DBILocale, "data" | "dbi"> & {
10
+ data: TDataFormat;
11
11
  };
12
- export declare class DBILocale {
12
+ export declare class DBILocale<TDataFormat = LangConstructorObject> {
13
13
  name: TDBILocaleString;
14
14
  data: LangObject;
15
15
  private _data;
16
16
  dbi: DBI;
17
- constructor(dbi: DBI, cfg: TDBILocaleConstructor);
17
+ constructor(dbi: DBI, cfg: TDBILocaleConstructor<TDataFormat>);
18
18
  }
19
19
  export declare function convertLang(data: LangConstructorObject): LangObject;
20
20
  //# sourceMappingURL=Locale.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Locale.d.ts","sourceRoot":"","sources":["../../src/types/Locale.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,WAAW,UAAU;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,qBAAqB;IACpC,CAAC,QAAQ,EAAE,MAAM,GAA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AA2B;IACrD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;oBAC9B,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;gBACxF,CAAC,CAAC,CAAA;SACH;aAAM;YACL,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SAClC;IACH,CAAC,CAAC,CAAC,CAAA;AACL,CAAC;AAVD,kCAUC","sourcesContent":["// @ts-ignore\r\nimport * as stuffs from \"stuffs\";\r\nimport { DBI } from \"../DBI\";\r\n\r\nexport interface LangObject {\r\n [property: string]: LangObject & ((...args: any[]) => string);\r\n}\r\n\r\nexport interface LangConstructorObject {\r\n [property: string]: LangConstructorObject | string;\r\n}\r\n\r\nexport type TDBILocaleString = \"en\" | \"bg\" | \"zh\" | \"hr\" | \"cs\" | \"da\" | \"nl\" | \"fi\" | \"fr\" | \"de\" | \"el\" | \"hi\" | \"hu\" | \"it\" | \"ja\" | \"ko\" | \"no\" | \"pl\" | \"pt\" | \"ro\" | \"ru\" | \"es\" | \"sv\" | \"th\" | \"tr\" | \"uk\" | \"vi\";\r\n\r\nexport type TDBILocaleConstructor = Omit<DBILocale, \"data\" | \"dbi\"> & { data: LangConstructorObject };\r\n\r\nexport class DBILocale {\r\n name: TDBILocaleString;\r\n data: LangObject\r\n private _data: LangConstructorObject;\r\n dbi: DBI;\r\n constructor(dbi: DBI, cfg: TDBILocaleConstructor) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this._data = cfg.data;\r\n this.data = convertLang(cfg.data);\r\n }\r\n}\r\n\r\nexport function convertLang(data: LangConstructorObject): LangObject {\r\n return Object.fromEntries(Object.entries(data).map(([key, value]) => {\r\n if (typeof value === \"string\") {\r\n return [key, (...args: any[]) => {\r\n return stuffs.mapReplace(value, Object.fromEntries(args.map((t, i) => [`{${i}}`, t])))\r\n }]\r\n } else {\r\n return [key, convertLang(value)];\r\n }\r\n }))\r\n}\r\n"]}
1
+ {"version":3,"file":"Locale.js","sourceRoot":"","sources":["../../src/types/Locale.ts"],"names":[],"mappings":";;;;AAAA,aAAa;AACb,uDAAiC;AAejC,MAAa,SAAS;IACpB,IAAI,CAAmB;IACvB,IAAI,CAAa;IACT,KAAK,CAAc;IAC3B,GAAG,CAAM;IACT,YAAY,GAAQ,EAAE,GAAuC;QAC3D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,IAAW,CAAC,CAAC;IAC3C,CAAC;CACF;AAXD,8BAWC;AAED,SAAgB,WAAW,CAAC,IAA2B;IACrD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;oBAC9B,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;gBACxF,CAAC,CAAC,CAAA;SACH;aAAM;YACL,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SAClC;IACH,CAAC,CAAC,CAAC,CAAA;AACL,CAAC;AAVD,kCAUC","sourcesContent":["// @ts-ignore\r\nimport * as stuffs from \"stuffs\";\r\nimport { DBI } from \"../DBI\";\r\n\r\nexport interface LangObject {\r\n [property: string]: LangObject & ((...args: any[]) => string);\r\n}\r\n\r\nexport interface LangConstructorObject {\r\n [property: string]: LangConstructorObject | string;\r\n}\r\n\r\nexport type TDBILocaleString = \"en\" | \"bg\" | \"zh\" | \"hr\" | \"cs\" | \"da\" | \"nl\" | \"fi\" | \"fr\" | \"de\" | \"el\" | \"hi\" | \"hu\" | \"it\" | \"ja\" | \"ko\" | \"no\" | \"pl\" | \"pt\" | \"ro\" | \"ru\" | \"es\" | \"sv\" | \"th\" | \"tr\" | \"uk\" | \"vi\";\r\n\r\nexport type TDBILocaleConstructor<TDataFormat> = Omit<DBILocale, \"data\" | \"dbi\"> & { data: TDataFormat };\r\n\r\nexport class DBILocale<TDataFormat = LangConstructorObject> {\r\n name: TDBILocaleString;\r\n data: LangObject;\r\n private _data: TDataFormat;\r\n dbi: DBI;\r\n constructor(dbi: DBI, cfg: TDBILocaleConstructor<TDataFormat>) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this._data = cfg.data;\r\n this.data = convertLang(cfg.data as any);\r\n }\r\n}\r\n\r\nexport function convertLang(data: LangConstructorObject): LangObject {\r\n return Object.fromEntries(Object.entries(data).map(([key, value]) => {\r\n if (typeof value === \"string\") {\r\n return [key, (...args: any[]) => {\r\n return stuffs.mapReplace(value, Object.fromEntries(args.map((t, i) => [`{${i}}`, t])))\r\n }]\r\n } else {\r\n return [key, convertLang(value)];\r\n }\r\n }))\r\n}\r\n"]}
@@ -8,7 +8,7 @@ export interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {
8
8
  export declare type TDBIModalOmitted = Omit<DBIModal, "type" | "description" | "dbi" | "toJSON">;
9
9
  export declare class DBIModal extends DBIBaseInteraction {
10
10
  constructor(dbi: DBI, cfg: TDBIModalOmitted);
11
- options: Omit<Discord.ModalComponentData, "customId">;
11
+ options: Omit<Discord.ModalComponentData, "customId"> | ((data: (number | string | any)[]) => Omit<Discord.ModalComponentData, "customId">);
12
12
  onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any;
13
13
  toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData;
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,WAAW,EAAE,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAEtD,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAEzF,qBAAa,QAAS,SAAQ,kBAAkB;gBAClC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,gBAAgB;IAOnC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;IAErD,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAEhE,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,kBAAkB;CAMhF"}
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,WAAW,EAAE,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAEtD,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAEzF,qBAAa,QAAS,SAAQ,kBAAkB;gBAClC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,gBAAgB;IAOnC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC,CAAC;IAE3I,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAEhE,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,kBAAkB;CAMhF"}
@@ -14,7 +14,7 @@ class DBIModal extends Interaction_1.DBIBaseInteraction {
14
14
  ;
15
15
  toJSON(...customData) {
16
16
  return {
17
- ...this.options,
17
+ ...(typeof this.options == "function" ? this.options(customData) : this.options),
18
18
  customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, customData)
19
19
  };
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;AACA,+CAA2F;AAE3F,gDAAoD;AAUpD,MAAa,QAAS,SAAQ,gCAAkB;IAC9C,YAAY,GAAQ,EAAE,GAAqB;QACzC,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,GAAW;YACf,IAAI,EAAE,OAAO;SACd,CAAC,CAAA;IACJ,CAAC;IAIQ,SAAS,CAAC,GAAwB,IAAwB,CAAC;IAAA,CAAC;IAErE,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;SACpD,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AAlBD,4BAkBC","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\n\r\nexport interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ModalSubmitInteraction<\"cached\">;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBIModalOmitted = Omit<DBIModal, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBIModal extends DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: TDBIModalOmitted) {\r\n super(dbi, {\r\n ...(cfg as any),\r\n type: \"Modal\"\r\n })\r\n }\r\n\r\n declare options: Omit<Discord.ModalComponentData, \"customId\">;\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any { };\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData {\r\n return {\r\n ...this.options,\r\n customId: customIdBuilder(this.dbi, this.name, customData)\r\n } as any;\r\n };\r\n}"]}
1
+ {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;AACA,+CAA2F;AAE3F,gDAAoD;AAUpD,MAAa,QAAS,SAAQ,gCAAkB;IAC9C,YAAY,GAAQ,EAAE,GAAqB;QACzC,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,GAAW;YACf,IAAI,EAAE,OAAO;SACd,CAAC,CAAA;IACJ,CAAC;IAIQ,SAAS,CAAC,GAAwB,IAAwB,CAAC;IAAA,CAAC;IAErE,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;YAChF,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;SACpD,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AAlBD,4BAkBC","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\n\r\nexport interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ModalSubmitInteraction<\"cached\">;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBIModalOmitted = Omit<DBIModal, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBIModal extends DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: TDBIModalOmitted) {\r\n super(dbi, {\r\n ...(cfg as any),\r\n type: \"Modal\"\r\n })\r\n }\r\n\r\n declare options: Omit<Discord.ModalComponentData, \"customId\"> | ((data: (number | string | any)[]) => Omit<Discord.ModalComponentData, \"customId\">);\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any { };\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData {\r\n return {\r\n ...(typeof this.options == \"function\" ? this.options(customData) : this.options),\r\n customId: customIdBuilder(this.dbi, this.name, customData)\r\n } as any;\r\n };\r\n}"]}
@@ -8,7 +8,7 @@ export interface IDBISelectMenuExecuteCtx extends IDBIBaseExecuteCtx {
8
8
  export declare type TDBISelectMenuOmitted = Omit<DBIBaseInteraction, "type" | "description" | "dbi" | "toJSON">;
9
9
  export declare class DBISelectMenu extends DBIBaseInteraction {
10
10
  constructor(dbi: DBI, args: TDBISelectMenuOmitted);
11
- options: Omit<Discord.SelectMenuComponentData, "customId" | "type">;
11
+ options: Omit<Discord.SelectMenuComponentData, "customId" | "type"> | ((data: (number | string | any)[]) => Omit<Discord.SelectMenuComponentData, "customId" | "type">);
12
12
  onExecute(ctx: IDBISelectMenuExecuteCtx): Promise<any> | any;
13
13
  toJSON(...customData: (string | number | object)[]): Discord.SelectMenuComponentData;
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SelectMenu.d.ts","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3F,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,qBAAqB,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAExG,qBAAa,aAAc,SAAQ,kBAAkB;gBAC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AAG,CAAC,GAAG,GAAG;IAErE,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,uBAAuB;CAOrF"}
@@ -16,7 +16,7 @@ class DBISelectMenu extends Interaction_1.DBIBaseInteraction {
16
16
  ;
17
17
  toJSON(...customData) {
18
18
  return {
19
- ...this.options,
19
+ ...(typeof this.options == "function" ? this.options(customData) : this.options),
20
20
  customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, customData),
21
21
  type: discord_js_1.default.ComponentType.SelectMenu
22
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAoD;AASpD,MAAa,aAAc,SAAQ,gCAAkB;IACnD,YAAY,GAAQ,EAAE,IAA2B;QAC/C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAA6B,IAAwB,CAAC;IAAA,CAAC;IAE1E,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;YAC1D,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,UAAU;SAChC,CAAA;IACV,CAAC;IAAA,CAAC;CACH;AAnBD,sCAmBC","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\n\r\nexport interface IDBISelectMenuExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBISelectMenuOmitted = Omit<DBIBaseInteraction, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBISelectMenu extends DBIBaseInteraction {\r\n constructor(dbi: DBI, args: TDBISelectMenuOmitted) {\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.SelectMenuComponentData, \"customId\" | \"type\">;\r\n\r\n override onExecute(ctx: IDBISelectMenuExecuteCtx): Promise<any> | any { };\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.SelectMenuComponentData {\r\n return {\r\n ...this.options,\r\n customId: customIdBuilder(this.dbi, this.name, customData),\r\n type: Discord.ComponentType.SelectMenu\r\n } as any\r\n };\r\n}"]}
1
+ {"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAoD;AASpD,MAAa,aAAc,SAAQ,gCAAkB;IACnD,YAAY,GAAQ,EAAE,IAA2B;QAC/C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAA6B,IAAwB,CAAC;IAAA,CAAC;IAE1E,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;YAChF,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;YAC1D,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,UAAU;SAChC,CAAA;IACV,CAAC;IAAA,CAAC;CACH;AAnBD,sCAmBC","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\n\r\nexport interface IDBISelectMenuExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBISelectMenuOmitted = Omit<DBIBaseInteraction, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBISelectMenu extends DBIBaseInteraction {\r\n constructor(dbi: DBI, args: TDBISelectMenuOmitted) {\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.SelectMenuComponentData, \"customId\" | \"type\"> | ((data: (number | string | any)[]) => Omit<Discord.SelectMenuComponentData, \"customId\" | \"type\">);\r\n\r\n override onExecute(ctx: IDBISelectMenuExecuteCtx): Promise<any> | any { };\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.SelectMenuComponentData {\r\n return {\r\n ...(typeof this.options == \"function\" ? this.options(customData) : this.options),\r\n customId: customIdBuilder(this.dbi, this.name, customData),\r\n type: Discord.ComponentType.SelectMenu\r\n } as any\r\n };\r\n}"]}
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "stuffs": "^0.1.17"
10
10
  },
11
11
  "name": "@mostfeatured/dbi",
12
- "version": "0.0.25",
12
+ "version": "0.0.28",
13
13
  "main": "dist/index.js",
14
14
  "type": "commonjs",
15
15
  "private": false,
package/src/DBI.ts CHANGED
@@ -6,7 +6,7 @@ import { DBIEvent, TDBIEventOmitted } from "./types/Event";
6
6
  import { MemoryStore } from "./utils/MemoryStore";
7
7
  import { hookInteractionListeners } from "./methods/hookInteractionListeners";
8
8
  import { Events } from "./Events";
9
- import { DBILocale, TDBILocaleConstructor, TDBILocaleString } from "./types/Locale";
9
+ import { DBILocale, LangConstructorObject, TDBILocaleConstructor, TDBILocaleString } from "./types/Locale";
10
10
  import { DBIButton, TDBIButtonOmitted } from "./types/Button";
11
11
  import { DBISelectMenu, TDBISelectMenuOmitted } from "./types/SelectMenu";
12
12
  import { DBIMessageContextMenu, TDBIMessageContextMenuOmitted } from "./types/MessageContextMenu";
@@ -41,6 +41,8 @@ export interface DBIConfig {
41
41
  * Persist store. (Default to MemoryStore thats not persis tho.)
42
42
  */
43
43
  store: DBIStore;
44
+
45
+ clearRefsAfter?: number;
44
46
  }
45
47
 
46
48
  export interface DBIConfigConstructor {
@@ -59,13 +61,15 @@ export interface DBIConfigConstructor {
59
61
  * Persist store. (Default to MemoryStore thats not persis tho.)
60
62
  */
61
63
  store?: DBIStore;
64
+
65
+ clearRefsAfter?: number;
62
66
  }
63
67
 
64
- export interface DBIRegisterAPI {
68
+ export interface DBIRegisterAPI<TLocaleFormat> {
65
69
  ChatInput(cfg: TDBIChatInputOmitted): DBIChatInput;
66
70
  ChatInputOptions: typeof DBIChatInputOptions;
67
71
  Event(cfg: TDBIEventOmitted): DBIEvent;
68
- Locale(cfg: TDBILocaleConstructor): DBILocale;
72
+ Locale(cfg: TDBILocaleConstructor<TLocaleFormat>): DBILocale;
69
73
  Button(cfg: TDBIButtonOmitted): DBIButton;
70
74
  SelectMenu(cfg: TDBISelectMenuOmitted): DBISelectMenu;
71
75
  MessageContextMenu(cfg: TDBIMessageContextMenuOmitted): DBIMessageContextMenu;
@@ -75,7 +79,7 @@ export interface DBIRegisterAPI {
75
79
  onUnload(cb: () => Promise<any> | any): any;
76
80
  }
77
81
 
78
- export class DBI<TOtherData = Record<string, any>> {
82
+ export class DBI<TOtherData = Record<string, any>, TLocaleFormat = LangConstructorObject> {
79
83
  namespace: string;
80
84
  config: DBIConfig;
81
85
  client: Discord.Client<true>;
@@ -83,7 +87,7 @@ export class DBI<TOtherData = Record<string, any>> {
83
87
  interactions: Discord.Collection<string, DBIChatInput | DBIButton | DBISelectMenu | DBIMessageContextMenu | DBIUserContextMenu | DBIModal>;
84
88
  events: Discord.Collection<string, DBIEvent>;
85
89
  plugins: Discord.Collection<string, any>;
86
- locales: Discord.Collection<string, DBILocale>;
90
+ locales: Discord.Collection<string, DBILocale<TLocaleFormat>>;
87
91
  interactionLocales: Discord.Collection<string, DBIInteractionLocale>;
88
92
  other: TOtherData;
89
93
  eventMap: Record<string, string[]>;
@@ -95,6 +99,7 @@ export class DBI<TOtherData = Record<string, any>> {
95
99
  events: Events;
96
100
  cluster?: Sharding.Client;
97
101
  private _loaded: boolean;
102
+ private _hooked: boolean;
98
103
  constructor(namespace: string, config: DBIConfigConstructor) {
99
104
  this.namespace = namespace;
100
105
 
@@ -124,7 +129,7 @@ export class DBI<TOtherData = Record<string, any>> {
124
129
  refs: new Map()
125
130
  }
126
131
 
127
- this.events = new Events(this);
132
+ this.events = new Events(this as any);
128
133
  this.client = new Discord.Client({
129
134
  ...(config.discord?.options || {}) as any,
130
135
  ...(config.sharding ? {
@@ -133,13 +138,37 @@ export class DBI<TOtherData = Record<string, any>> {
133
138
  } : {})
134
139
  });
135
140
  this.cluster = config.sharding ? new Sharding.Client(this.client) : undefined;
136
- this._hookListeners();
137
141
  this._loaded = false;
142
+ this._hooked = false;
138
143
  }
139
144
 
140
145
  private async _hookListeners() {
141
- this.data.unloaders.add(hookInteractionListeners(this));
142
- this.data.unloaders.add(hookEventListeners(this));
146
+ if (this._hooked) return;
147
+ this._hooked = true;
148
+ this.data.unloaders.add(hookInteractionListeners(this as any));
149
+ this.data.unloaders.add(hookEventListeners(this as any));
150
+ if (typeof this.config.clearRefsAfter == "number") {
151
+ this.data.unloaders.add((() => {
152
+ let interval = setInterval(() => {
153
+ this.data.refs.forEach(({ at }, key) => {
154
+ if (Date.now() > (at + this.config.clearRefsAfter)) {
155
+ this.data.refs.delete(key);
156
+ }
157
+ });
158
+ }, 60000);
159
+ return () => {
160
+ clearInterval(interval);
161
+ }
162
+ })());
163
+ }
164
+ }
165
+
166
+ private async _unhookListeners() {
167
+ if (!this._hooked) return;
168
+ this._hooked = false;
169
+ this.data.unloaders.forEach(f => {
170
+ f();
171
+ });
143
172
  }
144
173
 
145
174
  private async _unregisterAll() {
@@ -152,7 +181,7 @@ export class DBI<TOtherData = Record<string, any>> {
152
181
  }
153
182
 
154
183
  private async _registerAll() {
155
- const self = this;
184
+ const self = this as any;
156
185
 
157
186
  for await (const cb of this.data.registers) {
158
187
  let ChatInput = function(cfg: DBIChatInput) {
@@ -211,7 +240,7 @@ export class DBI<TOtherData = Record<string, any>> {
211
240
  };
212
241
  Modal = Object.assign(Modal, class { constructor(...args: any[]) { return Modal.apply(this, args as any); } });
213
242
 
214
- let Locale = function(cfg: TDBILocaleConstructor) {
243
+ let Locale = function(cfg: TDBILocaleConstructor<TLocaleFormat>) {
215
244
  let dbiLocale = new DBILocale(self, cfg);
216
245
  if (self.data.locales.has(dbiLocale.name)) throw new Error(`DBILocale "${dbiLocale.name}" already loaded!`);
217
246
  self.data.locales.set(dbiLocale.name, dbiLocale);
@@ -281,13 +310,14 @@ export class DBI<TOtherData = Record<string, any>> {
281
310
  await this.client.login(this.config.discord.token);
282
311
  }
283
312
 
284
- async register(cb: (api: DBIRegisterAPI) => void): Promise<any> {
313
+ async register(cb: (api: DBIRegisterAPI<TLocaleFormat>) => void): Promise<any> {
285
314
  this.data.registers.add(cb);
286
315
  }
287
316
 
288
317
  async load(): Promise<boolean> {
289
318
  if (this._loaded) return false;
290
319
  await this._registerAll();
320
+ await this._hookListeners();
291
321
  this._loaded = true;
292
322
  return true;
293
323
  }
@@ -295,6 +325,7 @@ export class DBI<TOtherData = Record<string, any>> {
295
325
  async unload(): Promise<boolean> {
296
326
  if (!this._loaded) return false;
297
327
  await this._unregisterAll();
328
+ await this._unhookListeners();
298
329
  this._loaded = false;
299
330
  return true;
300
331
  }
package/src/index.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { DBI, DBIConfigConstructor } from "./DBI";
2
+ import { LangConstructorObject } from "./types/Locale";
2
3
  export { recursiveImport } from "./utils/recursiveImport";
3
4
  export { MemoryStore } from "./utils/MemoryStore";
4
5
 
5
- export function createDBI<TOtherType = Record<string, any>>(namespace: string, cfg: DBIConfigConstructor): DBI<TOtherType> {
6
- return new DBI<TOtherType>(namespace, cfg);
6
+ export function createDBI<TOtherType = Record<string, any>, TDataFormat = LangConstructorObject>(namespace: string, cfg: DBIConfigConstructor): DBI<TOtherType, TDataFormat> {
7
+ return new DBI<TOtherType, TDataFormat>(namespace, cfg);
7
8
  }
@@ -171,8 +171,6 @@ export async function publishInteractions(
171
171
  return all;
172
172
  }, []);
173
173
 
174
- body = snakecaseKeys(body);
175
-
176
174
  switch (publishType) {
177
175
  case "Global": {
178
176
  await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });
@@ -188,9 +186,16 @@ export async function publishInteractions(
188
186
 
189
187
  export function localeifyOptions(options: any[], localeData: any): any[] {
190
188
  return options.map(i => {
191
- return localeData[i.name] ? Object.assign(i, {
192
- name_localizations: localeData[i.name].nameLocales,
193
- description_localizations: localeData[i.name].descriptionLocales,
189
+ let optionData = localeData[i.name];
190
+ return optionData ? Object.assign(i, {
191
+ name_localizations: optionData.nameLocales,
192
+ description_localizations: optionData.descriptionLocales,
193
+ choices: i.choices ? i.choices.map((j) => {
194
+ let choiceLocale = optionData.choiceLocales[j.name];
195
+ return choiceLocale ? Object.assign(j, {
196
+ name_localizations: choiceLocale
197
+ }) : j;
198
+ }) : undefined
194
199
  }) : i;
195
200
  })
196
201
  }
@@ -218,11 +223,21 @@ export function formatLocale(locale: DBIInteractionLocale): any {
218
223
  descriptionLocales[longLocale] = localeData.description;
219
224
  Object.entries(localeData.options || []).forEach(([optionName, optionData]) => {
220
225
  if (!optionsLocales[optionName]) optionsLocales[optionName] = {};
221
- if (!optionsLocales[optionName].nameLocales) optionsLocales[optionName].nameLocales = {};
222
- if (!optionsLocales[optionName].descriptionLocales) optionsLocales[optionName].descriptionLocales = {};
226
+ let optionLocale = optionsLocales[optionName];
227
+ if (!optionLocale.nameLocales) optionLocale.nameLocales = {};
228
+ if (!optionLocale.descriptionLocales) optionLocale.descriptionLocales = {};
229
+ if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};
230
+
231
+ Object.entries(optionData.choices).forEach(([choiceOriginalName, choiceName]) => {
232
+ if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};
233
+ if (!optionLocale.choiceLocales[choiceOriginalName]) optionLocale.choiceLocales[choiceOriginalName] = {};
234
+ let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];
235
+
236
+ choiceLocale[longLocale] = choiceName;
237
+ });
223
238
 
224
- optionsLocales[optionName].nameLocales[longLocale] = optionData.name;
225
- optionsLocales[optionName].descriptionLocales[longLocale] = optionData.description;
239
+ optionLocale.nameLocales[longLocale] = optionData.name;
240
+ optionLocale.descriptionLocales[longLocale] = optionData.description;
226
241
  })
227
242
  });
228
243
  });
@@ -18,13 +18,13 @@ export class DBIButton extends DBIBaseInteraction {
18
18
  });
19
19
  }
20
20
 
21
- declare options: Omit<Discord.ButtonComponentData, "customId" | "type">;
21
+ declare options?: Omit<Discord.ButtonComponentData, "customId" | "type"> | ((data: (number | string | any)[]) => Omit<Discord.ButtonComponentData, "customId" | "type">);
22
22
 
23
23
  override onExecute(ctx: IDBIButtonExecuteCtx): Promise<any> | any { };
24
24
 
25
25
  toJSON(...customData: (string | number | object)[]): Discord.ButtonComponentData {
26
26
  return {
27
- ...this.options,
27
+ ...(typeof this.options == "function" ? this.options(customData) : this.options),
28
28
  customId: customIdBuilder(this.dbi, this.name, customData),
29
29
  type: Discord.ComponentType.Button
30
30
  } as any;
@@ -148,6 +148,15 @@ export class DBIChatInputOptions {
148
148
  };
149
149
  }
150
150
 
151
+ static role(cfg: TNameDescription) {
152
+ return {
153
+ type: Discord.ApplicationCommandOptionType.Role,
154
+ name: cfg.name,
155
+ description: cfg.description,
156
+ required: cfg.required
157
+ }
158
+ }
159
+
151
160
  static mentionable(cfg: TNameDescription) {
152
161
  return {
153
162
  type: Discord.ApplicationCommandOptionType.Mentionable,
@@ -9,6 +9,9 @@ export type TDBIInteractionLocaleData = {
9
9
  [k: string]: {
10
10
  name: string;
11
11
  description: string;
12
+ choices?: {
13
+ [k: string]: string
14
+ }
12
15
  }
13
16
  }
14
17
  };
@@ -12,18 +12,18 @@ export interface LangConstructorObject {
12
12
 
13
13
  export type TDBILocaleString = "en" | "bg" | "zh" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "no" | "pl" | "pt" | "ro" | "ru" | "es" | "sv" | "th" | "tr" | "uk" | "vi";
14
14
 
15
- export type TDBILocaleConstructor = Omit<DBILocale, "data" | "dbi"> & { data: LangConstructorObject };
15
+ export type TDBILocaleConstructor<TDataFormat> = Omit<DBILocale, "data" | "dbi"> & { data: TDataFormat };
16
16
 
17
- export class DBILocale {
17
+ export class DBILocale<TDataFormat = LangConstructorObject> {
18
18
  name: TDBILocaleString;
19
- data: LangObject
20
- private _data: LangConstructorObject;
19
+ data: LangObject;
20
+ private _data: TDataFormat;
21
21
  dbi: DBI;
22
- constructor(dbi: DBI, cfg: TDBILocaleConstructor) {
22
+ constructor(dbi: DBI, cfg: TDBILocaleConstructor<TDataFormat>) {
23
23
  this.dbi = dbi;
24
24
  this.name = cfg.name;
25
25
  this._data = cfg.data;
26
- this.data = convertLang(cfg.data);
26
+ this.data = convertLang(cfg.data as any);
27
27
  }
28
28
  }
29
29
 
@@ -19,13 +19,13 @@ export class DBIModal extends DBIBaseInteraction {
19
19
  })
20
20
  }
21
21
 
22
- declare options: Omit<Discord.ModalComponentData, "customId">;
22
+ declare options: Omit<Discord.ModalComponentData, "customId"> | ((data: (number | string | any)[]) => Omit<Discord.ModalComponentData, "customId">);
23
23
 
24
24
  override onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any { };
25
25
 
26
26
  toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData {
27
27
  return {
28
- ...this.options,
28
+ ...(typeof this.options == "function" ? this.options(customData) : this.options),
29
29
  customId: customIdBuilder(this.dbi, this.name, customData)
30
30
  } as any;
31
31
  };
@@ -18,13 +18,13 @@ export class DBISelectMenu extends DBIBaseInteraction {
18
18
  });
19
19
  }
20
20
 
21
- declare options: Omit<Discord.SelectMenuComponentData, "customId" | "type">;
21
+ declare options: Omit<Discord.SelectMenuComponentData, "customId" | "type"> | ((data: (number | string | any)[]) => Omit<Discord.SelectMenuComponentData, "customId" | "type">);
22
22
 
23
23
  override onExecute(ctx: IDBISelectMenuExecuteCtx): Promise<any> | any { };
24
24
 
25
25
  toJSON(...customData: (string | number | object)[]): Discord.SelectMenuComponentData {
26
26
  return {
27
- ...this.options,
27
+ ...(typeof this.options == "function" ? this.options(customData) : this.options),
28
28
  customId: customIdBuilder(this.dbi, this.name, customData),
29
29
  type: Discord.ComponentType.SelectMenu
30
30
  } as any