@mostfeatured/dbi 0.0.61 โ 0.0.64
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.
- package/dist/DBI.d.ts +8 -0
- package/dist/DBI.d.ts.map +1 -1
- package/dist/DBI.js +2 -2
- package/dist/DBI.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/methods/publishInteractions.d.ts.map +1 -1
- package/dist/methods/publishInteractions.js +2 -4
- package/dist/methods/publishInteractions.js.map +1 -1
- package/dist/types/Button.js +1 -1
- package/dist/types/Button.js.map +1 -1
- package/dist/types/Modal.js +1 -1
- package/dist/types/Modal.js.map +1 -1
- package/dist/types/SelectMenu.js +1 -1
- package/dist/types/SelectMenu.js.map +1 -1
- package/dist/utils/customId.d.ts +1 -1
- package/dist/utils/customId.d.ts.map +1 -1
- package/dist/utils/customId.js +8 -4
- package/dist/utils/customId.js.map +1 -1
- package/package.json +1 -1
- package/src/DBI.ts +7 -2
- package/src/index.ts +8 -1
- package/src/methods/publishInteractions.ts +2 -4
- package/src/types/Button.ts +2 -2
- package/src/types/Modal.ts +2 -2
- package/src/types/SelectMenu.ts +2 -2
- package/src/utils/customId.ts +4 -2
package/dist/DBI.d.ts
CHANGED
|
@@ -64,6 +64,14 @@ export interface DBIConfigConstructor {
|
|
|
64
64
|
ttl: number;
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
+
data?: {
|
|
68
|
+
other?: Record<string, any>;
|
|
69
|
+
refs?: Map<string, {
|
|
70
|
+
at: number;
|
|
71
|
+
value: any;
|
|
72
|
+
ttl?: number;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
67
75
|
strict?: boolean;
|
|
68
76
|
}
|
|
69
77
|
export interface DBIRegisterAPI<TNamespace extends NamespaceEnums> {
|
package/dist/DBI.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
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AAQ,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,cAAc,CAAC,UAAU,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;IAIrE,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAQxB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAQhC,IAAI,MAAM,IAAI,OAAO,CAEpB;IAEK,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IACtD,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;CA0B7E"}
|
package/dist/DBI.js
CHANGED
|
@@ -53,13 +53,13 @@ class DBI {
|
|
|
53
53
|
events: new discord_js_1.default.Collection(),
|
|
54
54
|
locales: new discord_js_1.default.Collection(),
|
|
55
55
|
interactionLocales: new discord_js_1.default.Collection(),
|
|
56
|
-
other: {},
|
|
56
|
+
other: config.data?.other ?? {},
|
|
57
57
|
eventMap: eventMap_json_1.default,
|
|
58
58
|
customEventNames: new Set(),
|
|
59
59
|
unloaders: new Set(),
|
|
60
60
|
registers: new Set(),
|
|
61
61
|
registerUnloaders: new Set(),
|
|
62
|
-
refs: new Map()
|
|
62
|
+
refs: config.data?.refs ?? new Map()
|
|
63
63
|
};
|
|
64
64
|
this.events = new Events_1.Events(this);
|
|
65
65
|
this.client = new discord_js_1.default.Client({
|
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,yCAAyE;AACzE,qDAAkD;AAClD,iFAA8E;AAC9E,qCAAkC;AAClC,2CAAoF;AACpF,2CAA8D;AAC9D,mDAA0E;AAC1E,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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;AA7UD,kBA6UC","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 { ClientEvents, 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\nimport { TDBIInteractions } from \"./types/Interaction\";\r\nimport { NamespaceData, NamespaceEnums } from \"../generated/namespaceData\";\r\nimport { DBICustomEvent, TDBICustomEventOmitted } from \"./types/CustomEvent\";\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: \"hybrid\" | \"default\" | \"off\";\r\n /**\r\n * Persist store. (Default to MemoryStore thats not persis tho.)\r\n */\r\n store: DBIStore;\r\n\r\n references: {\r\n autoClear?: {\r\n check: number;\r\n ttl: number;\r\n }\r\n };\r\n\r\n strict: boolean;\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?: \"hybrid\" | \"default\" | \"off\";\r\n /**\r\n * Persist store. (Default to MemoryStore thats not persis tho.)\r\n */\r\n store?: DBIStore;\r\n\r\n references?: {\r\n autoClear?: {\r\n check: number;\r\n ttl: number;\r\n }\r\n };\r\n\r\n strict?: boolean;\r\n}\r\n\r\nexport interface DBIRegisterAPI<TNamespace extends NamespaceEnums> {\r\n ChatInput(cfg: TDBIChatInputOmitted<TNamespace>): DBIChatInput<TNamespace>;\r\n ChatInputOptions: DBIChatInputOptions<TNamespace>;\r\n Event(cfg: TDBIEventOmitted<TNamespace>): DBIEvent<TNamespace>;\r\n Locale(cfg: TDBILocaleConstructor<TNamespace>): DBILocale<TNamespace>;\r\n Button(cfg: TDBIButtonOmitted<TNamespace>): DBIButton<TNamespace>;\r\n SelectMenu(cfg: TDBISelectMenuOmitted<TNamespace>): DBISelectMenu<TNamespace>;\r\n MessageContextMenu(cfg: TDBIMessageContextMenuOmitted<TNamespace>): DBIMessageContextMenu<TNamespace>;\r\n UserContextMenu(cfg: TDBIUserContextMenuOmitted<TNamespace>): DBIUserContextMenu<TNamespace>;\r\n InteractionLocale(cfg: TDBIInteractionLocaleOmitted): DBIInteractionLocale;\r\n Modal(cfg: TDBIModalOmitted<TNamespace>): DBIModal<TNamespace>;\r\n CustomEvent<T extends keyof NamespaceData[TNamespace][\"customEvents\"]>(cfg: TDBICustomEventOmitted<TNamespace, T>): DBICustomEvent<TNamespace, T>;\r\n onUnload(cb: () => Promise<any> | any): any;\r\n}\r\n\r\nexport class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string, any>> {\r\n namespace: TNamespace;\r\n config: DBIConfig;\r\n client: Discord.Client<true>;\r\n data: {\r\n interactions: Discord.Collection<string, TDBIInteractions<TNamespace>>;\r\n events: Discord.Collection<string, DBIEvent<TNamespace>>;\r\n locales: Discord.Collection<string, DBILocale<TNamespace>>;\r\n interactionLocales: Discord.Collection<string, DBIInteractionLocale>;\r\n other: TOtherData;\r\n eventMap: Record<string, string[] | { [k: string]: string }>;\r\n customEventNames: Set<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, ttl?: number }>;\r\n };\r\n events: Events<TNamespace>;\r\n cluster?: Sharding.Client;\r\n private _loaded: boolean;\r\n private _hooked: boolean;\r\n constructor(namespace: TNamespace, config: DBIConfigConstructor) {\r\n this.namespace = namespace as any;\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 ?? \"off\";\r\n config.strict = config.strict ?? true;\r\n config.references = {\r\n autoClear: undefined,\r\n ...(config.references || {})\r\n }\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 locales: new Discord.Collection(),\r\n interactionLocales: new Discord.Collection(),\r\n other: {} as TOtherData,\r\n eventMap,\r\n customEventNames: new Set(),\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 == \"hybrid\" ? {\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 == \"hybrid\" ? 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.references.autoClear != \"undefined\") {\r\n this.data.unloaders.add((() => {\r\n let interval = setInterval(() => {\r\n this.data.refs.forEach(({ at, ttl }, key) => {\r\n if (Date.now() > (at + (ttl || this.config.references.autoClear.ttl))) {\r\n this.data.refs.delete(key);\r\n }\r\n });\r\n }, this.config.references.autoClear.check);\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.customEventNames.forEach((value) => {\r\n delete this.data.eventMap[value];\r\n });\r\n this.data.customEventNames.clear();\r\n }\r\n\r\n private async _registerAll() {\r\n const self = this;\r\n const ChatInputOptions = new DBIChatInputOptions(self);\r\n\r\n for await (const cb of this.data.registers) {\r\n let ChatInput = function (cfg: DBIChatInput<TNamespace>) {\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<TNamespace>) {\r\n let dbiEvent = new DBIEvent(self as any, cfg);\r\n if (self.config.strict && 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<TNamespace>) {\r\n let dbiButton = new DBIButton(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiSelectMenu = new DBISelectMenu(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiMessageContextMenu = new DBIMessageContextMenu(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiUserContextMenu = new DBIUserContextMenu(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiModal = new DBIModal(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiLocale = new DBILocale(self as any, cfg);\r\n if (self.config.strict && self.data.interactionLocales.has(dbiLocale.name)) throw new Error(`DBILocale \"${dbiLocale.name}\" already loaded!`);\r\n if (self.data.locales.has(dbiLocale.name)) dbiLocale.mergeLocale(self.data.locales.get(dbiLocale.name));\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 CustomEvent = function (cfg: TDBICustomEventOmitted<TNamespace>) {\r\n let dbiCustomEvent = new DBICustomEvent(self, cfg) as any;\r\n if (self.config.strict && self.data.eventMap[dbiCustomEvent.name]) throw new Error(`DBICustomEvent \"${dbiCustomEvent.name}\" already loaded!`);\r\n self.data.eventMap[dbiCustomEvent.name] = dbiCustomEvent.map;\r\n self.data.customEventNames.add(dbiCustomEvent.name);\r\n return dbiCustomEvent;\r\n };\r\n CustomEvent = Object.assign(CustomEvent, class { constructor(...args: any[]) { return CustomEvent.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.config.strict && 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,\r\n Locale,\r\n Button,\r\n SelectMenu,\r\n MessageContextMenu,\r\n UserContextMenu,\r\n CustomEvent,\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 * this.data.interactions.get(name)\r\n */\r\n interaction<TInteractionName extends keyof NamespaceData[TNamespace][\"interactionMapping\"]>(name: TInteractionName): NamespaceData[TNamespace][\"interactionMapping\"][TInteractionName] {\r\n return this.data.interactions.get(name as any) as any;\r\n }\r\n\r\n emit<TEventName extends keyof (NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)>(name: TEventName, args: (NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[TEventName] ): void {\r\n this.client.emit(name as any, { ...args, _DIRECT_: true } as any);\r\n }\r\n\r\n/**\r\n * \r\n * ((NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[K] as const)\r\n * typeof ((NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[K])[keyof typeof ((NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[K])]\r\n */\r\n\r\n /**\r\n * this.data.events.get(name)\r\n */\r\n event<TEventName extends NamespaceData[TNamespace][\"eventNames\"]>(name: TEventName): DBIEvent<TNamespace> {\r\n return this.data.events.get(name);\r\n }\r\n\r\n /**\r\n * this.data.locales.get(name)\r\n */\r\n locale<TLocaleName extends NamespaceData[TNamespace][\"localeNames\"]>(name: TLocaleName): DBILocale<TNamespace> {\r\n return this.data.locales.get(name) as any;\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.sharding == \"default\" ? undefined : this.config.discord.token);\r\n }\r\n\r\n async register(cb: (api: DBIRegisterAPI<TNamespace>) => 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}"]}
|
|
1
|
+
{"version":3,"file":"DBI.js","sourceRoot":"","sources":["../src/DBI.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AACjC,2DAAiF;AACjF,yEAAyE;AACzE,uEAAoE;AACpE,yCAAyE;AACzE,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;AAG/F,qDAA6E;AAmF7E,MAAa,GAAG;IACd,SAAS,CAAa;IACtB,MAAM,CAAY;IAClB,MAAM,CAAuB;IAC7B,IAAI,CAYF;IACF,MAAM,CAAqB;IAC3B,OAAO,CAAmB;IAClB,OAAO,CAAU;IAC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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 { ClientEvents, 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\nimport { TDBIInteractions } from \"./types/Interaction\";\r\nimport { NamespaceData, NamespaceEnums } from \"../generated/namespaceData\";\r\nimport { DBICustomEvent, TDBICustomEventOmitted } from \"./types/CustomEvent\";\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: \"hybrid\" | \"default\" | \"off\";\r\n /**\r\n * Persist store. (Default to MemoryStore thats not persis tho.)\r\n */\r\n store: DBIStore;\r\n\r\n references: {\r\n autoClear?: {\r\n check: number;\r\n ttl: number;\r\n }\r\n };\r\n\r\n strict: boolean;\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?: \"hybrid\" | \"default\" | \"off\";\r\n /**\r\n * Persist store. (Default to MemoryStore thats not persis tho.)\r\n */\r\n store?: DBIStore;\r\n\r\n references?: {\r\n autoClear?: {\r\n check: number;\r\n ttl: number;\r\n }\r\n };\r\n\r\n data?: {\r\n other?: Record<string, any>;\r\n refs?: Map<string, { at: number, value: any, ttl?: number }>;\r\n }\r\n\r\n strict?: boolean;\r\n}\r\n\r\nexport interface DBIRegisterAPI<TNamespace extends NamespaceEnums> {\r\n ChatInput(cfg: TDBIChatInputOmitted<TNamespace>): DBIChatInput<TNamespace>;\r\n ChatInputOptions: DBIChatInputOptions<TNamespace>;\r\n Event(cfg: TDBIEventOmitted<TNamespace>): DBIEvent<TNamespace>;\r\n Locale(cfg: TDBILocaleConstructor<TNamespace>): DBILocale<TNamespace>;\r\n Button(cfg: TDBIButtonOmitted<TNamespace>): DBIButton<TNamespace>;\r\n SelectMenu(cfg: TDBISelectMenuOmitted<TNamespace>): DBISelectMenu<TNamespace>;\r\n MessageContextMenu(cfg: TDBIMessageContextMenuOmitted<TNamespace>): DBIMessageContextMenu<TNamespace>;\r\n UserContextMenu(cfg: TDBIUserContextMenuOmitted<TNamespace>): DBIUserContextMenu<TNamespace>;\r\n InteractionLocale(cfg: TDBIInteractionLocaleOmitted): DBIInteractionLocale;\r\n Modal(cfg: TDBIModalOmitted<TNamespace>): DBIModal<TNamespace>;\r\n CustomEvent<T extends keyof NamespaceData[TNamespace][\"customEvents\"]>(cfg: TDBICustomEventOmitted<TNamespace, T>): DBICustomEvent<TNamespace, T>;\r\n onUnload(cb: () => Promise<any> | any): any;\r\n}\r\n\r\nexport class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string, any>> {\r\n namespace: TNamespace;\r\n config: DBIConfig;\r\n client: Discord.Client<true>;\r\n data: {\r\n interactions: Discord.Collection<string, TDBIInteractions<TNamespace>>;\r\n events: Discord.Collection<string, DBIEvent<TNamespace>>;\r\n locales: Discord.Collection<string, DBILocale<TNamespace>>;\r\n interactionLocales: Discord.Collection<string, DBIInteractionLocale>;\r\n other: TOtherData;\r\n eventMap: Record<string, string[] | { [k: string]: string }>;\r\n customEventNames: Set<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, ttl?: number }>;\r\n };\r\n events: Events<TNamespace>;\r\n cluster?: Sharding.Client;\r\n private _loaded: boolean;\r\n private _hooked: boolean;\r\n constructor(namespace: TNamespace, config: DBIConfigConstructor) {\r\n this.namespace = namespace as any;\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 ?? \"off\";\r\n config.strict = config.strict ?? true;\r\n config.references = {\r\n autoClear: undefined,\r\n ...(config.references || {})\r\n }\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 locales: new Discord.Collection(),\r\n interactionLocales: new Discord.Collection(),\r\n other: (config.data?.other as any) ?? ({} as TOtherData),\r\n eventMap,\r\n customEventNames: new Set(),\r\n unloaders: new Set(),\r\n registers: new Set(),\r\n registerUnloaders: new Set(),\r\n refs: config.data?.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 == \"hybrid\" ? {\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 == \"hybrid\" ? 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.references.autoClear != \"undefined\") {\r\n this.data.unloaders.add((() => {\r\n let interval = setInterval(() => {\r\n this.data.refs.forEach(({ at, ttl }, key) => {\r\n if (Date.now() > (at + (ttl || this.config.references.autoClear.ttl))) {\r\n this.data.refs.delete(key);\r\n }\r\n });\r\n }, this.config.references.autoClear.check);\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.customEventNames.forEach((value) => {\r\n delete this.data.eventMap[value];\r\n });\r\n this.data.customEventNames.clear();\r\n }\r\n\r\n private async _registerAll() {\r\n const self = this;\r\n const ChatInputOptions = new DBIChatInputOptions(self);\r\n\r\n for await (const cb of this.data.registers) {\r\n let ChatInput = function (cfg: DBIChatInput<TNamespace>) {\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<TNamespace>) {\r\n let dbiEvent = new DBIEvent(self as any, cfg);\r\n if (self.config.strict && 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<TNamespace>) {\r\n let dbiButton = new DBIButton(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiSelectMenu = new DBISelectMenu(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiMessageContextMenu = new DBIMessageContextMenu(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiUserContextMenu = new DBIUserContextMenu(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiModal = new DBIModal(self as any, cfg);\r\n if (self.config.strict && 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 as any);\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<TNamespace>) {\r\n let dbiLocale = new DBILocale(self as any, cfg);\r\n if (self.config.strict && self.data.interactionLocales.has(dbiLocale.name)) throw new Error(`DBILocale \"${dbiLocale.name}\" already loaded!`);\r\n if (self.data.locales.has(dbiLocale.name)) dbiLocale.mergeLocale(self.data.locales.get(dbiLocale.name));\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 CustomEvent = function (cfg: TDBICustomEventOmitted<TNamespace>) {\r\n let dbiCustomEvent = new DBICustomEvent(self, cfg) as any;\r\n if (self.config.strict && self.data.eventMap[dbiCustomEvent.name]) throw new Error(`DBICustomEvent \"${dbiCustomEvent.name}\" already loaded!`);\r\n self.data.eventMap[dbiCustomEvent.name] = dbiCustomEvent.map;\r\n self.data.customEventNames.add(dbiCustomEvent.name);\r\n return dbiCustomEvent;\r\n };\r\n CustomEvent = Object.assign(CustomEvent, class { constructor(...args: any[]) { return CustomEvent.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.config.strict && 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,\r\n Locale,\r\n Button,\r\n SelectMenu,\r\n MessageContextMenu,\r\n UserContextMenu,\r\n CustomEvent,\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 * this.data.interactions.get(name)\r\n */\r\n interaction<TInteractionName extends keyof NamespaceData[TNamespace][\"interactionMapping\"]>(name: TInteractionName): NamespaceData[TNamespace][\"interactionMapping\"][TInteractionName] {\r\n return this.data.interactions.get(name as any) as any;\r\n }\r\n\r\n emit<TEventName extends keyof (NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)>(name: TEventName, args: (NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[TEventName] ): void {\r\n this.client.emit(name as any, { ...args, _DIRECT_: true } as any);\r\n }\r\n\r\n/**\r\n * \r\n * ((NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[K] as const)\r\n * typeof ((NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[K])[keyof typeof ((NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[K])]\r\n */\r\n\r\n /**\r\n * this.data.events.get(name)\r\n */\r\n event<TEventName extends NamespaceData[TNamespace][\"eventNames\"]>(name: TEventName): DBIEvent<TNamespace> {\r\n return this.data.events.get(name);\r\n }\r\n\r\n /**\r\n * this.data.locales.get(name)\r\n */\r\n locale<TLocaleName extends NamespaceData[TNamespace][\"localeNames\"]>(name: TLocaleName): DBILocale<TNamespace> {\r\n return this.data.locales.get(name) as any;\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.sharding == \"default\" ? undefined : this.config.discord.token);\r\n }\r\n\r\n async register(cb: (api: DBIRegisterAPI<TNamespace>) => 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
|
@@ -2,6 +2,11 @@ import { NamespaceEnums } from "../generated/namespaceData";
|
|
|
2
2
|
import { DBI, DBIConfigConstructor } from "./DBI";
|
|
3
3
|
export { recursiveImport } from "./utils/recursiveImport";
|
|
4
4
|
export { MemoryStore } from "./utils/MemoryStore";
|
|
5
|
+
import { parseCustomId, buildCustomId } from "./utils/customId";
|
|
5
6
|
export declare const generatedPath: string;
|
|
6
7
|
export declare function createDBI<TNamespace extends NamespaceEnums, TOtherType = Record<string, any>>(namespace: TNamespace, cfg: DBIConfigConstructor): DBI<TNamespace, TOtherType>;
|
|
8
|
+
export declare const Utils: {
|
|
9
|
+
parseCustomId: typeof parseCustomId;
|
|
10
|
+
buildCustomId: typeof buildCustomId;
|
|
11
|
+
};
|
|
7
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,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;AAGlD,eAAO,MAAM,aAAa,QAA0C,CAAC;AAErE,wBAAgB,SAAS,CAAC,UAAU,SAAS,cAAc,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,oBAAoB,GAAG,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAE5K"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,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;AAGlD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEhE,eAAO,MAAM,aAAa,QAA0C,CAAC;AAErE,wBAAgB,SAAS,CAAC,UAAU,SAAS,cAAc,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,oBAAoB,GAAG,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAE5K;AAED,eAAO,MAAM,KAAK;;;CAGjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDBI = exports.generatedPath = exports.MemoryStore = exports.recursiveImport = void 0;
|
|
3
|
+
exports.Utils = exports.createDBI = exports.generatedPath = exports.MemoryStore = exports.recursiveImport = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const DBI_1 = require("./DBI");
|
|
6
6
|
var recursiveImport_1 = require("./utils/recursiveImport");
|
|
@@ -8,10 +8,15 @@ Object.defineProperty(exports, "recursiveImport", { enumerable: true, get: funct
|
|
|
8
8
|
var MemoryStore_1 = require("./utils/MemoryStore");
|
|
9
9
|
Object.defineProperty(exports, "MemoryStore", { enumerable: true, get: function () { return MemoryStore_1.MemoryStore; } });
|
|
10
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const customId_1 = require("./utils/customId");
|
|
11
12
|
exports.generatedPath = path_1.default.resolve(__dirname, "../generated");
|
|
12
13
|
function createDBI(namespace, cfg) {
|
|
13
14
|
return new DBI_1.DBI(namespace, cfg);
|
|
14
15
|
}
|
|
15
16
|
exports.createDBI = createDBI;
|
|
16
17
|
;
|
|
18
|
+
exports.Utils = {
|
|
19
|
+
parseCustomId: customId_1.parseCustomId,
|
|
20
|
+
buildCustomId: customId_1.buildCustomId
|
|
21
|
+
};
|
|
17
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,+BAAkD;AAClD,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB,wDAAwB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,+BAAkD;AAClD,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB,wDAAwB;AACxB,+CAAgE;AAEnD,QAAA,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAErE,SAAgB,SAAS,CAAsE,SAAqB,EAAE,GAAyB;IAC7I,OAAO,IAAI,SAAG,CAAyB,SAAS,EAAE,GAAG,CAAC,CAAC;AACzD,CAAC;AAFD,8BAEC;AAAA,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,aAAa,EAAb,wBAAa;IACb,aAAa,EAAb,wBAAa;CACd,CAAA","sourcesContent":["import { NamespaceEnums } from \"../generated/namespaceData\";\r\nimport { DBI, DBIConfigConstructor } from \"./DBI\";\r\nexport { recursiveImport } from \"./utils/recursiveImport\";\r\nexport { MemoryStore } from \"./utils/MemoryStore\";\r\n\r\nimport path from \"path\";\r\nimport { parseCustomId, buildCustomId } from \"./utils/customId\";\r\n\r\nexport const generatedPath = path.resolve(__dirname, \"../generated\");\r\n\r\nexport function createDBI<TNamespace extends NamespaceEnums, TOtherType = Record<string, any>>(namespace: TNamespace, cfg: DBIConfigConstructor): DBI<TNamespace, TOtherType> {\r\n return new DBI<TNamespace, TOtherType>(namespace, cfg);\r\n};\r\n\r\nexport const Utils = {\r\n parseCustomId,\r\n buildCustomId\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;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAK/D,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC,EACtE,mBAAmB,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACrE,WAAW,EAAE,OAAO,GAAG,QAAQ,EAC/B,OAAO,CAAC,EAAE,MAAM,
|
|
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;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAK/D,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC,EACtE,mBAAmB,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACrE,WAAW,EAAE,OAAO,GAAG,QAAQ,EAC/B,OAAO,CAAC,EAAE,MAAM,iBAqKjB;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"}
|
|
@@ -38,7 +38,6 @@ async function publishInteractions(clientToken, interactions, interactionsLocale
|
|
|
38
38
|
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
39
39
|
name: nameSplitted[1],
|
|
40
40
|
description: current.description,
|
|
41
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
42
41
|
dm_permission: current.directMessages,
|
|
43
42
|
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
44
43
|
name_localizations: localeData.nameLocales(1),
|
|
@@ -48,6 +47,7 @@ async function publishInteractions(clientToken, interactions, interactionsLocale
|
|
|
48
47
|
all.push({
|
|
49
48
|
type: v9_1.ApplicationCommandType.ChatInput,
|
|
50
49
|
name: nameSplitted[0],
|
|
50
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
51
51
|
name_localizations: localeData.nameLocales(0),
|
|
52
52
|
description: "...",
|
|
53
53
|
options: [
|
|
@@ -68,6 +68,7 @@ async function publishInteractions(clientToken, interactions, interactionsLocale
|
|
|
68
68
|
type: v9_1.ApplicationCommandType.ChatInput,
|
|
69
69
|
name: nameSplitted[0],
|
|
70
70
|
name_localizations: localeData.nameLocales(0),
|
|
71
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
71
72
|
description: "...",
|
|
72
73
|
options: [
|
|
73
74
|
{
|
|
@@ -80,7 +81,6 @@ async function publishInteractions(clientToken, interactions, interactionsLocale
|
|
|
80
81
|
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
81
82
|
name: nameSplitted[2],
|
|
82
83
|
description: current.description,
|
|
83
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
84
84
|
dm_permission: current.directMessages,
|
|
85
85
|
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
86
86
|
name_localizations: localeData.nameLocales(2),
|
|
@@ -104,7 +104,6 @@ async function publishInteractions(clientToken, interactions, interactionsLocale
|
|
|
104
104
|
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
105
105
|
name: nameSplitted[2],
|
|
106
106
|
description: current.description,
|
|
107
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
108
107
|
dm_permission: current.directMessages,
|
|
109
108
|
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
110
109
|
name_localizations: localeData.nameLocales(2),
|
|
@@ -118,7 +117,6 @@ async function publishInteractions(clientToken, interactions, interactionsLocale
|
|
|
118
117
|
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
119
118
|
name: nameSplitted[2],
|
|
120
119
|
description: current.description,
|
|
121
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
122
120
|
dm_permission: current.directMessages,
|
|
123
121
|
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
124
122
|
name_localizations: localeData.nameLocales(2),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AAMzD,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,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAE5N,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,YAAsE,EACtE,mBAAqE,EACrE,WAA+B,EAC/B,OAAgB;IAEhB,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5E,MAAM,IAAI,GAAG,IAAI,WAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAE3B,MAAM,EAAE,GAAyB,MAAM,IAAI,CAAC,GAA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";\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\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\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<NamespaceEnums>>,\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: \"10\" });\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 \"Guild\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Global\": {\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}"]}
|
|
1
|
+
{"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AAMzD,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,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAE5N,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,YAAsE,EACtE,mBAAqE,EACrE,WAA+B,EAC/B,OAAgB;IAEhB,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAA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kB;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\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\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<NamespaceEnums>>,\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: \"10\" });\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 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 default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\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 default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\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 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 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 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 \"Guild\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Global\": {\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}"]}
|
package/dist/types/Button.js
CHANGED
|
@@ -19,7 +19,7 @@ class DBIButton extends Interaction_1.DBIBaseInteraction {
|
|
|
19
19
|
toJSON(arg = {}) {
|
|
20
20
|
return {
|
|
21
21
|
...stuffs_1.default.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
22
|
-
customId: (0, customId_1.
|
|
22
|
+
customId: (0, customId_1.buildCustomId)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
|
|
23
23
|
type: discord_js_1.default.ComponentType.Button,
|
|
24
24
|
};
|
|
25
25
|
}
|
package/dist/types/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAkD;AAGlD,4DAA4B;AAC5B,mDAAuE;AASvE,MAAa,SAA6C,SAAQ,gCAA8B;IAC9F,YAAY,GAAoB,EAAE,IAAmC;QACnE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAqC,IAA0B,CAAC;IAAA,CAAC;IACpF,MAAM,CAAC,MAA0C,EAAE;QACjD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,wBAAa,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;YACpG,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,MAAM;SAC5B,CAAC;IACX,CAAC;IAAA,CAAC;IACF,aAAa,CAAC,MAA0C,EAAE;QACxD,OAAO,IAAI,gCAAgB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IAC1D,CAAC;CAEF;AAtBD,8BAsBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport { buildCustomId } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBIButtonBuilder, DBIButtonOverrides } from \"./ButtonBuilder\";\r\n\r\nexport interface IDBIButtonExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBIButtonOmitted<TNamespace extends NamespaceEnums> = Omit<DBIButton<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBIButton<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBIButtonOmitted<TNamespace>) {\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<TNamespace>): Promise<void> | void { };\r\n toJSON(arg: IDBIToJSONArgs<DBIButtonOverrides> = {}): Discord.ButtonComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),\r\n type: Discord.ComponentType.Button,\r\n } as any;\r\n };\r\n createBuilder(arg: IDBIToJSONArgs<DBIButtonOverrides> = {}): DBIButtonBuilder<TNamespace> {\r\n return new DBIButtonBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
|
package/dist/types/Modal.js
CHANGED
|
@@ -18,7 +18,7 @@ class DBIModal extends Interaction_1.DBIBaseInteraction {
|
|
|
18
18
|
toJSON(arg = {}) {
|
|
19
19
|
return {
|
|
20
20
|
...stuffs_1.default.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
21
|
-
customId: (0, customId_1.
|
|
21
|
+
customId: (0, customId_1.buildCustomId)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl)
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
;
|
package/dist/types/Modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;;AACA,+CAA2F;AAE3F,
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;;AACA,+CAA2F;AAE3F,gDAAkD;AAGlD,4DAA4B;AAC5B,iDAAoE;AAgBpE,MAAa,QAA4C,SAAQ,gCAA8B;IAC7F,YAAY,GAAoB,EAAE,IAAkC;QAClE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAoC,IAA0B,CAAC;IAAA,CAAC;IAEnF,MAAM,CAAC,MAAyC,EAAE;QAChD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,wBAAa,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;SAC9F,CAAC;IACX,CAAC;IAAA,CAAC;IAEF,aAAa,CAAC,MAAyC,EAAE;QACvD,OAAO,IAAI,8BAAe,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;CAEF;AAvBD,4BAuBC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\nimport { buildCustomId } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBIModalBuilder, DBIModalOverrides } from \"./ModalBuilder\";\r\n\r\n\r\nexport interface IDBIModalExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ModalSubmitInteraction<\"cached\">;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport interface ModalComponentData {\r\n title: string;\r\n components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];\r\n}\r\n\r\nexport type TDBIModalOmitted<TNamespace extends NamespaceEnums> = Omit<DBIModal<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBIModal<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBIModalOmitted<TNamespace>) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Modal\"\r\n });\r\n }\r\n\r\n declare options: ModalComponentData;\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx<TNamespace>): Promise<void> | void { };\r\n\r\n toJSON(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): Discord.ModalComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl)\r\n } as any;\r\n };\r\n\r\n createBuilder(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): DBIModalBuilder<TNamespace> {\r\n return new DBIModalBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
|
package/dist/types/SelectMenu.js
CHANGED
|
@@ -19,7 +19,7 @@ class DBISelectMenu extends Interaction_1.DBIBaseInteraction {
|
|
|
19
19
|
toJSON(arg = {}) {
|
|
20
20
|
return {
|
|
21
21
|
...stuffs_1.default.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
22
|
-
customId: (0, customId_1.
|
|
22
|
+
customId: (0, customId_1.buildCustomId)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
|
|
23
23
|
type: discord_js_1.default.ComponentType.SelectMenu,
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,
|
|
1
|
+
{"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAkD;AAGlD,4DAA4B;AAC5B,2DAAmF;AAUnF,MAAa,aAAiD,SAAQ,gCAA8B;IAClG,YAAY,GAAoB,EAAE,IAAuC;QACvE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAyC,IAA0B,CAAC;IAAA,CAAC;IAExF,MAAM,CAAC,MAA8C,EAAE;QACrD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,wBAAa,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;YACpG,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,UAAU;SAChC,CAAC;IACX,CAAC;IAAA,CAAC;IAEF,aAAa,CAAC,MAA8C,EAAE;QAC5D,OAAO,IAAI,wCAAoB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IAC9D,CAAC;CAEF;AAxBD,sCAwBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport { buildCustomId } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBISelectMenuBuilder, DBISelectMenuOverrides } from \"./SelectMenuBuilder\";\r\n\r\n\r\nexport interface IDBISelectMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBISelectMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBISelectMenu<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBISelectMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBISelectMenuOmitted<TNamespace>) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"SelectMenu\",\r\n });\r\n }\r\n\r\n declare options: Omit<Discord.BaseSelectMenuComponentData, \"customId\" | \"type\">;\r\n\r\n override onExecute(ctx: IDBISelectMenuExecuteCtx<TNamespace>): Promise<void> | void { };\r\n\r\n toJSON(arg: IDBIToJSONArgs<DBISelectMenuOverrides> = {}): Discord.BaseSelectMenuComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),\r\n type: Discord.ComponentType.SelectMenu,\r\n } as any;\r\n };\r\n\r\n createBuilder(arg: IDBIToJSONArgs<DBISelectMenuOverrides> = {}): DBISelectMenuBuilder<TNamespace> {\r\n return new DBISelectMenuBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
|
package/dist/utils/customId.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DBI } from "../DBI";
|
|
2
2
|
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function buildCustomId(dbi: DBI<NamespaceEnums>, name: string, data: any[], ttl?: number): string;
|
|
4
4
|
export declare function parseCustomId(dbi: DBI<NamespaceEnums>, customId: string): {
|
|
5
5
|
name: string;
|
|
6
6
|
data: any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customId.d.ts","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,wBAAgB,
|
|
1
|
+
{"version":3,"file":"customId.d.ts","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,EAAC,MAAM,GAAG,MAAM,CAmBtG;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAA;CAAC,CAarG"}
|
package/dist/utils/customId.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCustomId = exports.
|
|
3
|
+
exports.parseCustomId = exports.buildCustomId = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const stuffs = tslib_1.__importStar(require("stuffs"));
|
|
6
|
-
function
|
|
6
|
+
function buildCustomId(dbi, name, data, ttl) {
|
|
7
7
|
let customId = [
|
|
8
8
|
name,
|
|
9
|
-
...
|
|
9
|
+
...data.map(value => {
|
|
10
10
|
if (typeof value == "string")
|
|
11
11
|
return value;
|
|
12
12
|
if (typeof value == "number")
|
|
13
13
|
return `ฯ${value}`;
|
|
14
|
+
if (typeof value == "boolean")
|
|
15
|
+
return `๐ซ${value ? 1 : 0}`;
|
|
14
16
|
let id = stuffs.randomString(8);
|
|
15
17
|
Object.assign(value, {
|
|
16
18
|
$ref: id,
|
|
@@ -26,13 +28,15 @@ function customIdBuilder(dbi, name, customData, ttl) {
|
|
|
26
28
|
throw new Error("Custom id cannot be longer than 100 characters.");
|
|
27
29
|
return customId;
|
|
28
30
|
}
|
|
29
|
-
exports.
|
|
31
|
+
exports.buildCustomId = buildCustomId;
|
|
30
32
|
function parseCustomId(dbi, customId) {
|
|
31
33
|
let splitted = customId.split("โ");
|
|
32
34
|
let name = splitted.shift();
|
|
33
35
|
let data = splitted.map(value => {
|
|
34
36
|
if (value.startsWith("ฯ"))
|
|
35
37
|
return Number(value.slice(1));
|
|
38
|
+
if (value.startsWith("๐ซ"))
|
|
39
|
+
return !!Number(value.slice(1));
|
|
36
40
|
if (value.startsWith("ยค"))
|
|
37
41
|
return dbi.data.refs.get(value.slice(1))?.value;
|
|
38
42
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customId.js","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AAGjC,SAAgB,
|
|
1
|
+
{"version":3,"file":"customId.js","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AAGjC,SAAgB,aAAa,CAAC,GAAwB,EAAE,IAAY,EAAE,IAAW,EAAE,GAAW;IAC5F,IAAI,QAAQ,GAAG;QACb,IAAI;QACJ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAClB,IAAI,OAAO,KAAK,IAAI,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAC3C,IAAI,OAAO,KAAK,IAAI,QAAQ;gBAAE,OAAO,IAAI,KAA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AAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO;QACL,IAAI;QACJ,IAAI;KACL,CAAA;AACH,CAAC;AAbD,sCAaC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport * as stuffs from \"stuffs\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\n\r\nexport function buildCustomId(dbi: DBI<NamespaceEnums>, name: string, data: any[], ttl?:number): string {\r\n let customId = [\r\n name,\r\n ...data.map(value => {\r\n if (typeof value == \"string\") return value;\r\n if (typeof value == \"number\") return `ฯ${value}`;\r\n if (typeof value == \"boolean\") return `๐ซ${value ? 1 : 0}`;\r\n let id = stuffs.randomString(8);\r\n Object.assign(value, {\r\n $ref: id,\r\n $unRef() { return dbi.data.refs.delete(id); },\r\n })\r\n dbi.data.refs.set(id, { at: Date.now(), value, ttl });\r\n return `ยค${id}`;\r\n })\r\n ].join(\"โ\");\r\n if (!dbi.config.strict) customId = customId.slice(0, 100);\r\n if (customId.length > 100) throw new Error(\"Custom id cannot be longer than 100 characters.\")\r\n return customId;\r\n}\r\n\r\nexport function parseCustomId(dbi: DBI<NamespaceEnums>, customId: string): {name: string, data: any[]} {\r\n let splitted = customId.split(\"โ\");\r\n let name = splitted.shift();\r\n let data = splitted.map(value => {\r\n if (value.startsWith(\"ฯ\")) return Number(value.slice(1));\r\n if (value.startsWith(\"๐ซ\")) return !!Number(value.slice(1));\r\n if (value.startsWith(\"ยค\")) return dbi.data.refs.get(value.slice(1))?.value;\r\n return value;\r\n });\r\n return {\r\n name,\r\n data\r\n }\r\n}"]}
|
package/package.json
CHANGED
package/src/DBI.ts
CHANGED
|
@@ -79,6 +79,11 @@ export interface DBIConfigConstructor {
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
data?: {
|
|
83
|
+
other?: Record<string, any>;
|
|
84
|
+
refs?: Map<string, { at: number, value: any, ttl?: number }>;
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
strict?: boolean;
|
|
83
88
|
}
|
|
84
89
|
|
|
@@ -143,13 +148,13 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
143
148
|
events: new Discord.Collection(),
|
|
144
149
|
locales: new Discord.Collection(),
|
|
145
150
|
interactionLocales: new Discord.Collection(),
|
|
146
|
-
other: {} as TOtherData,
|
|
151
|
+
other: (config.data?.other as any) ?? ({} as TOtherData),
|
|
147
152
|
eventMap,
|
|
148
153
|
customEventNames: new Set(),
|
|
149
154
|
unloaders: new Set(),
|
|
150
155
|
registers: new Set(),
|
|
151
156
|
registerUnloaders: new Set(),
|
|
152
|
-
refs: new Map()
|
|
157
|
+
refs: config.data?.refs ?? new Map()
|
|
153
158
|
}
|
|
154
159
|
|
|
155
160
|
this.events = new Events(this as any);
|
package/src/index.ts
CHANGED
|
@@ -4,8 +4,15 @@ export { recursiveImport } from "./utils/recursiveImport";
|
|
|
4
4
|
export { MemoryStore } from "./utils/MemoryStore";
|
|
5
5
|
|
|
6
6
|
import path from "path";
|
|
7
|
+
import { parseCustomId, buildCustomId } from "./utils/customId";
|
|
8
|
+
|
|
7
9
|
export const generatedPath = path.resolve(__dirname, "../generated");
|
|
8
10
|
|
|
9
11
|
export function createDBI<TNamespace extends NamespaceEnums, TOtherType = Record<string, any>>(namespace: TNamespace, cfg: DBIConfigConstructor): DBI<TNamespace, TOtherType> {
|
|
10
12
|
return new DBI<TNamespace, TOtherType>(namespace, cfg);
|
|
11
|
-
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const Utils = {
|
|
16
|
+
parseCustomId,
|
|
17
|
+
buildCustomId
|
|
18
|
+
}
|
|
@@ -53,7 +53,6 @@ export async function publishInteractions(
|
|
|
53
53
|
type: ApplicationCommandOptionType.Subcommand,
|
|
54
54
|
name: nameSplitted[1],
|
|
55
55
|
description: current.description,
|
|
56
|
-
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
57
56
|
dm_permission: current.directMessages,
|
|
58
57
|
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
59
58
|
name_localizations: localeData.nameLocales(1),
|
|
@@ -63,6 +62,7 @@ export async function publishInteractions(
|
|
|
63
62
|
all.push({
|
|
64
63
|
type: ApplicationCommandType.ChatInput,
|
|
65
64
|
name: nameSplitted[0],
|
|
65
|
+
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
66
66
|
name_localizations: localeData.nameLocales(0),
|
|
67
67
|
description: "...",
|
|
68
68
|
options: [
|
|
@@ -82,6 +82,7 @@ export async function publishInteractions(
|
|
|
82
82
|
type: ApplicationCommandType.ChatInput,
|
|
83
83
|
name: nameSplitted[0],
|
|
84
84
|
name_localizations: localeData.nameLocales(0),
|
|
85
|
+
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
85
86
|
description: "...",
|
|
86
87
|
options: [
|
|
87
88
|
{
|
|
@@ -94,7 +95,6 @@ export async function publishInteractions(
|
|
|
94
95
|
type: ApplicationCommandOptionType.Subcommand,
|
|
95
96
|
name: nameSplitted[2],
|
|
96
97
|
description: current.description,
|
|
97
|
-
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
98
98
|
dm_permission: current.directMessages,
|
|
99
99
|
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
100
100
|
name_localizations: localeData.nameLocales(2),
|
|
@@ -117,7 +117,6 @@ export async function publishInteractions(
|
|
|
117
117
|
type: ApplicationCommandOptionType.Subcommand,
|
|
118
118
|
name: nameSplitted[2],
|
|
119
119
|
description: current.description,
|
|
120
|
-
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
121
120
|
dm_permission: current.directMessages,
|
|
122
121
|
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
123
122
|
name_localizations: localeData.nameLocales(2),
|
|
@@ -130,7 +129,6 @@ export async function publishInteractions(
|
|
|
130
129
|
type: ApplicationCommandOptionType.Subcommand,
|
|
131
130
|
name: nameSplitted[2],
|
|
132
131
|
description: current.description,
|
|
133
|
-
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
134
132
|
dm_permission: current.directMessages,
|
|
135
133
|
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
136
134
|
name_localizations: localeData.nameLocales(2),
|
package/src/types/Button.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Discord from "discord.js";
|
|
2
2
|
import { DBI } from "../DBI";
|
|
3
3
|
import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
|
|
4
|
-
import {
|
|
4
|
+
import { buildCustomId } from "../utils/customId";
|
|
5
5
|
import { IDBIToJSONArgs } from "../utils/UtilTypes";
|
|
6
6
|
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
7
7
|
import stuffs from "stuffs";
|
|
@@ -28,7 +28,7 @@ export class DBIButton<TNamespace extends NamespaceEnums> extends DBIBaseInterac
|
|
|
28
28
|
toJSON(arg: IDBIToJSONArgs<DBIButtonOverrides> = {}): Discord.ButtonComponentData {
|
|
29
29
|
return {
|
|
30
30
|
...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
31
|
-
customId:
|
|
31
|
+
customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
|
|
32
32
|
type: Discord.ComponentType.Button,
|
|
33
33
|
} as any;
|
|
34
34
|
};
|
package/src/types/Modal.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DBI } from "../DBI";
|
|
2
2
|
import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
|
|
3
3
|
import Discord from "discord.js";
|
|
4
|
-
import {
|
|
4
|
+
import { buildCustomId } from "../utils/customId";
|
|
5
5
|
import { IDBIToJSONArgs } from "../utils/UtilTypes";
|
|
6
6
|
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
7
7
|
import stuffs from "stuffs";
|
|
@@ -36,7 +36,7 @@ export class DBIModal<TNamespace extends NamespaceEnums> extends DBIBaseInteract
|
|
|
36
36
|
toJSON(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): Discord.ModalComponentData {
|
|
37
37
|
return {
|
|
38
38
|
...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
39
|
-
customId:
|
|
39
|
+
customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl)
|
|
40
40
|
} as any;
|
|
41
41
|
};
|
|
42
42
|
|
package/src/types/SelectMenu.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Discord from "discord.js";
|
|
2
2
|
import { DBI } from "../DBI";
|
|
3
3
|
import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
|
|
4
|
-
import {
|
|
4
|
+
import { buildCustomId } from "../utils/customId";
|
|
5
5
|
import { IDBIToJSONArgs } from "../utils/UtilTypes";
|
|
6
6
|
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
7
7
|
import stuffs from "stuffs";
|
|
@@ -30,7 +30,7 @@ export class DBISelectMenu<TNamespace extends NamespaceEnums> extends DBIBaseInt
|
|
|
30
30
|
toJSON(arg: IDBIToJSONArgs<DBISelectMenuOverrides> = {}): Discord.BaseSelectMenuComponentData {
|
|
31
31
|
return {
|
|
32
32
|
...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
33
|
-
customId:
|
|
33
|
+
customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
|
|
34
34
|
type: Discord.ComponentType.SelectMenu,
|
|
35
35
|
} as any;
|
|
36
36
|
};
|
package/src/utils/customId.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { DBI } from "../DBI";
|
|
|
2
2
|
import * as stuffs from "stuffs";
|
|
3
3
|
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
4
4
|
|
|
5
|
-
export function
|
|
5
|
+
export function buildCustomId(dbi: DBI<NamespaceEnums>, name: string, data: any[], ttl?:number): string {
|
|
6
6
|
let customId = [
|
|
7
7
|
name,
|
|
8
|
-
...
|
|
8
|
+
...data.map(value => {
|
|
9
9
|
if (typeof value == "string") return value;
|
|
10
10
|
if (typeof value == "number") return `ฯ${value}`;
|
|
11
|
+
if (typeof value == "boolean") return `๐ซ${value ? 1 : 0}`;
|
|
11
12
|
let id = stuffs.randomString(8);
|
|
12
13
|
Object.assign(value, {
|
|
13
14
|
$ref: id,
|
|
@@ -27,6 +28,7 @@ export function parseCustomId(dbi: DBI<NamespaceEnums>, customId: string): {name
|
|
|
27
28
|
let name = splitted.shift();
|
|
28
29
|
let data = splitted.map(value => {
|
|
29
30
|
if (value.startsWith("ฯ")) return Number(value.slice(1));
|
|
31
|
+
if (value.startsWith("๐ซ")) return !!Number(value.slice(1));
|
|
30
32
|
if (value.startsWith("ยค")) return dbi.data.refs.get(value.slice(1))?.value;
|
|
31
33
|
return value;
|
|
32
34
|
});
|