@mostfeatured/dbi 0.1.5 → 0.1.6
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.map +1 -1
- package/dist/DBI.js +5 -3
- package/dist/DBI.js.map +1 -1
- package/dist/methods/publishInteractions.js +9 -9
- package/dist/methods/publishInteractions.js.map +1 -1
- package/dist/types/Interaction.d.ts +8 -3
- package/dist/types/Interaction.d.ts.map +1 -1
- package/dist/types/Interaction.js +8 -1
- package/dist/types/Interaction.js.map +1 -1
- package/package.json +1 -1
- package/src/DBI.ts +40 -51
- package/src/methods/publishInteractions.ts +8 -8
- package/src/types/Interaction.ts +21 -4
- package/tsconfig.json +4 -2
package/dist/DBI.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBI.d.ts","sourceRoot":"","sources":["../src/DBI.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EACL,YAAY,EACZ,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGzE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC5B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,+BAA+B,CAAC;AA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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;CAiC7E"}
|
package/dist/DBI.js
CHANGED
|
@@ -486,9 +486,11 @@ class DBI {
|
|
|
486
486
|
return this._loaded;
|
|
487
487
|
}
|
|
488
488
|
async publish(...args) {
|
|
489
|
-
let interactions = this.data.interactions.filter((i) => i.type
|
|
490
|
-
i.type == "
|
|
491
|
-
i.type == "
|
|
489
|
+
let interactions = this.data.interactions.filter((i) => i.publish.type != "None" &&
|
|
490
|
+
(i.publish.type == args[0] || i.publish.type == "All") &&
|
|
491
|
+
(i.type == "ChatInput" ||
|
|
492
|
+
i.type == "MessageContextMenu" ||
|
|
493
|
+
i.type == "UserContextMenu"));
|
|
492
494
|
switch (args[0]) {
|
|
493
495
|
case "Global": {
|
|
494
496
|
return await (0, publishInteractions_1.publishInteractions)(this.data.clients, args[1] ? new discord_js_1.default.Collection() : interactions, this.data.interactionLocales, args[0]);
|
package/dist/DBI.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBI.js","sourceRoot":"","sources":["../src/DBI.ts"],"names":[],"mappings":";;;;AAAA,oEAAqD;AACrD,2DAGqC;AACrC,yEAAyE;AACzE,uEAAoE;AACpE,yCAAyE;AACzE,qDAAkD;AAClD,iFAA8E;AAC9E,qCAAkC;AAClC,iDAI8B;AAC9B,sDAAyE;AACzE,0EAG6C;AAC7C,yEAG0C;AAC1C,mEAGuC;AACvC,qEAAkE;AAClE,iFAA4C;AAC5C,oDAAsE;AACtE,0EAAoD;AACpD,4DAAuB;AACvB,uEAGyC;AAGzC,2DAGmC;AACnC,8EAAkC;AAClC,sEAG2C;AAC3C,oFAGkD;AAClD,4EAG8C;AAC9C,sEAG2C;AAC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AAO,EACjB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,oBAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,YAAY,EACjD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAC5B,IAAI,CAAC,CAAC,CAAC,CACR,CAAC;aACH;YACD,KAAK,OAAO,CAAC,CAAC;gBACZ,OAAO,MAAM,IAAA,yCAAmB,EAC9B,IAAI,CAAC,IAAI,CAAC,OAAO,EACjB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,oBAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,YAAY,EACjD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAC5B,IAAI,CAAC,CAAC,CAAC,EACP,IAAI,CAAC,CAAC,CAAC,CACR,CAAC;aACH;SACF;IACH,CAAC;CACF;AAtuBD,kBAsuBC","sourcesContent":["import Discord, { MessagePayload } from \"discord.js\";\r\nimport {\r\n DBIChatInput,\r\n TDBIChatInputOmitted,\r\n} 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 {\r\n DBILocale,\r\n TDBILocaleConstructor,\r\n TDBILocaleString,\r\n} from \"./types/other/Locale\";\r\nimport { DBIButton, TDBIButtonOmitted } from \"./types/Components/Button\";\r\nimport {\r\n DBIStringSelectMenu,\r\n TDBIStringSelectMenuOmitted,\r\n} from \"./types/Components/StringSelectMenu\";\r\nimport {\r\n DBIMessageContextMenu,\r\n TDBIMessageContextMenuOmitted,\r\n} from \"./types/other/MessageContextMenu\";\r\nimport {\r\n DBIUserContextMenu,\r\n TDBIUserContextMenuOmitted,\r\n} from \"./types/other/UserContextMenu\";\r\nimport { hookEventListeners } from \"./methods/hookEventListeners\";\r\nimport eventMap from \"./data/eventMap.json\";\r\nimport { DBIModal, TDBIModalOmitted } from \"./types/Components/Modal\";\r\nimport * as Sharding from \"discord-hybrid-sharding\";\r\nimport _ from \"lodash\";\r\nimport {\r\n DBIInteractionLocale,\r\n TDBIInteractionLocaleOmitted,\r\n} from \"./types/other/InteractionLocale\";\r\nimport { TDBIInteractions } from \"./types/Interaction\";\r\nimport { NamespaceData, NamespaceEnums } from \"../generated/namespaceData\";\r\nimport {\r\n DBICustomEvent,\r\n TDBICustomEventOmitted,\r\n} from \"./types/other/CustomEvent\";\r\nimport aaq from \"async-and-quick\";\r\nimport {\r\n DBIUserSelectMenu,\r\n TDBIUserSelectMenuOmitted,\r\n} from \"./types/Components/UserSelectMenu\";\r\nimport {\r\n DBIMentionableSelectMenu,\r\n TDBIMentionableSelectMenuOmitted,\r\n} from \"./types/Components/MentionableSelectMenu\";\r\nimport {\r\n DBIChannelSelectMenu,\r\n TDBIChannelSelectMenuOmitted,\r\n} from \"./types/Components/ChannelSelectMenu\";\r\nimport {\r\n DBIRoleSelectMenu,\r\n TDBIRoleSelectMenuOmitted,\r\n} from \"./types/Components/RoleSelectMenu\";\r\nimport { handleMessageCommands } from \"./methods/handleMessageCommands\";\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 type DBIClientData<TNamespace extends NamespaceEnums> = {\r\n namespace: NamespaceData[TNamespace][\"clientNamespaces\"];\r\n token: string;\r\n options: Discord.ClientOptions;\r\n client: Discord.Client<true>;\r\n};\r\n\r\nexport interface DBIConfig {\r\n discord: {\r\n namespace: string;\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 messageCommands?: {\r\n prefixes: string[];\r\n typeAliases: {\r\n booleans: Record<string, boolean>;\r\n };\r\n };\r\n}\r\n\r\nexport interface DBIConfigConstructor {\r\n discord:\r\n | {\r\n token: string;\r\n options: Discord.ClientOptions;\r\n }\r\n | {\r\n namespace: string;\r\n token: string;\r\n options: Discord.ClientOptions;\r\n }[];\r\n\r\n defaults?: {\r\n locale?: TDBILocaleString;\r\n directMessages?: boolean;\r\n defaultMemberPermissions?: Discord.PermissionsString[];\r\n messageCommands?: {\r\n deferReplyContent?: MessagePayload | string;\r\n };\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 messageCommands?: {\r\n prefixes: string[];\r\n typeAliases?: {\r\n /**\r\n * Example: {\"yes\": true, \"no\": false}\r\n */\r\n booleans?: Record<string, boolean>;\r\n };\r\n };\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 StringSelectMenu(\r\n cfg: TDBIStringSelectMenuOmitted<TNamespace>\r\n ): DBIStringSelectMenu<TNamespace>;\r\n UserSelectMenu(\r\n cfg: TDBIUserSelectMenuOmitted<TNamespace>\r\n ): DBIUserSelectMenu<TNamespace>;\r\n RoleSelectMenu(\r\n cfg: TDBIRoleSelectMenuOmitted<TNamespace>\r\n ): DBIRoleSelectMenu<TNamespace>;\r\n ChannelSelectMenu(\r\n cfg: TDBIChannelSelectMenuOmitted<TNamespace>\r\n ): DBIChannelSelectMenu<TNamespace>;\r\n MentionableSelectMenu(\r\n cfg: TDBIMentionableSelectMenuOmitted<TNamespace>\r\n ): DBIMentionableSelectMenu<TNamespace>;\r\n MessageContextMenu(\r\n cfg: TDBIMessageContextMenuOmitted<TNamespace>\r\n ): DBIMessageContextMenu<TNamespace>;\r\n UserContextMenu(\r\n cfg: TDBIUserContextMenuOmitted<TNamespace>\r\n ): 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\"]>(\r\n cfg: TDBICustomEventOmitted<TNamespace, T>\r\n ): DBICustomEvent<TNamespace, T>;\r\n onUnload(cb: () => Promise<any> | any): any;\r\n}\r\n\r\nexport class DBI<\r\n TNamespace extends NamespaceEnums,\r\n TOtherData = Record<string, any>\r\n> {\r\n namespace: TNamespace;\r\n config: DBIConfig;\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 clients: DBIClientData<TNamespace>[] & {\r\n next(key?: string): DBIClientData<TNamespace>;\r\n random(): DBIClientData<TNamespace>;\r\n random(size: number): DBIClientData<TNamespace>[];\r\n first(): DBIClientData<TNamespace>;\r\n get(\r\n namespace: NamespaceData[TNamespace][\"clientNamespaces\"]\r\n ): DBIClientData<TNamespace>;\r\n indexes: Record<string, number>;\r\n };\r\n };\r\n events: Events<TNamespace>;\r\n cluster?: Sharding.ClusterClient<Discord.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 const self = this;\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 messageCommands: {\r\n deferReplyContent: \"Loading...\",\r\n ...(config.defaults?.messageCommands || {}),\r\n },\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 if (config.messageCommands) {\r\n if (config.strict && !config.messageCommands?.prefixes?.length)\r\n throw new Error(\"No message command prefixes provided.\");\r\n\r\n let { typeAliases } = config.messageCommands;\r\n\r\n config.messageCommands.typeAliases = {\r\n booleans: typeAliases.booleans ?? {\r\n true: true,\r\n false: false,\r\n yes: true,\r\n no: false,\r\n y: true,\r\n n: false,\r\n \"1\": true,\r\n \"0\": false,\r\n },\r\n };\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: { ...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 clients: Object.assign([], {\r\n next(key = \"global\") {\r\n this.indexes[key] = ((this.indexes[key] ?? -1) + 1) % this.length;\r\n return this[this.indexes[key]];\r\n },\r\n random(size?: number) {\r\n if (typeof size === \"number\") {\r\n return this.sort(() => Math.random() - 0.5).slice(0, size);\r\n } else {\r\n return this[Math.floor(Math.random() * this.length)];\r\n }\r\n },\r\n first() {\r\n return this[0];\r\n },\r\n get(namespace: string) {\r\n return this.find((i: any) => i.namespace === namespace);\r\n },\r\n indexes: {},\r\n }) as any,\r\n };\r\n\r\n this.events = new Events(this as any);\r\n\r\n config.discord = Array.isArray(config.discord)\r\n ? config.discord\r\n : [\r\n {\r\n token: config.discord.token,\r\n options: config.discord.options,\r\n namespace: \"default\",\r\n },\r\n ];\r\n\r\n this.data.clients.push(...(config.discord as any));\r\n for (let clientContext of this.data.clients) {\r\n let client = new Discord.Client({\r\n ...((clientContext.options || {}) as any),\r\n ...(config.sharding == \"hybrid\"\r\n ? {\r\n shards: Sharding.getInfo().SHARD_LIST,\r\n shardCount: Sharding.getInfo().TOTAL_SHARDS,\r\n }\r\n : {}),\r\n });\r\n clientContext.client = client as Discord.Client<true>;\r\n }\r\n\r\n if (this.data.clients.length === 0) throw new Error(\"No clients provided.\");\r\n if (\r\n this.data.clients.length !== 1 &&\r\n !(config.sharding && config.sharding === \"off\")\r\n )\r\n throw new Error(\"Sharding only supports 1 client.\");\r\n\r\n this.cluster =\r\n config.sharding == \"hybrid\"\r\n ? new Sharding.ClusterClient(this.data.clients[0].client)\r\n : 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 const self = this;\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 (() => {\r\n let interval = setInterval(() => {\r\n this.data.refs.forEach(({ at, ttl }, key) => {\r\n if (\r\n Date.now() >\r\n at + (ttl || this.config.references.autoClear.ttl)\r\n ) {\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 if (typeof this.config.messageCommands !== \"undefined\") {\r\n this.data.unloaders.add(\r\n (() => {\r\n const { client } = this.client();\r\n\r\n function onMessage(message: Discord.Message) {\r\n handleMessageCommands(self as any, message);\r\n }\r\n\r\n client.on(\"messageCreate\", onMessage);\r\n return () => {\r\n client.off(\"messageCreate\", onMessage);\r\n };\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))\r\n throw new Error(\r\n `DBIChatInput \"${dbiChatInput.name}\" already loaded as \"${\r\n self.data.interactions.get(dbiChatInput.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(dbiChatInput.name, dbiChatInput);\r\n return dbiChatInput;\r\n };\r\n ChatInput = Object.assign(\r\n ChatInput,\r\n class {\r\n constructor(...args: any[]) {\r\n return ChatInput.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let Event = function (cfg: TDBIEventOmitted<TNamespace>) {\r\n let dbiEvent = new DBIEvent(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.events.has(dbiEvent.id || dbiEvent.name)\r\n )\r\n throw new Error(\r\n `DBIEvent \"${dbiEvent.id || dbiEvent.name}\" already loaded!`\r\n );\r\n self.data.events.set(dbiEvent.id || dbiEvent.name, dbiEvent);\r\n return dbiEvent;\r\n };\r\n Event = Object.assign(\r\n Event,\r\n class {\r\n constructor(...args: any[]) {\r\n return Event.apply(this, args as any);\r\n }\r\n }\r\n );\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))\r\n throw new Error(\r\n `DBIButton \"${dbiButton.name}\" already loaded as \"${\r\n self.data.interactions.get(dbiButton.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(dbiButton.name, dbiButton as any);\r\n return dbiButton;\r\n };\r\n Button = Object.assign(\r\n Button,\r\n class {\r\n constructor(...args: any[]) {\r\n return Button.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let StringSelectMenu = function (\r\n cfg: TDBIStringSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiStringSelectMenu = new DBIStringSelectMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiStringSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIStringSelectMenu \"${\r\n dbiStringSelectMenu.name\r\n }\" already loaded as \"${\r\n self.data.interactions.get(dbiStringSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiStringSelectMenu.name,\r\n dbiStringSelectMenu as any\r\n );\r\n return dbiStringSelectMenu;\r\n };\r\n StringSelectMenu = Object.assign(\r\n StringSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return StringSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let UserSelectMenu = function (\r\n cfg: TDBIUserSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiUserSelectMenu = new DBIUserSelectMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiUserSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIUserSelectMenu \"${dbiUserSelectMenu.name}\" already loaded as \"${\r\n self.data.interactions.get(dbiUserSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiUserSelectMenu.name,\r\n dbiUserSelectMenu as any\r\n );\r\n return dbiUserSelectMenu;\r\n };\r\n UserSelectMenu = Object.assign(\r\n UserSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return UserSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let RoleSelectMenu = function (\r\n cfg: TDBIRoleSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiRoleSelectMenu = new DBIRoleSelectMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiRoleSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIRoleSelectMenu \"${dbiRoleSelectMenu.name}\" already loaded as \"${\r\n self.data.interactions.get(dbiRoleSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiRoleSelectMenu.name,\r\n dbiRoleSelectMenu as any\r\n );\r\n return dbiRoleSelectMenu;\r\n };\r\n RoleSelectMenu = Object.assign(\r\n RoleSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return RoleSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let ChannelSelectMenu = function (\r\n cfg: TDBIChannelSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiChannelSelectMenu = new DBIChannelSelectMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiChannelSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIChannelSelectMenu \"${\r\n dbiChannelSelectMenu.name\r\n }\" already loaded as \"${\r\n self.data.interactions.get(dbiChannelSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiChannelSelectMenu.name,\r\n dbiChannelSelectMenu as any\r\n );\r\n return dbiChannelSelectMenu;\r\n };\r\n ChannelSelectMenu = Object.assign(\r\n ChannelSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return ChannelSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let MentionableSelectMenu = function (\r\n cfg: TDBIMentionableSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiMentionableSelectMenu = new DBIMentionableSelectMenu(\r\n self as any,\r\n cfg\r\n );\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiMentionableSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIMentionableSelectMenu \"${\r\n dbiMentionableSelectMenu.name\r\n }\" already loaded as \"${\r\n self.data.interactions.get(dbiMentionableSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiMentionableSelectMenu.name,\r\n dbiMentionableSelectMenu as any\r\n );\r\n return dbiMentionableSelectMenu;\r\n };\r\n MentionableSelectMenu = Object.assign(\r\n MentionableSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return MentionableSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let MessageContextMenu = function (\r\n cfg: TDBIMessageContextMenuOmitted<TNamespace>\r\n ) {\r\n let dbiMessageContextMenu = new DBIMessageContextMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiMessageContextMenu.name)\r\n )\r\n throw new Error(\r\n `DBIMessageContextMenu \"${\r\n dbiMessageContextMenu.name\r\n }\" already loaded as \"${\r\n self.data.interactions.get(dbiMessageContextMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiMessageContextMenu.name,\r\n dbiMessageContextMenu as any\r\n );\r\n return dbiMessageContextMenu;\r\n };\r\n MessageContextMenu = Object.assign(\r\n MessageContextMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return MessageContextMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let UserContextMenu = function (\r\n cfg: TDBIUserContextMenuOmitted<TNamespace>\r\n ) {\r\n let dbiUserContextMenu = new DBIUserContextMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiUserContextMenu.name)\r\n )\r\n throw new Error(\r\n `DBIUserContextMenu \"${\r\n dbiUserContextMenu.name\r\n }\" already loaded as \"${\r\n self.data.interactions.get(dbiUserContextMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiUserContextMenu.name,\r\n dbiUserContextMenu as any\r\n );\r\n return dbiUserContextMenu;\r\n };\r\n UserContextMenu = Object.assign(\r\n UserContextMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return UserContextMenu.apply(this, args as any);\r\n }\r\n }\r\n );\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))\r\n throw new Error(\r\n `DBIModal \"${dbiModal.name}\" already loaded as \"${\r\n self.data.interactions.get(dbiModal.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(dbiModal.name, dbiModal as any);\r\n return dbiModal;\r\n };\r\n Modal = Object.assign(\r\n Modal,\r\n class {\r\n constructor(...args: any[]) {\r\n return Modal.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let Locale = function (cfg: TDBILocaleConstructor<TNamespace>) {\r\n let dbiLocale = new DBILocale(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactionLocales.has(dbiLocale.name)\r\n )\r\n throw new Error(`DBILocale \"${dbiLocale.name}\" already loaded!`);\r\n if (self.data.locales.has(dbiLocale.name))\r\n 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(\r\n Locale,\r\n class {\r\n constructor(...args: any[]) {\r\n return Locale.apply(this, args as any);\r\n }\r\n }\r\n );\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])\r\n throw new Error(\r\n `DBICustomEvent \"${dbiCustomEvent.name}\" already loaded!`\r\n );\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(\r\n CustomEvent,\r\n class {\r\n constructor(...args: any[]) {\r\n return CustomEvent.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let InteractionLocale = function (cfg: TDBIInteractionLocaleOmitted) {\r\n let dbiInteractionLocale = new DBIInteractionLocale(self, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactionLocales.has(dbiInteractionLocale.name)\r\n )\r\n throw new Error(\r\n `DBIInteractionLocale \"${dbiInteractionLocale.name}\" already loaded!`\r\n );\r\n self.data.interactionLocales.set(\r\n dbiInteractionLocale.name,\r\n dbiInteractionLocale\r\n );\r\n return dbiInteractionLocale;\r\n };\r\n InteractionLocale = Object.assign(\r\n InteractionLocale,\r\n class {\r\n constructor(...args: any[]) {\r\n return InteractionLocale.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n await cb({\r\n ChatInput,\r\n Event,\r\n ChatInputOptions,\r\n Locale,\r\n Button,\r\n StringSelectMenu,\r\n UserSelectMenu,\r\n RoleSelectMenu,\r\n ChannelSelectMenu,\r\n MentionableSelectMenu,\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 self.data.interactions.sort((a, b) => b.name.length - a.name.length);\r\n }\r\n\r\n emit<\r\n TEventName extends keyof (NamespaceData[TNamespace][\"customEvents\"] &\r\n ClientEvents)\r\n >(\r\n name: TEventName,\r\n args: (NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[TEventName]\r\n ): void {\r\n this.data.clients.forEach((d) =>\r\n d.client.emit(name as any, { ...args, _DIRECT_: true } as any)\r\n );\r\n }\r\n\r\n /**\r\n * this.data.interactions.get(name)\r\n */\r\n interaction<\r\n TInteractionName extends keyof NamespaceData[TNamespace][\"interactionMapping\"]\r\n >(\r\n name: TInteractionName\r\n ): NamespaceData[TNamespace][\"interactionMapping\"][TInteractionName] {\r\n return this.data.interactions.get(name as any) as any;\r\n }\r\n\r\n client<TClientName extends NamespaceData[TNamespace][\"clientNamespaces\"]>(\r\n name?: TClientName\r\n ): DBIClientData<TNamespace> {\r\n return name ? this.data.clients.get(name) : this.data.clients.first();\r\n }\r\n /**\r\n * this.data.events.get(name)\r\n */\r\n event<TEventName extends NamespaceData[TNamespace][\"eventNames\"]>(\r\n name: TEventName\r\n ): 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\"]>(\r\n name: TLocaleName\r\n ): 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>(\r\n k: K,\r\n defaultValue?: TOtherData[K]\r\n ): 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 aaq.quickForEach(this.data.clients, async (clientContext) => {\r\n await clientContext.client.login(\r\n this.config.sharding == \"default\" ? null : clientContext.token\r\n );\r\n });\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(\r\n (i) =>\r\n i.type == \"ChatInput\" ||\r\n i.type == \"MessageContextMenu\" ||\r\n i.type == \"UserContextMenu\"\r\n ) as any;\r\n switch (args[0]) {\r\n case \"Global\": {\r\n return await publishInteractions(\r\n this.data.clients,\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.data.clients,\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"]}
|
|
1
|
+
{"version":3,"file":"DBI.js","sourceRoot":"","sources":["../src/DBI.ts"],"names":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ted,\r\n} 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 {\r\n DBILocale,\r\n TDBILocaleConstructor,\r\n TDBILocaleString,\r\n} from \"./types/other/Locale\";\r\nimport { DBIButton, TDBIButtonOmitted } from \"./types/Components/Button\";\r\nimport {\r\n DBIStringSelectMenu,\r\n TDBIStringSelectMenuOmitted,\r\n} from \"./types/Components/StringSelectMenu\";\r\nimport {\r\n DBIMessageContextMenu,\r\n TDBIMessageContextMenuOmitted,\r\n} from \"./types/other/MessageContextMenu\";\r\nimport {\r\n DBIUserContextMenu,\r\n TDBIUserContextMenuOmitted,\r\n} from \"./types/other/UserContextMenu\";\r\nimport { hookEventListeners } from \"./methods/hookEventListeners\";\r\nimport eventMap from \"./data/eventMap.json\";\r\nimport { DBIModal, TDBIModalOmitted } from \"./types/Components/Modal\";\r\nimport * as Sharding from \"discord-hybrid-sharding\";\r\nimport _ from \"lodash\";\r\nimport {\r\n DBIInteractionLocale,\r\n TDBIInteractionLocaleOmitted,\r\n} from \"./types/other/InteractionLocale\";\r\nimport { TDBIInteractions } from \"./types/Interaction\";\r\nimport { NamespaceData, NamespaceEnums } from \"../generated/namespaceData\";\r\nimport {\r\n DBICustomEvent,\r\n TDBICustomEventOmitted,\r\n} from \"./types/other/CustomEvent\";\r\nimport aaq from \"async-and-quick\";\r\nimport {\r\n DBIUserSelectMenu,\r\n TDBIUserSelectMenuOmitted,\r\n} from \"./types/Components/UserSelectMenu\";\r\nimport {\r\n DBIMentionableSelectMenu,\r\n TDBIMentionableSelectMenuOmitted,\r\n} from \"./types/Components/MentionableSelectMenu\";\r\nimport {\r\n DBIChannelSelectMenu,\r\n TDBIChannelSelectMenuOmitted,\r\n} from \"./types/Components/ChannelSelectMenu\";\r\nimport {\r\n DBIRoleSelectMenu,\r\n TDBIRoleSelectMenuOmitted,\r\n} from \"./types/Components/RoleSelectMenu\";\r\nimport { handleMessageCommands } from \"./methods/handleMessageCommands\";\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 type DBIClientData<TNamespace extends NamespaceEnums> = {\r\n namespace: NamespaceData[TNamespace][\"clientNamespaces\"];\r\n token: string;\r\n options: Discord.ClientOptions;\r\n client: Discord.Client<true>;\r\n};\r\n\r\nexport interface DBIConfig {\r\n discord: {\r\n namespace: string;\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 messageCommands?: {\r\n prefixes: string[];\r\n typeAliases: {\r\n booleans: Record<string, boolean>;\r\n };\r\n };\r\n}\r\n\r\nexport interface DBIConfigConstructor {\r\n discord:\r\n | {\r\n token: string;\r\n options: Discord.ClientOptions;\r\n }\r\n | {\r\n namespace: string;\r\n token: string;\r\n options: Discord.ClientOptions;\r\n }[];\r\n\r\n defaults?: {\r\n locale?: TDBILocaleString;\r\n directMessages?: boolean;\r\n defaultMemberPermissions?: Discord.PermissionsString[];\r\n messageCommands?: {\r\n deferReplyContent?: MessagePayload | string;\r\n };\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 messageCommands?: {\r\n prefixes: string[];\r\n typeAliases?: {\r\n /**\r\n * Example: {\"yes\": true, \"no\": false}\r\n */\r\n booleans?: Record<string, boolean>;\r\n };\r\n };\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 StringSelectMenu(\r\n cfg: TDBIStringSelectMenuOmitted<TNamespace>\r\n ): DBIStringSelectMenu<TNamespace>;\r\n UserSelectMenu(\r\n cfg: TDBIUserSelectMenuOmitted<TNamespace>\r\n ): DBIUserSelectMenu<TNamespace>;\r\n RoleSelectMenu(\r\n cfg: TDBIRoleSelectMenuOmitted<TNamespace>\r\n ): DBIRoleSelectMenu<TNamespace>;\r\n ChannelSelectMenu(\r\n cfg: TDBIChannelSelectMenuOmitted<TNamespace>\r\n ): DBIChannelSelectMenu<TNamespace>;\r\n MentionableSelectMenu(\r\n cfg: TDBIMentionableSelectMenuOmitted<TNamespace>\r\n ): DBIMentionableSelectMenu<TNamespace>;\r\n MessageContextMenu(\r\n cfg: TDBIMessageContextMenuOmitted<TNamespace>\r\n ): DBIMessageContextMenu<TNamespace>;\r\n UserContextMenu(\r\n cfg: TDBIUserContextMenuOmitted<TNamespace>\r\n ): 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\"]>(\r\n cfg: TDBICustomEventOmitted<TNamespace, T>\r\n ): DBICustomEvent<TNamespace, T>;\r\n onUnload(cb: () => Promise<any> | any): any;\r\n}\r\n\r\nexport class DBI<\r\n TNamespace extends NamespaceEnums,\r\n TOtherData = Record<string, any>\r\n> {\r\n namespace: TNamespace;\r\n config: DBIConfig;\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 clients: DBIClientData<TNamespace>[] & {\r\n next(key?: string): DBIClientData<TNamespace>;\r\n random(): DBIClientData<TNamespace>;\r\n random(size: number): DBIClientData<TNamespace>[];\r\n first(): DBIClientData<TNamespace>;\r\n get(\r\n namespace: NamespaceData[TNamespace][\"clientNamespaces\"]\r\n ): DBIClientData<TNamespace>;\r\n indexes: Record<string, number>;\r\n };\r\n };\r\n events: Events<TNamespace>;\r\n cluster?: Sharding.ClusterClient<Discord.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 const self = this;\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 messageCommands: {\r\n deferReplyContent: \"Loading...\",\r\n ...(config.defaults?.messageCommands || {}),\r\n },\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 if (config.messageCommands) {\r\n if (config.strict && !config.messageCommands?.prefixes?.length)\r\n throw new Error(\"No message command prefixes provided.\");\r\n\r\n let { typeAliases } = config.messageCommands;\r\n\r\n config.messageCommands.typeAliases = {\r\n booleans: typeAliases.booleans ?? {\r\n true: true,\r\n false: false,\r\n yes: true,\r\n no: false,\r\n y: true,\r\n n: false,\r\n \"1\": true,\r\n \"0\": false,\r\n },\r\n };\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: { ...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 clients: Object.assign([], {\r\n next(key = \"global\") {\r\n this.indexes[key] = ((this.indexes[key] ?? -1) + 1) % this.length;\r\n return this[this.indexes[key]];\r\n },\r\n random(size?: number) {\r\n if (typeof size === \"number\") {\r\n return this.sort(() => Math.random() - 0.5).slice(0, size);\r\n } else {\r\n return this[Math.floor(Math.random() * this.length)];\r\n }\r\n },\r\n first() {\r\n return this[0];\r\n },\r\n get(namespace: string) {\r\n return this.find((i: any) => i.namespace === namespace);\r\n },\r\n indexes: {},\r\n }) as any,\r\n };\r\n\r\n this.events = new Events(this as any);\r\n\r\n config.discord = Array.isArray(config.discord)\r\n ? config.discord\r\n : [\r\n {\r\n token: config.discord.token,\r\n options: config.discord.options,\r\n namespace: \"default\",\r\n },\r\n ];\r\n\r\n this.data.clients.push(...(config.discord as any));\r\n for (let clientContext of this.data.clients) {\r\n let client = new Discord.Client({\r\n ...((clientContext.options || {}) as any),\r\n ...(config.sharding == \"hybrid\"\r\n ? {\r\n shards: Sharding.getInfo().SHARD_LIST,\r\n shardCount: Sharding.getInfo().TOTAL_SHARDS,\r\n }\r\n : {}),\r\n });\r\n clientContext.client = client as Discord.Client<true>;\r\n }\r\n\r\n if (this.data.clients.length === 0) throw new Error(\"No clients provided.\");\r\n if (\r\n this.data.clients.length !== 1 &&\r\n !(config.sharding && config.sharding === \"off\")\r\n )\r\n throw new Error(\"Sharding only supports 1 client.\");\r\n\r\n this.cluster =\r\n config.sharding == \"hybrid\"\r\n ? new Sharding.ClusterClient(this.data.clients[0].client)\r\n : 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 const self = this;\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 (() => {\r\n let interval = setInterval(() => {\r\n this.data.refs.forEach(({ at, ttl }, key) => {\r\n if (\r\n Date.now() >\r\n at + (ttl || this.config.references.autoClear.ttl)\r\n ) {\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 if (typeof this.config.messageCommands !== \"undefined\") {\r\n this.data.unloaders.add(\r\n (() => {\r\n const { client } = this.client();\r\n\r\n function onMessage(message: Discord.Message) {\r\n handleMessageCommands(self as any, message);\r\n }\r\n\r\n client.on(\"messageCreate\", onMessage);\r\n return () => {\r\n client.off(\"messageCreate\", onMessage);\r\n };\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))\r\n throw new Error(\r\n `DBIChatInput \"${dbiChatInput.name}\" already loaded as \"${self.data.interactions.get(dbiChatInput.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(dbiChatInput.name, dbiChatInput);\r\n return dbiChatInput;\r\n };\r\n ChatInput = Object.assign(\r\n ChatInput,\r\n class {\r\n constructor(...args: any[]) {\r\n return ChatInput.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let Event = function (cfg: TDBIEventOmitted<TNamespace>) {\r\n let dbiEvent = new DBIEvent(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.events.has(dbiEvent.id || dbiEvent.name)\r\n )\r\n throw new Error(\r\n `DBIEvent \"${dbiEvent.id || dbiEvent.name}\" already loaded!`\r\n );\r\n self.data.events.set(dbiEvent.id || dbiEvent.name, dbiEvent);\r\n return dbiEvent;\r\n };\r\n Event = Object.assign(\r\n Event,\r\n class {\r\n constructor(...args: any[]) {\r\n return Event.apply(this, args as any);\r\n }\r\n }\r\n );\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))\r\n throw new Error(\r\n `DBIButton \"${dbiButton.name}\" already loaded as \"${self.data.interactions.get(dbiButton.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(dbiButton.name, dbiButton as any);\r\n return dbiButton;\r\n };\r\n Button = Object.assign(\r\n Button,\r\n class {\r\n constructor(...args: any[]) {\r\n return Button.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let StringSelectMenu = function (\r\n cfg: TDBIStringSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiStringSelectMenu = new DBIStringSelectMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiStringSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIStringSelectMenu \"${dbiStringSelectMenu.name\r\n }\" already loaded as \"${self.data.interactions.get(dbiStringSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiStringSelectMenu.name,\r\n dbiStringSelectMenu as any\r\n );\r\n return dbiStringSelectMenu;\r\n };\r\n StringSelectMenu = Object.assign(\r\n StringSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return StringSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let UserSelectMenu = function (\r\n cfg: TDBIUserSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiUserSelectMenu = new DBIUserSelectMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiUserSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIUserSelectMenu \"${dbiUserSelectMenu.name}\" already loaded as \"${self.data.interactions.get(dbiUserSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiUserSelectMenu.name,\r\n dbiUserSelectMenu as any\r\n );\r\n return dbiUserSelectMenu;\r\n };\r\n UserSelectMenu = Object.assign(\r\n UserSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return UserSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let RoleSelectMenu = function (\r\n cfg: TDBIRoleSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiRoleSelectMenu = new DBIRoleSelectMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiRoleSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIRoleSelectMenu \"${dbiRoleSelectMenu.name}\" already loaded as \"${self.data.interactions.get(dbiRoleSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiRoleSelectMenu.name,\r\n dbiRoleSelectMenu as any\r\n );\r\n return dbiRoleSelectMenu;\r\n };\r\n RoleSelectMenu = Object.assign(\r\n RoleSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return RoleSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let ChannelSelectMenu = function (\r\n cfg: TDBIChannelSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiChannelSelectMenu = new DBIChannelSelectMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiChannelSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIChannelSelectMenu \"${dbiChannelSelectMenu.name\r\n }\" already loaded as \"${self.data.interactions.get(dbiChannelSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiChannelSelectMenu.name,\r\n dbiChannelSelectMenu as any\r\n );\r\n return dbiChannelSelectMenu;\r\n };\r\n ChannelSelectMenu = Object.assign(\r\n ChannelSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return ChannelSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let MentionableSelectMenu = function (\r\n cfg: TDBIMentionableSelectMenuOmitted<TNamespace>\r\n ) {\r\n let dbiMentionableSelectMenu = new DBIMentionableSelectMenu(\r\n self as any,\r\n cfg\r\n );\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiMentionableSelectMenu.name)\r\n )\r\n throw new Error(\r\n `DBIMentionableSelectMenu \"${dbiMentionableSelectMenu.name\r\n }\" already loaded as \"${self.data.interactions.get(dbiMentionableSelectMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiMentionableSelectMenu.name,\r\n dbiMentionableSelectMenu as any\r\n );\r\n return dbiMentionableSelectMenu;\r\n };\r\n MentionableSelectMenu = Object.assign(\r\n MentionableSelectMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return MentionableSelectMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let MessageContextMenu = function (\r\n cfg: TDBIMessageContextMenuOmitted<TNamespace>\r\n ) {\r\n let dbiMessageContextMenu = new DBIMessageContextMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiMessageContextMenu.name)\r\n )\r\n throw new Error(\r\n `DBIMessageContextMenu \"${dbiMessageContextMenu.name\r\n }\" already loaded as \"${self.data.interactions.get(dbiMessageContextMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiMessageContextMenu.name,\r\n dbiMessageContextMenu as any\r\n );\r\n return dbiMessageContextMenu;\r\n };\r\n MessageContextMenu = Object.assign(\r\n MessageContextMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return MessageContextMenu.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let UserContextMenu = function (\r\n cfg: TDBIUserContextMenuOmitted<TNamespace>\r\n ) {\r\n let dbiUserContextMenu = new DBIUserContextMenu(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactions.has(dbiUserContextMenu.name)\r\n )\r\n throw new Error(\r\n `DBIUserContextMenu \"${dbiUserContextMenu.name\r\n }\" already loaded as \"${self.data.interactions.get(dbiUserContextMenu.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(\r\n dbiUserContextMenu.name,\r\n dbiUserContextMenu as any\r\n );\r\n return dbiUserContextMenu;\r\n };\r\n UserContextMenu = Object.assign(\r\n UserContextMenu,\r\n class {\r\n constructor(...args: any[]) {\r\n return UserContextMenu.apply(this, args as any);\r\n }\r\n }\r\n );\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))\r\n throw new Error(\r\n `DBIModal \"${dbiModal.name}\" already loaded as \"${self.data.interactions.get(dbiModal.name)?.type\r\n }\"!`\r\n );\r\n self.data.interactions.set(dbiModal.name, dbiModal as any);\r\n return dbiModal;\r\n };\r\n Modal = Object.assign(\r\n Modal,\r\n class {\r\n constructor(...args: any[]) {\r\n return Modal.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let Locale = function (cfg: TDBILocaleConstructor<TNamespace>) {\r\n let dbiLocale = new DBILocale(self as any, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactionLocales.has(dbiLocale.name)\r\n )\r\n throw new Error(`DBILocale \"${dbiLocale.name}\" already loaded!`);\r\n if (self.data.locales.has(dbiLocale.name))\r\n 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(\r\n Locale,\r\n class {\r\n constructor(...args: any[]) {\r\n return Locale.apply(this, args as any);\r\n }\r\n }\r\n );\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])\r\n throw new Error(\r\n `DBICustomEvent \"${dbiCustomEvent.name}\" already loaded!`\r\n );\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(\r\n CustomEvent,\r\n class {\r\n constructor(...args: any[]) {\r\n return CustomEvent.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n let InteractionLocale = function (cfg: TDBIInteractionLocaleOmitted) {\r\n let dbiInteractionLocale = new DBIInteractionLocale(self, cfg);\r\n if (\r\n self.config.strict &&\r\n self.data.interactionLocales.has(dbiInteractionLocale.name)\r\n )\r\n throw new Error(\r\n `DBIInteractionLocale \"${dbiInteractionLocale.name}\" already loaded!`\r\n );\r\n self.data.interactionLocales.set(\r\n dbiInteractionLocale.name,\r\n dbiInteractionLocale\r\n );\r\n return dbiInteractionLocale;\r\n };\r\n InteractionLocale = Object.assign(\r\n InteractionLocale,\r\n class {\r\n constructor(...args: any[]) {\r\n return InteractionLocale.apply(this, args as any);\r\n }\r\n }\r\n );\r\n\r\n await cb({\r\n ChatInput,\r\n Event,\r\n ChatInputOptions,\r\n Locale,\r\n Button,\r\n StringSelectMenu,\r\n UserSelectMenu,\r\n RoleSelectMenu,\r\n ChannelSelectMenu,\r\n MentionableSelectMenu,\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 self.data.interactions.sort((a, b) => b.name.length - a.name.length);\r\n }\r\n\r\n emit<\r\n TEventName extends keyof (NamespaceData[TNamespace][\"customEvents\"] &\r\n ClientEvents)\r\n >(\r\n name: TEventName,\r\n args: (NamespaceData[TNamespace][\"customEvents\"] & ClientEvents)[TEventName]\r\n ): void {\r\n this.data.clients.forEach((d) =>\r\n d.client.emit(name as any, { ...args, _DIRECT_: true } as any)\r\n );\r\n }\r\n\r\n /**\r\n * this.data.interactions.get(name)\r\n */\r\n interaction<\r\n TInteractionName extends keyof NamespaceData[TNamespace][\"interactionMapping\"]\r\n >(\r\n name: TInteractionName\r\n ): NamespaceData[TNamespace][\"interactionMapping\"][TInteractionName] {\r\n return this.data.interactions.get(name as any) as any;\r\n }\r\n\r\n client<TClientName extends NamespaceData[TNamespace][\"clientNamespaces\"]>(\r\n name?: TClientName\r\n ): DBIClientData<TNamespace> {\r\n return name ? this.data.clients.get(name) : this.data.clients.first();\r\n }\r\n /**\r\n * this.data.events.get(name)\r\n */\r\n event<TEventName extends NamespaceData[TNamespace][\"eventNames\"]>(\r\n name: TEventName\r\n ): 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\"]>(\r\n name: TLocaleName\r\n ): 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>(\r\n k: K,\r\n defaultValue?: TOtherData[K]\r\n ): 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 aaq.quickForEach(this.data.clients, async (clientContext) => {\r\n await clientContext.client.login(\r\n this.config.sharding == \"default\" ? null : clientContext.token\r\n );\r\n });\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(\r\n (i) =>\r\n i.publish.type != \"None\" &&\r\n (i.publish.type == args[0] || i.publish.type == \"All\") &&\r\n (\r\n i.type == \"ChatInput\" ||\r\n i.type == \"MessageContextMenu\" ||\r\n i.type == \"UserContextMenu\"\r\n )\r\n ) as any;\r\n switch (args[0]) {\r\n case \"Global\": {\r\n return await publishInteractions(\r\n this.data.clients,\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.data.clients,\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"]}
|
|
@@ -10,15 +10,15 @@ async function publishInteractions(clients, interactions, interactionsLocales, p
|
|
|
10
10
|
interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));
|
|
11
11
|
interactions = interactions.sort((a, b) => b.name.split(" ").length - a.name.split(" ").length);
|
|
12
12
|
let body = interactions.reduce((all, current) => {
|
|
13
|
-
if (current.publish && !all[current.publish])
|
|
14
|
-
all[current.publish] = [];
|
|
13
|
+
if (current.publish && !all[current.publish.to])
|
|
14
|
+
all[current.publish.to] = [];
|
|
15
15
|
switch (current.type) {
|
|
16
16
|
case "ChatInput": {
|
|
17
17
|
let nameSplitted = current.name.split(" ");
|
|
18
18
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
19
19
|
switch (nameSplitted.length) {
|
|
20
20
|
case 1: {
|
|
21
|
-
all[current.publish].push({
|
|
21
|
+
all[current.publish.to].push({
|
|
22
22
|
type: v9_1.ApplicationCommandType.ChatInput,
|
|
23
23
|
description: current.description,
|
|
24
24
|
name: nameSplitted[0],
|
|
@@ -31,7 +31,7 @@ async function publishInteractions(clients, interactions, interactionsLocales, p
|
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
case 2: {
|
|
34
|
-
let baseItem = all[current.publish].find(i => i.name == current.name.split(" ")[0] && i.type == v9_1.ApplicationCommandType.ChatInput);
|
|
34
|
+
let baseItem = all[current.publish.to].find(i => i.name == current.name.split(" ")[0] && i.type == v9_1.ApplicationCommandType.ChatInput);
|
|
35
35
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
36
36
|
let option = {
|
|
37
37
|
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
@@ -43,7 +43,7 @@ async function publishInteractions(clients, interactions, interactionsLocales, p
|
|
|
43
43
|
description_localizations: localeData.descriptionLocales,
|
|
44
44
|
};
|
|
45
45
|
if (!baseItem) {
|
|
46
|
-
all[current.publish].push({
|
|
46
|
+
all[current.publish.to].push({
|
|
47
47
|
type: v9_1.ApplicationCommandType.ChatInput,
|
|
48
48
|
name: nameSplitted[0],
|
|
49
49
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
@@ -60,10 +60,10 @@ async function publishInteractions(clients, interactions, interactionsLocales, p
|
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
62
|
case 3: {
|
|
63
|
-
let level1Item = all[current.publish].find(i => i.name == current.name.split(" ")[0] && i.type == v9_1.ApplicationCommandType.ChatInput);
|
|
63
|
+
let level1Item = all[current.publish.to].find(i => i.name == current.name.split(" ")[0] && i.type == v9_1.ApplicationCommandType.ChatInput);
|
|
64
64
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
65
65
|
if (!level1Item) {
|
|
66
|
-
all[current.publish].push({
|
|
66
|
+
all[current.publish.to].push({
|
|
67
67
|
type: v9_1.ApplicationCommandType.ChatInput,
|
|
68
68
|
name: nameSplitted[0],
|
|
69
69
|
name_localizations: localeData.nameLocales(0),
|
|
@@ -130,7 +130,7 @@ async function publishInteractions(clients, interactions, interactionsLocales, p
|
|
|
130
130
|
}
|
|
131
131
|
case "MessageContextMenu": {
|
|
132
132
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
133
|
-
all[current.publish].push({
|
|
133
|
+
all[current.publish.to].push({
|
|
134
134
|
type: v9_1.ApplicationCommandType.Message,
|
|
135
135
|
name: current.name,
|
|
136
136
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
@@ -142,7 +142,7 @@ async function publishInteractions(clients, interactions, interactionsLocales, p
|
|
|
142
142
|
}
|
|
143
143
|
case "UserContextMenu": {
|
|
144
144
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
145
|
-
all[current.publish].push({
|
|
145
|
+
all[current.publish.to].push({
|
|
146
146
|
type: v9_1.ApplicationCommandType.User,
|
|
147
147
|
name: current.name,
|
|
148
148
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AAOzD,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,OA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,YAAY,CAAC,aAAa,GAAG,EAAE,CAAC;gBAEjE,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAAE,EAAE;oBACrF,IAAI,CAAC,YAAY,CAAC,aAAa;wBAAE,YAAY,CAAC,aAAa,GAAG,EAAE,CAAC;oBACjE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC;wBAAE,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC;oBACzG,IAAI,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;oBAElE,YAAY,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;gBACxC,CAAC,CAAC,CAAC;gBAEH,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;gBACvD,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACvE,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW;QACX,cAAc;QACd,kBAAkB;QAClB,cAAc;KACf,CAAA;AACH,CAAC;AAhDD,oCAgDC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput } from \"../types/ChatInput/ChatInput\";\r\nimport { REST } from \"@discordjs/rest\";\r\nimport { Routes, RESTGetAPIUserResult, RESTPutAPIApplicationCommandsJSONBody, ApplicationCommandType, ApplicationCommandOptionType } from \"discord-api-types/v9\";\r\nimport { reducePermissions } from \"../utils/permissions\";\r\nimport snakecaseKeys from \"snakecase-keys\";\r\nimport { DBI, DBIClientData } from \"../DBI\";\r\nimport { DBIInteractionLocale } from \"../types/other/InteractionLocale\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport { ApplicationRoleConnectionMetadataType, ApplicationRoleConnectionMetadata } from \"../types/ApplicationRoleConnectionMetadata\";\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 clients: DBIClientData<NamespaceEnums>[],\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 interactions = interactions.sort((a, b) => b.name.split(\" \").length - a.name.split(\" \").length);\r\n\r\n let body: {[k: string]: RESTPutAPIApplicationCommandsJSONBody} =\r\n interactions.reduce((all, current) => {\r\n if (current.publish && !all[current.publish]) all[current.publish] = [];\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[current.publish].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[current.publish].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[current.publish].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[current.publish].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[current.publish].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[current.publish].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[current.publish].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 }, {} as {[k: string]: any});\r\n \r\n\r\n for (let i = 0; i < clients.length; i++) {\r\n const client = clients[i];\r\n const rest = new REST({ version: \"10\" });\r\n rest.setToken(client.token);\r\n \r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n \r\n switch (publishType) {\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body: body[client.namespace] || [] });\r\n break;\r\n }\r\n case \"Global\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body: body[client.namespace] || [] });\r\n break;\r\n }\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.value ?? 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;AAOzD,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,OAAwC,EACxC,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;IAC5E,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAA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AE,EAAE;oBACrF,IAAI,CAAC,YAAY,CAAC,aAAa;wBAAE,YAAY,CAAC,aAAa,GAAG,EAAE,CAAC;oBACjE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC;wBAAE,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC;oBACzG,IAAI,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;oBAElE,YAAY,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;gBACxC,CAAC,CAAC,CAAC;gBAEH,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;gBACvD,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACvE,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW;QACX,cAAc;QACd,kBAAkB;QAClB,cAAc;KACf,CAAA;AACH,CAAC;AAhDD,oCAgDC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput } from \"../types/ChatInput/ChatInput\";\r\nimport { REST } from \"@discordjs/rest\";\r\nimport { Routes, RESTGetAPIUserResult, RESTPutAPIApplicationCommandsJSONBody, ApplicationCommandType, ApplicationCommandOptionType } from \"discord-api-types/v9\";\r\nimport { reducePermissions } from \"../utils/permissions\";\r\nimport snakecaseKeys from \"snakecase-keys\";\r\nimport { DBI, DBIClientData } from \"../DBI\";\r\nimport { DBIInteractionLocale } from \"../types/other/InteractionLocale\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport { ApplicationRoleConnectionMetadataType, ApplicationRoleConnectionMetadata } from \"../types/ApplicationRoleConnectionMetadata\";\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 clients: DBIClientData<NamespaceEnums>[],\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 interactions = interactions.sort((a, b) => b.name.split(\" \").length - a.name.split(\" \").length);\r\n\r\n let body: {[k: string]: RESTPutAPIApplicationCommandsJSONBody} =\r\n interactions.reduce((all, current) => {\r\n if (current.publish && !all[current.publish.to]) all[current.publish.to] = [];\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[current.publish.to].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[current.publish.to].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[current.publish.to].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[current.publish.to].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[current.publish.to].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[current.publish.to].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[current.publish.to].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 }, {} as {[k: string]: any});\r\n \r\n\r\n for (let i = 0; i < clients.length; i++) {\r\n const client = clients[i];\r\n const rest = new REST({ version: \"10\" });\r\n rest.setToken(client.token);\r\n \r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n \r\n switch (publishType) {\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body: body[client.namespace] || [] });\r\n break;\r\n }\r\n case \"Global\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body: body[client.namespace] || [] });\r\n break;\r\n }\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.value ?? 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}"]}
|
|
@@ -28,16 +28,21 @@ export type TDBIReferencedData = ({
|
|
|
28
28
|
} | string | number);
|
|
29
29
|
export type TDBIInteractionTypes = "ChatInput" | "UserContextMenu" | "MessageContextMenu" | "Modal" | "Autocomplete" | "StringSelectMenu" | "UserSelectMenu" | "ChannelSelectMenu" | "MentionableSelectMenu" | "RoleSelectMenu" | "Button";
|
|
30
30
|
export type TDBIRateLimitTypes = "User" | "Channel" | "Guild" | "Member" | "Message";
|
|
31
|
-
export type
|
|
31
|
+
export type TDBIRateLimit = {
|
|
32
32
|
type: TDBIRateLimitTypes;
|
|
33
33
|
/**
|
|
34
34
|
* Duration in milliseconds.
|
|
35
35
|
*/
|
|
36
36
|
duration: number;
|
|
37
37
|
};
|
|
38
|
+
export type TDBIPublishTypes = "Guild" | "Global" | "None" | "All";
|
|
39
|
+
export type TDBIPublish = {
|
|
40
|
+
type: TDBIPublishTypes;
|
|
41
|
+
to: NamespaceData[NamespaceEnums]["clientNamespaces"];
|
|
42
|
+
};
|
|
38
43
|
export declare class DBIBaseInteraction<TNamespace extends NamespaceEnums> {
|
|
39
44
|
constructor(dbi: DBI<TNamespace>, cfg: Omit<DBIBaseInteraction<TNamespace>, "dbi">);
|
|
40
|
-
publish?:
|
|
45
|
+
publish?: TDBIPublish;
|
|
41
46
|
dbi: DBI<TNamespace>;
|
|
42
47
|
name: string;
|
|
43
48
|
description: string;
|
|
@@ -48,7 +53,7 @@ export declare class DBIBaseInteraction<TNamespace extends NamespaceEnums> {
|
|
|
48
53
|
aliases?: string[];
|
|
49
54
|
};
|
|
50
55
|
};
|
|
51
|
-
rateLimits?:
|
|
56
|
+
rateLimits?: TDBIRateLimit[];
|
|
52
57
|
toJSON(overrides: any): any;
|
|
53
58
|
onExecute(ctx: IDBIBaseExecuteCtx<TNamespace>): Promise<void> | void;
|
|
54
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interaction.d.ts","sourceRoot":"","sources":["../../src/types/Interaction.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,MAAM,gBAAgB,CAAC,UAAU,SAAS,cAAc,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,mBAAmB,CAAC,UAAU,CAAC,GAAG,qBAAqB,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAEjP,MAAM,WAAW,kBAAkB,CAAC,UAAU,SAAS,cAAc;IACnE,WAAW,EACT,OAAO,CAAC,2BAA2B,GACnC,OAAO,CAAC,iCAAiC,GACzC,OAAO,CAAC,oCAAoC,GAC5C,OAAO,CAAC,sBAAsB,GAC9B,OAAO,CAAC,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,SAA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K,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,cAAc,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;IAC1E,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,MAAM,CAAC,SAAS,EAAE,GAAG,GAAG,GAAG;IAE3B,SAAS,CAAC,GAAG,EAAE,kBAAkB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CAGrE"}
|
|
@@ -10,7 +10,14 @@ class DBIBaseInteraction {
|
|
|
10
10
|
this.type = cfg.type;
|
|
11
11
|
this.options = cfg.options;
|
|
12
12
|
this.other = cfg.other;
|
|
13
|
-
this.publish = cfg.publish ??
|
|
13
|
+
this.publish = cfg.publish ?? {
|
|
14
|
+
to: dbi.data.clients.first()?.namespace,
|
|
15
|
+
type: "All"
|
|
16
|
+
};
|
|
17
|
+
if (!this.publish.to)
|
|
18
|
+
this.publish.to = dbi.data.clients.first()?.namespace;
|
|
19
|
+
if (!this.publish.type)
|
|
20
|
+
this.publish.type = "All";
|
|
14
21
|
this.rateLimits = cfg.rateLimits ?? [];
|
|
15
22
|
}
|
|
16
23
|
publish;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interaction.js","sourceRoot":"","sources":["../../src/types/Interaction.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Interaction.js","sourceRoot":"","sources":["../../src/types/Interaction.ts"],"names":[],"mappings":";;;AA4EA,MAAa,kBAAkB;IAC7B,YAAY,GAAoB,EAAE,GAAgD;QAChF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI;YAC5B,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS;YACvC,IAAI,EAAE,KAAK;SACZ,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YAAE,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC;QAC5E,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC;IACzC,CAAC;IAED,OAAO,CAAe;IACtB,GAAG,CAAkB;IACrB,IAAI,CAAS;IACb,WAAW,CAAS;IACX,IAAI,CAAuB;IACpC,OAAO,CAAe;IACtB,KAAK,CAAqE;IAC1E,UAAU,CAAmB;IAC7B,MAAM,CAAC,SAAc,IAAS,CAAC;IAE/B,SAAS,CAAC,GAAmC;IAE7C,CAAC;CACF;AA/BD,gDA+BC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { NamespaceEnums, NamespaceData } from \"../../generated/namespaceData\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIButton } from \"./Components/Button\";\r\nimport { DBIChatInput } from \"./ChatInput/ChatInput\";\r\nimport { DBILocale } from \"./other/Locale\";\r\nimport { DBIMessageContextMenu } from \"./other/MessageContextMenu\";\r\nimport { DBIModal } from \"./Components/Modal\";\r\nimport { DBIStringSelectMenu } from \"./Components/StringSelectMenu\";\r\nimport { DBIUserContextMenu } from \"./other/UserContextMenu\";\r\n\r\nexport type TDBIInteractions<TNamespace extends NamespaceEnums> = DBIChatInput<TNamespace> | DBIButton<TNamespace> | DBIStringSelectMenu<TNamespace> | DBIMessageContextMenu<TNamespace> | DBIUserContextMenu<TNamespace> | DBIModal<TNamespace>;\r\n\r\nexport interface IDBIBaseExecuteCtx<TNamespace extends NamespaceEnums> {\r\n interaction:\r\n | Discord.ChatInputCommandInteraction\r\n | Discord.UserContextMenuCommandInteraction\r\n | Discord.MessageContextMenuCommandInteraction\r\n | Discord.ModalSubmitInteraction\r\n | Discord.AutocompleteInteraction\r\n | Discord.AnySelectMenuInteraction\r\n | Discord.ButtonInteraction;\r\n locale: {\r\n user: DBILocale<TNamespace>,\r\n guild?: DBILocale<TNamespace>\r\n }\r\n dbi: DBI<TNamespace>;\r\n dbiInteraction: TDBIInteractions<TNamespace>;\r\n setRateLimit(type: TDBIRateLimitTypes, duration: number): Promise<any>;\r\n other: Record<string, any>;\r\n clientNamespace: NamespaceData[TNamespace][\"clientNamespaces\"];\r\n}\r\n\r\nexport type TDBIReferencedData = ({ [key: string]: any, $ref: string, $unRef(): boolean } | string | number);\r\n\r\nexport type TDBIInteractionTypes =\r\n | \"ChatInput\"\r\n | \"UserContextMenu\"\r\n | \"MessageContextMenu\"\r\n | \"Modal\"\r\n | \"Autocomplete\"\r\n | \"StringSelectMenu\"\r\n | \"UserSelectMenu\"\r\n | \"ChannelSelectMenu\"\r\n | \"MentionableSelectMenu\"\r\n | \"RoleSelectMenu\"\r\n | \"Button\";\r\n\r\nexport type TDBIRateLimitTypes =\r\n | \"User\"\r\n | \"Channel\"\r\n | \"Guild\"\r\n | \"Member\"\r\n | \"Message\";\r\n\r\n\r\nexport type TDBIRateLimit = {\r\n type: TDBIRateLimitTypes;\r\n /**\r\n * Duration in milliseconds.\r\n */\r\n duration: number;\r\n}\r\n\r\nexport type TDBIPublishTypes =\r\n | \"Guild\"\r\n | \"Global\"\r\n | \"None\"\r\n | \"All\";\r\n\r\n\r\nexport type TDBIPublish = {\r\n type: TDBIPublishTypes;\r\n to: NamespaceData[NamespaceEnums][\"clientNamespaces\"];\r\n}\r\n\r\nexport class DBIBaseInteraction<TNamespace extends NamespaceEnums> {\r\n constructor(dbi: DBI<TNamespace>, cfg: Omit<DBIBaseInteraction<TNamespace>, \"dbi\">) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this.description = cfg.description;\r\n this.onExecute = cfg.onExecute;\r\n this.type = cfg.type;\r\n this.options = cfg.options;\r\n this.other = cfg.other;\r\n this.publish = cfg.publish ?? {\r\n to: dbi.data.clients.first()?.namespace,\r\n type: \"All\"\r\n };\r\n if (!this.publish.to) this.publish.to = dbi.data.clients.first()?.namespace;\r\n if (!this.publish.type) this.publish.type = \"All\";\r\n this.rateLimits = cfg.rateLimits ?? [];\r\n }\r\n\r\n publish?: TDBIPublish;\r\n dbi: DBI<TNamespace>;\r\n name: string;\r\n description: string;\r\n readonly type: TDBIInteractionTypes;\r\n options?: any | any[];\r\n other?: Record<string, any> & { messageCommand?: { aliases?: string[] } };\r\n rateLimits?: TDBIRateLimit[];\r\n toJSON(overrides: any): any { }\r\n\r\n onExecute(ctx: IDBIBaseExecuteCtx<TNamespace>): Promise<void> | void {\r\n\r\n }\r\n}"]}
|
package/package.json
CHANGED
package/src/DBI.ts
CHANGED
|
@@ -111,15 +111,15 @@ export interface DBIConfig {
|
|
|
111
111
|
|
|
112
112
|
export interface DBIConfigConstructor {
|
|
113
113
|
discord:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
| {
|
|
115
|
+
token: string;
|
|
116
|
+
options: Discord.ClientOptions;
|
|
117
|
+
}
|
|
118
|
+
| {
|
|
119
|
+
namespace: string;
|
|
120
|
+
token: string;
|
|
121
|
+
options: Discord.ClientOptions;
|
|
122
|
+
}[];
|
|
123
123
|
|
|
124
124
|
defaults?: {
|
|
125
125
|
locale?: TDBILocaleString;
|
|
@@ -313,12 +313,12 @@ export class DBI<
|
|
|
313
313
|
config.discord = Array.isArray(config.discord)
|
|
314
314
|
? config.discord
|
|
315
315
|
: [
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
316
|
+
{
|
|
317
|
+
token: config.discord.token,
|
|
318
|
+
options: config.discord.options,
|
|
319
|
+
namespace: "default",
|
|
320
|
+
},
|
|
321
|
+
];
|
|
322
322
|
|
|
323
323
|
this.data.clients.push(...(config.discord as any));
|
|
324
324
|
for (let clientContext of this.data.clients) {
|
|
@@ -326,9 +326,9 @@ export class DBI<
|
|
|
326
326
|
...((clientContext.options || {}) as any),
|
|
327
327
|
...(config.sharding == "hybrid"
|
|
328
328
|
? {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
329
|
+
shards: Sharding.getInfo().SHARD_LIST,
|
|
330
|
+
shardCount: Sharding.getInfo().TOTAL_SHARDS,
|
|
331
|
+
}
|
|
332
332
|
: {}),
|
|
333
333
|
});
|
|
334
334
|
clientContext.client = client as Discord.Client<true>;
|
|
@@ -421,8 +421,7 @@ export class DBI<
|
|
|
421
421
|
let dbiChatInput = new DBIChatInput(self, cfg);
|
|
422
422
|
if (self.data.interactions.has(dbiChatInput.name))
|
|
423
423
|
throw new Error(
|
|
424
|
-
`DBIChatInput "${dbiChatInput.name}" already loaded as "${
|
|
425
|
-
self.data.interactions.get(dbiChatInput.name)?.type
|
|
424
|
+
`DBIChatInput "${dbiChatInput.name}" already loaded as "${self.data.interactions.get(dbiChatInput.name)?.type
|
|
426
425
|
}"!`
|
|
427
426
|
);
|
|
428
427
|
self.data.interactions.set(dbiChatInput.name, dbiChatInput);
|
|
@@ -462,8 +461,7 @@ export class DBI<
|
|
|
462
461
|
let dbiButton = new DBIButton(self as any, cfg);
|
|
463
462
|
if (self.config.strict && self.data.interactions.has(dbiButton.name))
|
|
464
463
|
throw new Error(
|
|
465
|
-
`DBIButton "${dbiButton.name}" already loaded as "${
|
|
466
|
-
self.data.interactions.get(dbiButton.name)?.type
|
|
464
|
+
`DBIButton "${dbiButton.name}" already loaded as "${self.data.interactions.get(dbiButton.name)?.type
|
|
467
465
|
}"!`
|
|
468
466
|
);
|
|
469
467
|
self.data.interactions.set(dbiButton.name, dbiButton as any);
|
|
@@ -487,10 +485,8 @@ export class DBI<
|
|
|
487
485
|
self.data.interactions.has(dbiStringSelectMenu.name)
|
|
488
486
|
)
|
|
489
487
|
throw new Error(
|
|
490
|
-
`DBIStringSelectMenu "${
|
|
491
|
-
|
|
492
|
-
}" already loaded as "${
|
|
493
|
-
self.data.interactions.get(dbiStringSelectMenu.name)?.type
|
|
488
|
+
`DBIStringSelectMenu "${dbiStringSelectMenu.name
|
|
489
|
+
}" already loaded as "${self.data.interactions.get(dbiStringSelectMenu.name)?.type
|
|
494
490
|
}"!`
|
|
495
491
|
);
|
|
496
492
|
self.data.interactions.set(
|
|
@@ -517,8 +513,7 @@ export class DBI<
|
|
|
517
513
|
self.data.interactions.has(dbiUserSelectMenu.name)
|
|
518
514
|
)
|
|
519
515
|
throw new Error(
|
|
520
|
-
`DBIUserSelectMenu "${dbiUserSelectMenu.name}" already loaded as "${
|
|
521
|
-
self.data.interactions.get(dbiUserSelectMenu.name)?.type
|
|
516
|
+
`DBIUserSelectMenu "${dbiUserSelectMenu.name}" already loaded as "${self.data.interactions.get(dbiUserSelectMenu.name)?.type
|
|
522
517
|
}"!`
|
|
523
518
|
);
|
|
524
519
|
self.data.interactions.set(
|
|
@@ -545,8 +540,7 @@ export class DBI<
|
|
|
545
540
|
self.data.interactions.has(dbiRoleSelectMenu.name)
|
|
546
541
|
)
|
|
547
542
|
throw new Error(
|
|
548
|
-
`DBIRoleSelectMenu "${dbiRoleSelectMenu.name}" already loaded as "${
|
|
549
|
-
self.data.interactions.get(dbiRoleSelectMenu.name)?.type
|
|
543
|
+
`DBIRoleSelectMenu "${dbiRoleSelectMenu.name}" already loaded as "${self.data.interactions.get(dbiRoleSelectMenu.name)?.type
|
|
550
544
|
}"!`
|
|
551
545
|
);
|
|
552
546
|
self.data.interactions.set(
|
|
@@ -573,10 +567,8 @@ export class DBI<
|
|
|
573
567
|
self.data.interactions.has(dbiChannelSelectMenu.name)
|
|
574
568
|
)
|
|
575
569
|
throw new Error(
|
|
576
|
-
`DBIChannelSelectMenu "${
|
|
577
|
-
|
|
578
|
-
}" already loaded as "${
|
|
579
|
-
self.data.interactions.get(dbiChannelSelectMenu.name)?.type
|
|
570
|
+
`DBIChannelSelectMenu "${dbiChannelSelectMenu.name
|
|
571
|
+
}" already loaded as "${self.data.interactions.get(dbiChannelSelectMenu.name)?.type
|
|
580
572
|
}"!`
|
|
581
573
|
);
|
|
582
574
|
self.data.interactions.set(
|
|
@@ -606,10 +598,8 @@ export class DBI<
|
|
|
606
598
|
self.data.interactions.has(dbiMentionableSelectMenu.name)
|
|
607
599
|
)
|
|
608
600
|
throw new Error(
|
|
609
|
-
`DBIMentionableSelectMenu "${
|
|
610
|
-
|
|
611
|
-
}" already loaded as "${
|
|
612
|
-
self.data.interactions.get(dbiMentionableSelectMenu.name)?.type
|
|
601
|
+
`DBIMentionableSelectMenu "${dbiMentionableSelectMenu.name
|
|
602
|
+
}" already loaded as "${self.data.interactions.get(dbiMentionableSelectMenu.name)?.type
|
|
613
603
|
}"!`
|
|
614
604
|
);
|
|
615
605
|
self.data.interactions.set(
|
|
@@ -636,10 +626,8 @@ export class DBI<
|
|
|
636
626
|
self.data.interactions.has(dbiMessageContextMenu.name)
|
|
637
627
|
)
|
|
638
628
|
throw new Error(
|
|
639
|
-
`DBIMessageContextMenu "${
|
|
640
|
-
|
|
641
|
-
}" already loaded as "${
|
|
642
|
-
self.data.interactions.get(dbiMessageContextMenu.name)?.type
|
|
629
|
+
`DBIMessageContextMenu "${dbiMessageContextMenu.name
|
|
630
|
+
}" already loaded as "${self.data.interactions.get(dbiMessageContextMenu.name)?.type
|
|
643
631
|
}"!`
|
|
644
632
|
);
|
|
645
633
|
self.data.interactions.set(
|
|
@@ -666,10 +654,8 @@ export class DBI<
|
|
|
666
654
|
self.data.interactions.has(dbiUserContextMenu.name)
|
|
667
655
|
)
|
|
668
656
|
throw new Error(
|
|
669
|
-
`DBIUserContextMenu "${
|
|
670
|
-
|
|
671
|
-
}" already loaded as "${
|
|
672
|
-
self.data.interactions.get(dbiUserContextMenu.name)?.type
|
|
657
|
+
`DBIUserContextMenu "${dbiUserContextMenu.name
|
|
658
|
+
}" already loaded as "${self.data.interactions.get(dbiUserContextMenu.name)?.type
|
|
673
659
|
}"!`
|
|
674
660
|
);
|
|
675
661
|
self.data.interactions.set(
|
|
@@ -691,8 +677,7 @@ export class DBI<
|
|
|
691
677
|
let dbiModal = new DBIModal(self as any, cfg);
|
|
692
678
|
if (self.config.strict && self.data.interactions.has(dbiModal.name))
|
|
693
679
|
throw new Error(
|
|
694
|
-
`DBIModal "${dbiModal.name}" already loaded as "${
|
|
695
|
-
self.data.interactions.get(dbiModal.name)?.type
|
|
680
|
+
`DBIModal "${dbiModal.name}" already loaded as "${self.data.interactions.get(dbiModal.name)?.type
|
|
696
681
|
}"!`
|
|
697
682
|
);
|
|
698
683
|
self.data.interactions.set(dbiModal.name, dbiModal as any);
|
|
@@ -914,9 +899,13 @@ export class DBI<
|
|
|
914
899
|
async publish(...args: any[]) {
|
|
915
900
|
let interactions = this.data.interactions.filter(
|
|
916
901
|
(i) =>
|
|
917
|
-
i.type
|
|
918
|
-
i.type == "
|
|
919
|
-
|
|
902
|
+
i.publish.type != "None" &&
|
|
903
|
+
(i.publish.type == args[0] || i.publish.type == "All") &&
|
|
904
|
+
(
|
|
905
|
+
i.type == "ChatInput" ||
|
|
906
|
+
i.type == "MessageContextMenu" ||
|
|
907
|
+
i.type == "UserContextMenu"
|
|
908
|
+
)
|
|
920
909
|
) as any;
|
|
921
910
|
switch (args[0]) {
|
|
922
911
|
case "Global": {
|
|
@@ -24,14 +24,14 @@ export async function publishInteractions(
|
|
|
24
24
|
|
|
25
25
|
let body: {[k: string]: RESTPutAPIApplicationCommandsJSONBody} =
|
|
26
26
|
interactions.reduce((all, current) => {
|
|
27
|
-
if (current.publish && !all[current.publish]) all[current.publish] = [];
|
|
27
|
+
if (current.publish && !all[current.publish.to]) all[current.publish.to] = [];
|
|
28
28
|
switch (current.type) {
|
|
29
29
|
case "ChatInput": {
|
|
30
30
|
let nameSplitted = current.name.split(" ");
|
|
31
31
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
32
32
|
switch (nameSplitted.length) {
|
|
33
33
|
case 1: {
|
|
34
|
-
all[current.publish].push({
|
|
34
|
+
all[current.publish.to].push({
|
|
35
35
|
type: ApplicationCommandType.ChatInput,
|
|
36
36
|
description: current.description,
|
|
37
37
|
name: nameSplitted[0],
|
|
@@ -44,7 +44,7 @@ export async function publishInteractions(
|
|
|
44
44
|
break;
|
|
45
45
|
}
|
|
46
46
|
case 2: {
|
|
47
|
-
let baseItem = all[current.publish].find(i => i.name == current.name.split(" ")[0] && i.type == ApplicationCommandType.ChatInput);
|
|
47
|
+
let baseItem = all[current.publish.to].find(i => i.name == current.name.split(" ")[0] && i.type == ApplicationCommandType.ChatInput);
|
|
48
48
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
49
49
|
let option = {
|
|
50
50
|
type: ApplicationCommandOptionType.Subcommand,
|
|
@@ -56,7 +56,7 @@ export async function publishInteractions(
|
|
|
56
56
|
description_localizations: localeData.descriptionLocales,
|
|
57
57
|
};
|
|
58
58
|
if (!baseItem) {
|
|
59
|
-
all[current.publish].push({
|
|
59
|
+
all[current.publish.to].push({
|
|
60
60
|
type: ApplicationCommandType.ChatInput,
|
|
61
61
|
name: nameSplitted[0],
|
|
62
62
|
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
@@ -72,10 +72,10 @@ export async function publishInteractions(
|
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
74
|
case 3: {
|
|
75
|
-
let level1Item = all[current.publish].find(i => i.name == current.name.split(" ")[0] && i.type == ApplicationCommandType.ChatInput);
|
|
75
|
+
let level1Item = all[current.publish.to].find(i => i.name == current.name.split(" ")[0] && i.type == ApplicationCommandType.ChatInput);
|
|
76
76
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
77
77
|
if (!level1Item) {
|
|
78
|
-
all[current.publish].push({
|
|
78
|
+
all[current.publish.to].push({
|
|
79
79
|
type: ApplicationCommandType.ChatInput,
|
|
80
80
|
name: nameSplitted[0],
|
|
81
81
|
name_localizations: localeData.nameLocales(0),
|
|
@@ -140,7 +140,7 @@ export async function publishInteractions(
|
|
|
140
140
|
}
|
|
141
141
|
case "MessageContextMenu": {
|
|
142
142
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
143
|
-
all[current.publish].push({
|
|
143
|
+
all[current.publish.to].push({
|
|
144
144
|
type: ApplicationCommandType.Message,
|
|
145
145
|
name: current.name,
|
|
146
146
|
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
@@ -152,7 +152,7 @@ export async function publishInteractions(
|
|
|
152
152
|
}
|
|
153
153
|
case "UserContextMenu": {
|
|
154
154
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
155
|
-
all[current.publish].push({
|
|
155
|
+
all[current.publish.to].push({
|
|
156
156
|
type: ApplicationCommandType.User,
|
|
157
157
|
name: current.name,
|
|
158
158
|
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
package/src/types/Interaction.ts
CHANGED
|
@@ -54,7 +54,7 @@ export type TDBIRateLimitTypes =
|
|
|
54
54
|
| "Message";
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
export type
|
|
57
|
+
export type TDBIRateLimit = {
|
|
58
58
|
type: TDBIRateLimitTypes;
|
|
59
59
|
/**
|
|
60
60
|
* Duration in milliseconds.
|
|
@@ -62,6 +62,18 @@ export type DBIRateLimit = {
|
|
|
62
62
|
duration: number;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
export type TDBIPublishTypes =
|
|
66
|
+
| "Guild"
|
|
67
|
+
| "Global"
|
|
68
|
+
| "None"
|
|
69
|
+
| "All";
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
export type TDBIPublish = {
|
|
73
|
+
type: TDBIPublishTypes;
|
|
74
|
+
to: NamespaceData[NamespaceEnums]["clientNamespaces"];
|
|
75
|
+
}
|
|
76
|
+
|
|
65
77
|
export class DBIBaseInteraction<TNamespace extends NamespaceEnums> {
|
|
66
78
|
constructor(dbi: DBI<TNamespace>, cfg: Omit<DBIBaseInteraction<TNamespace>, "dbi">) {
|
|
67
79
|
this.dbi = dbi;
|
|
@@ -71,18 +83,23 @@ export class DBIBaseInteraction<TNamespace extends NamespaceEnums> {
|
|
|
71
83
|
this.type = cfg.type;
|
|
72
84
|
this.options = cfg.options;
|
|
73
85
|
this.other = cfg.other;
|
|
74
|
-
this.publish = cfg.publish ??
|
|
86
|
+
this.publish = cfg.publish ?? {
|
|
87
|
+
to: dbi.data.clients.first()?.namespace,
|
|
88
|
+
type: "All"
|
|
89
|
+
};
|
|
90
|
+
if (!this.publish.to) this.publish.to = dbi.data.clients.first()?.namespace;
|
|
91
|
+
if (!this.publish.type) this.publish.type = "All";
|
|
75
92
|
this.rateLimits = cfg.rateLimits ?? [];
|
|
76
93
|
}
|
|
77
94
|
|
|
78
|
-
publish?:
|
|
95
|
+
publish?: TDBIPublish;
|
|
79
96
|
dbi: DBI<TNamespace>;
|
|
80
97
|
name: string;
|
|
81
98
|
description: string;
|
|
82
99
|
readonly type: TDBIInteractionTypes;
|
|
83
100
|
options?: any | any[];
|
|
84
101
|
other?: Record<string, any> & { messageCommand?: { aliases?: string[] } };
|
|
85
|
-
rateLimits?:
|
|
102
|
+
rateLimits?: TDBIRateLimit[];
|
|
86
103
|
toJSON(overrides: any): any { }
|
|
87
104
|
|
|
88
105
|
onExecute(ctx: IDBIBaseExecuteCtx<TNamespace>): Promise<void> | void {
|