@reciple/modules 10.0.28 → 10.0.30
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecipleInteractionEvents.mjs","names":[],"sources":["../../../src/classes/modules/RecipleInteractionEvents.ts"],"sourcesContent":["import { type Interaction, type CacheType, type Awaitable, Collection } from 'discord.js';\nimport { ClientEventModule, type AnyModule } from 'reciple';\nimport { InteractionListener } from '../InteractionListener.js';\nimport { InteractionListenerType } from '../../helpers/constants.js';\n\nexport class RecipleInteractionEvents extends ClientEventModule<'interactionCreate'> implements RecipleInteractionEvents.Options {\n public readonly id: string = 'org.reciple.js.interaction-events';\n public event = 'interactionCreate' as const;\n public moduleEventListenersProperty: string|string[] = 'interactions';\n public ignoredModules?: (module: AnyModule) => Awaitable<boolean>;\n public listeners: Collection<string, InteractionListener<InteractionListenerType>> = new Collection();\n\n private readonly logger = useLogger().clone({ label: 'InteractionEvents' });\n\n constructor(options: RecipleInteractionEvents.Options = {}) {\n super();\n\n Object.assign(this, options);\n }\n\n public async onReady(): Promise<void> {\n this.client.modules.on('readyModules', async (modules: AnyModule[]) => {\n this.logger.debug(`Resolving listeners for ready modules...`);\n\n for (const listener of await this.resolveListeners(modules)) {\n this.listeners.set(listener.id, listener);\n }\n });\n\n this.client.modules.on('disabledModules', async (modules: AnyModule[]) => {\n this.logger.debug(`Sweeping listeners for disabled modules...`);\n\n for (const module of modules) {\n this.listeners.sweep(listener => listener.moduleId === module.id)\n }\n });\n }\n\n public async onEvent(interaction: Interaction<CacheType>): Promise<void> {\n const type = RecipleInteractionEvents.getInteractionTypeFromInteraction(interaction);\n const listeners = this.listeners.filter(listener => listener.type === type);\n\n this.logger.debug(`Triggered (${listeners.size}) listeners for interaction type \"${InteractionListenerType[type]}\".`);\n\n for (const [id, listener] of listeners) {\n if (!await Promise.resolve(listener.filter(interaction))) continue;\n\n await Promise.resolve(listener.execute(interaction));\n\n if (listener.once) {\n this.logger.debug(`Removed listener \"${id}\" for interaction type \"${InteractionListenerType[type]}\".`);\n this.listeners.delete(id);\n }\n }\n }\n\n public async resolveListeners(customModules?: AnyModule[]) {\n this.logger.debug(`Resolving listeners from (${customModules?.length ?? this.client.modules.cache.size}) modules...`);\n\n const modules = (customModules ?? this.client.modules.cache.map(m => m)) as RecipleInteractionEvents.ListenerModule<string, InteractionListenerType>[];\n const listenersProperty = Array.isArray(this.moduleEventListenersProperty) ? this.moduleEventListenersProperty : [this.moduleEventListenersProperty];\n const listeners: InteractionListener<InteractionListenerType>[] = [];\n\n for (const module of modules) {\n if (module.id === this.id) continue;\n\n this.logger.debug(`Resolving listeners from module \"${module.id}\"...`);\n\n propertyLoop: for (const listenerProperty of listenersProperty) {\n if (!(listenerProperty in module)) continue propertyLoop;\n if (!Array.isArray(module[listenerProperty]) || !module[listenerProperty].length) continue;\n if (typeof this.ignoredModules === 'function' && await Promise.resolve(this.ignoredModules(module))) continue;\n\n const moduleListeners = module[listenerProperty];\n\n this.logger.debug(`Resolving listeners from module \"${module.id}\" with property \"${listenerProperty}\"...`);\n\n for (const data of moduleListeners) {\n const listener = InteractionListener.from(data);\n\n Reflect.set(listener, 'moduleId', module.id);\n listeners.push(listener);\n }\n\n this.logger.debug(`Resolved (${moduleListeners.length}) listeners from module \"${module.id}\" with property \"${listenerProperty}\".`);\n }\n }\n\n return listeners;\n }\n}\n\nexport namespace RecipleInteractionEvents {\n export interface Options {\n /**\n * The property that is scanned from modules to get interaction listeners.\n */\n moduleEventListenersProperty?: string|string[];\n /**\n * Filter modules that should be ignored.\n */\n ignoredModules?: (module: AnyModule) => Awaitable<boolean>;\n }\n\n export type ListenerModule<P extends string, T extends InteractionListenerType> = AnyModule & Record<P, InteractionListener.Resolvable<T>[]>;\n\n export function getInteractionTypeFromInteraction(interaction: Interaction): InteractionListenerType {\n if (interaction.isAutocomplete()) {\n return InteractionListenerType.Autocomplete;\n } else if (interaction.isChatInputCommand()) {\n return InteractionListenerType.ChatInput;\n } else if (interaction.isContextMenuCommand()) {\n return InteractionListenerType.ContextMenu;\n } else if (interaction.isModalSubmit()) {\n return InteractionListenerType.ModalSubmit;\n } else if (interaction.isButton()) {\n return InteractionListenerType.Button;\n } else if (interaction.isAnySelectMenu()) {\n return InteractionListenerType.SelectMenu;\n } else if (interaction.isPrimaryEntryPointCommand()) {\n return InteractionListenerType.PrimaryEntryPoint;\n }\n\n throw new Error(`Unknown interaction type.`);\n }\n}\n"],"mappings":";;;;;;AAKA,IAAa,2BAAb,MAAa,iCAAiC,kBAAmF;CAC7H,AAAgB,KAAa;CAC7B,AAAO,QAAQ;CACf,AAAO,+BAAgD;CACvD,AAAO;CACP,AAAO,YAA8E,IAAI,YAAY;CAErG,AAAiB,SAAS,WAAW,CAAC,MAAM,EAAE,OAAO,qBAAqB,CAAC;CAE3E,YAAY,UAA4C,EAAE,EAAE;AACxD,SAAO;AAEP,SAAO,OAAO,MAAM,QAAQ;;CAGhC,MAAa,UAAyB;AAClC,OAAK,OAAO,QAAQ,GAAG,gBAAgB,OAAO,YAAyB;AACnE,QAAK,OAAO,MAAM,2CAA2C;AAE7D,QAAK,MAAM,YAAY,MAAM,KAAK,iBAAiB,QAAQ,CACvD,MAAK,UAAU,IAAI,SAAS,IAAI,SAAS;IAE/C;AAEF,OAAK,OAAO,QAAQ,GAAG,mBAAmB,OAAO,YAAyB;AACtE,QAAK,OAAO,MAAM,6CAA6C;AAE/D,QAAK,MAAM,UAAU,QACjB,MAAK,UAAU,OAAM,aAAY,SAAS,aAAa,OAAO,GAAG;IAEvE;;CAGN,MAAa,QAAQ,aAAoD;EACrE,MAAM,OAAO,yBAAyB,kCAAkC,YAAY;EACpF,MAAM,YAAY,KAAK,UAAU,QAAO,aAAY,SAAS,SAAS,KAAK;AAE3E,OAAK,OAAO,MAAM,cAAc,UAAU,KAAK,oCAAoC,wBAAwB,MAAM,IAAI;AAErH,OAAK,MAAM,CAAC,IAAI,aAAa,WAA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iBAAiB,IAAI;;;AAI3I,SAAO
|
|
1
|
+
{"version":3,"file":"RecipleInteractionEvents.mjs","names":[],"sources":["../../../src/classes/modules/RecipleInteractionEvents.ts"],"sourcesContent":["import { type Interaction, type CacheType, type Awaitable, Collection } from 'discord.js';\nimport { ClientEventModule, type AnyModule } from 'reciple';\nimport { InteractionListener } from '../InteractionListener.js';\nimport { InteractionListenerType } from '../../helpers/constants.js';\n\nexport class RecipleInteractionEvents extends ClientEventModule<'interactionCreate'> implements RecipleInteractionEvents.Options {\n public readonly id: string = 'org.reciple.js.interaction-events';\n public event = 'interactionCreate' as const;\n public moduleEventListenersProperty: string|string[] = 'interactions';\n public ignoredModules?: (module: AnyModule) => Awaitable<boolean>;\n public listeners: Collection<string, InteractionListener<InteractionListenerType>> = new Collection();\n\n private readonly logger = useLogger().clone({ label: 'InteractionEvents' });\n\n constructor(options: RecipleInteractionEvents.Options = {}) {\n super();\n\n Object.assign(this, options);\n }\n\n public async onReady(): Promise<void> {\n this.client.modules.on('readyModules', async (modules: AnyModule[]) => {\n this.logger.debug(`Resolving listeners for ready modules...`);\n\n for (const listener of await this.resolveListeners(modules)) {\n this.listeners.set(listener.id, listener);\n }\n });\n\n this.client.modules.on('disabledModules', async (modules: AnyModule[]) => {\n this.logger.debug(`Sweeping listeners for disabled modules...`);\n\n for (const module of modules) {\n this.listeners.sweep(listener => listener.moduleId === module.id)\n }\n });\n }\n\n public async onEvent(interaction: Interaction<CacheType>): Promise<void> {\n const type = RecipleInteractionEvents.getInteractionTypeFromInteraction(interaction);\n const listeners = this.listeners.filter(listener => listener.type === type);\n\n this.logger.debug(`Triggered (${listeners.size}) listeners for interaction type \"${InteractionListenerType[type]}\".`);\n\n for (const [id, listener] of listeners) {\n if (!await Promise.resolve(listener.filter(interaction))) continue;\n\n await Promise.resolve(listener.execute(interaction));\n\n if (listener.once) {\n this.logger.debug(`Removed listener \"${id}\" for interaction type \"${InteractionListenerType[type]}\".`);\n this.listeners.delete(id);\n }\n }\n }\n\n public async resolveListeners(customModules?: AnyModule[]) {\n this.logger.debug(`Resolving listeners from (${customModules?.length ?? this.client.modules.cache.size}) modules...`);\n\n const modules = (customModules ?? this.client.modules.cache.map(m => m)) as RecipleInteractionEvents.ListenerModule<string, InteractionListenerType>[];\n const listenersProperty = Array.isArray(this.moduleEventListenersProperty) ? this.moduleEventListenersProperty : [this.moduleEventListenersProperty];\n const listeners: InteractionListener<InteractionListenerType>[] = [];\n\n for (const module of modules) {\n if (module.id === this.id) continue;\n\n this.logger.debug(`Resolving listeners from module \"${module.id}\"...`);\n\n propertyLoop: for (const listenerProperty of listenersProperty) {\n if (!(listenerProperty in module)) continue propertyLoop;\n if (!Array.isArray(module[listenerProperty]) || !module[listenerProperty].length) continue;\n if (typeof this.ignoredModules === 'function' && await Promise.resolve(this.ignoredModules(module))) continue;\n\n const moduleListeners = module[listenerProperty];\n\n this.logger.debug(`Resolving listeners from module \"${module.id}\" with property \"${listenerProperty}\"...`);\n\n for (const data of moduleListeners) {\n const listener = InteractionListener.from(data);\n\n Reflect.set(listener, 'moduleId', module.id);\n listeners.push(listener);\n }\n\n this.logger.debug(`Resolved (${moduleListeners.length}) listeners from module \"${module.id}\" with property \"${listenerProperty}\".`);\n }\n }\n\n return listeners;\n }\n}\n\nexport namespace RecipleInteractionEvents {\n export interface Options {\n /**\n * The property that is scanned from modules to get interaction listeners.\n */\n moduleEventListenersProperty?: string|string[];\n /**\n * Filter modules that should be ignored.\n */\n ignoredModules?: (module: AnyModule) => Awaitable<boolean>;\n }\n\n export type ListenerModule<P extends string, T extends InteractionListenerType> = AnyModule & Record<P, InteractionListener.Resolvable<T>[]>;\n\n export function getInteractionTypeFromInteraction(interaction: Interaction): InteractionListenerType {\n if (interaction.isAutocomplete()) {\n return InteractionListenerType.Autocomplete;\n } else if (interaction.isChatInputCommand()) {\n return InteractionListenerType.ChatInput;\n } else if (interaction.isContextMenuCommand()) {\n return InteractionListenerType.ContextMenu;\n } else if (interaction.isModalSubmit()) {\n return InteractionListenerType.ModalSubmit;\n } else if (interaction.isButton()) {\n return InteractionListenerType.Button;\n } else if (interaction.isAnySelectMenu()) {\n return InteractionListenerType.SelectMenu;\n } else if (interaction.isPrimaryEntryPointCommand()) {\n return InteractionListenerType.PrimaryEntryPoint;\n }\n\n throw new Error(`Unknown interaction type.`);\n }\n}\n"],"mappings":";;;;;;AAKA,IAAa,2BAAb,MAAa,iCAAiC,kBAAmF;CAC7H,AAAgB,KAAa;CAC7B,AAAO,QAAQ;CACf,AAAO,+BAAgD;CACvD,AAAO;CACP,AAAO,YAA8E,IAAI,YAAY;CAErG,AAAiB,SAAS,WAAW,CAAC,MAAM,EAAE,OAAO,qBAAqB,CAAC;CAE3E,YAAY,UAA4C,EAAE,EAAE;AACxD,SAAO;AAEP,SAAO,OAAO,MAAM,QAAQ;;CAGhC,MAAa,UAAyB;AAClC,OAAK,OAAO,QAAQ,GAAG,gBAAgB,OAAO,YAAyB;AACnE,QAAK,OAAO,MAAM,2CAA2C;AAE7D,QAAK,MAAM,YAAY,MAAM,KAAK,iBAAiB,QAAQ,CACvD,MAAK,UAAU,IAAI,SAAS,IAAI,SAAS;IAE/C;AAEF,OAAK,OAAO,QAAQ,GAAG,mBAAmB,OAAO,YAAyB;AACtE,QAAK,OAAO,MAAM,6CAA6C;AAE/D,QAAK,MAAM,UAAU,QACjB,MAAK,UAAU,OAAM,aAAY,SAAS,aAAa,OAAO,GAAG;IAEvE;;CAGN,MAAa,QAAQ,aAAoD;EACrE,MAAM,OAAO,yBAAyB,kCAAkC,YAAY;EACpF,MAAM,YAAY,KAAK,UAAU,QAAO,aAAY,SAAS,SAAS,KAAK;AAE3E,OAAK,OAAO,MAAM,cAAc,UAAU,KAAK,oCAAoC,wBAAwB,MAAM,IAAI;AAErH,OAAK,MAAM,CAAC,IAAI,aAAa,WAAW;AACpC,OAAI,CAAC,MAAM,QAAQ,QAAQ,SAAS,OAAO,YAAY,CAAC,CAAE;AAE1D,SAAM,QAAQ,QAAQ,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,QAAO,wBAAwB;WACxB,YAAY,oBAAoB,CACvC,QAAO,wBAAwB;WACxB,YAAY,sBAAsB,CACzC,QAAO,wBAAwB;WACxB,YAAY,eAAe,CAClC,QAAO,wBAAwB;WACxB,YAAY,UAAU,CAC7B,QAAO,wBAAwB;WACxB,YAAY,iBAAiB,CACpC,QAAO,wBAAwB;WACxB,YAAY,4BAA4B,CAC/C,QAAO,wBAAwB;AAGnC,QAAM,IAAI,MAAM,4BAA4B;;;+DAEnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecipleRegistryCache.mjs","names":[],"sources":["../../../src/classes/modules/RecipleRegistryCache.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { BaseModule, CommandType, type AnyCommandData, type Config, type MessageCommand } from 'reciple';\n\nexport class RecipleRegistryCache extends BaseModule implements RecipleRegistryCache.Options {\n public readonly id: string = 'org.reciple.js.registry-cache';\n\n public createCacheEntryEvenIfDisabled: boolean = true;\n public cacheDir: string = path.join(process.cwd(), '.cache/reciple-registry/');\n public maxCacheAgeMs?: number;\n public cacheEnabledEnv: string = 'RECIPLE_REGISTRY_CACHE';\n public cached: boolean = false;\n\n private readonly logger = useLogger().clone({ label: 'RegistryCache' });\n\n constructor(options?: RecipleRegistryCache.Options) {\n super();\n Object.assign(this, options ?? {});\n }\n\n get cachePath(): string {\n return path.join(this.cacheDir, this.client.application?.id ?? 'cache.json');\n }\n\n public async onReady(): Promise<void> {\n const enabled = this.isEnabled();\n\n if (enabled || this.createCacheEntryEvenIfDisabled) {\n this.client.commands?.once('applicationCommandsRegister', async (commands, guildId) => {\n await this.writeCacheEntry();\n });\n }\n\n if (!enabled) {\n this.client.modules.on('readyModules', async () => {\n this.logger.warn(`Registry cache is disabled. Cache is not used.`);\n });\n\n return;\n }\n\n this.logger.debug('Looking for a application commands cache entry...');\n const cachedEntry = await this.readCacheEntry();\n\n this.logger.debug('Creating current application commands cache entry...');\n const currentEntry = await this.createCacheEntry();\n\n if (cachedEntry && this.isCacheHit(cachedEntry, currentEntry)) {\n this.client.config!.applicationCommandsRegister = {\n ...this.client.config!.applicationCommandsRegister,\n registerGlobally: false,\n registerToGuilds: false\n }\n\n this.cached = true;\n }\n\n this.client.modules.on('readyModules', async () => {\n this.logger.warn(`Application commands are ${this.cached ? '' : 'not '}cached. ${this.cached ? 'Skipping' : 'Proceeding with'} registration.`);\n });\n }\n\n public async readCacheEntry(): Promise<RecipleRegistryCache.CacheEntry|null> {\n const stats = await stat(this.cachePath).catch(() => null);\n if (!stats) return null;\n\n return await readFile(this.cachePath, 'utf-8').then(JSON.parse).catch(() => null);\n }\n\n public async writeCacheEntry(entry?: RecipleRegistryCache.CacheEntry): Promise<void> {\n entry ??= await this.createCacheEntry();\n\n this.logger.debug('Writing application commands cache entry...');\n await mkdir(this.cacheDir, { recursive: true });\n await writeFile(this.cachePath, JSON.stringify(entry, null, 4), 'utf-8');\n\n this.logger.debug(`Application commands cache entry written to \"${this.cachePath}\".`);\n }\n\n public async clearCacheEntry(): Promise<void> {\n await rm(this.cachePath).catch(() => null);\n }\n\n public async createCacheEntry(): Promise<RecipleRegistryCache.CacheEntry> {\n this.logger.debug('Creating current application commands cache entry...');\n const commands = Array.from(this.client.commands?.cache.filter(cmd => cmd.type !== CommandType.Message).map(cmd => cmd.toJSON()).values() ?? []);\n\n for (const command of commands) {\n Object.assign(command, { id: \"[cache_value]\" });\n }\n\n const commandsHash = RecipleRegistryCache.createCommandsHash(commands);\n const configHash = RecipleRegistryCache.createConfigHash(this.client.config?.applicationCommandsRegister ?? {});\n\n this.logger.debug(`Commands hash: ${commandsHash}`);\n this.logger.debug(`Config hash: ${configHash}`);\n this.logger.debug('Current application commands cache entry created.');\n\n return {\n createdAt: Date.now(),\n commandsHash,\n configHash\n };\n }\n\n public isCacheHit(cached: RecipleRegistryCache.CacheEntry, current: RecipleRegistryCache.CacheEntry): boolean {\n this.logger.debug('Comparing cache entry with current application commands and configuration...');\n if (this.maxCacheAgeMs) {\n const age = Date.now() - cached.createdAt;\n if (age > this.maxCacheAgeMs) {\n this.logger.debug(`Cache entry is too old (age: ${age}ms, max age: ${this.maxCacheAgeMs}ms).`);\n return false;\n }\n }\n\n if (cached.commandsHash !== current.commandsHash) {\n this.logger.debug(`Cache entry commands hash doesn't match (cached: ${cached.commandsHash}, current: ${current.commandsHash}).`);\n return false;\n }\n if (cached.configHash !== current.configHash) {\n this.logger.debug(`Cache entry config hash doesn't match (cached: ${cached.configHash}, current: ${current.configHash}).`);\n return false;\n }\n\n this.logger.debug('Cache entry matches current application commands and configuration.');\n return true;\n }\n\n private isEnabled(): boolean {\n if (process.env[this.cacheEnabledEnv] !== 'false' && process.env[this.cacheEnabledEnv] !== '0') {\n return RecipleRegistryCache.checkClientIfEnabled(this.client.config ?? {});\n }\n\n return false;\n }\n}\n\nexport namespace RecipleRegistryCache {\n export interface Options {\n /**\n * @default true\n */\n createCacheEntryEvenIfDisabled?: boolean;\n /**\n * @default '.cache/reciple-registry/'\n */\n cacheDir?: string;\n /**\n * @default 86400000 // 24 hours in milliseconds\n */\n maxCacheAgeMs?: number;\n /**\n * @default 'RECIPLE_REGISTRY_CACHE'\n */\n cacheEnabledEnv?: string;\n }\n\n export interface CacheEntry {\n commandsHash: string;\n configHash: string;\n createdAt: number;\n }\n\n export type CommandData = Exclude<AnyCommandData, MessageCommand.Data>;\n\n export function checkClientIfEnabled(config: Config): boolean {\n return config.applicationCommandsRegister?.registerGlobally\n || config.applicationCommandsRegister?.registerToGuilds === true\n || (\n Array.isArray(config.applicationCommandsRegister?.registerToGuilds)\n && config.applicationCommandsRegister?.registerToGuilds.length > 0\n );\n }\n\n export function createCommandsHash(commands: Exclude<AnyCommandData, MessageCommand.Data>[]): string {\n const hash = createHash('sha256');\n\n hash.update(stringifyValue(commands));\n\n return hash.digest('hex');\n }\n\n export function createConfigHash(config: Config): string {\n const hash = createHash('sha256');\n const relevantConfig = { applicationCommandsRegister: config.applicationCommandsRegister };\n\n hash.update(stringifyValue(relevantConfig));\n\n return hash.digest('hex');\n }\n\n export function stringifyValue(object: any): string {\n switch (typeof object) {\n case 'string':\n return `\"${object}\"`;\n case 'number':\n case 'bigint':\n case 'boolean':\n case 'symbol':\n case 'function':\n return `\"${object.toString()}\"`;\n case 'undefined':\n return 'undefined';\n case 'object':\n if (object === null) {\n return 'null';\n }\n\n if (Array.isArray(object)) {\n return `[${object.map(s => stringifyValue(s)).join(', ')}]`;\n }\n\n if (object instanceof Map) {\n return `{${Array.from(object.entries()).map(([k, v]) => `${stringifyValue(k)}: ${stringifyValue(v)}`).join(', ')}}`;\n }\n\n if (object instanceof Set) {\n return `{${Array.from(object.values()).map(v => stringifyValue(v)).join(', ')}}`;\n }\n\n if (object instanceof Date) {\n return `\"${object.toISOString()}\"`;\n }\n\n try {\n const newObject: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(object)) {\n newObject[key] = stringifyValue(value);\n }\n\n return JSON.stringify(newObject);\n } catch {\n return String(object);\n }\n }\n }\n}\n"],"mappings":";;;;;;AAKA,IAAa,uBAAb,MAAa,6BAA6B,WAAmD;CACzF,AAAgB,KAAa;CAE7B,AAAO,iCAA0C;CACjD,AAAO,WAAmB,KAAK,KAAK,QAAQ,KAAK,EAAE,2BAA2B;CAC9E,AAAO;CACP,AAAO,kBAA0B;CACjC,AAAO,SAAkB;CAEzB,AAAiB,SAAS,WAAW,CAAC,MAAM,EAAE,OAAO,iBAAiB,CAAC;CAEvE,YAAY,SAAwC;AAChD,SAAO;AACP,SAAO,OAAO,MAAM,WAAW,EAAE,CAAC;;CAGtC,IAAI,YAAoB;AACpB,SAAO,KAAK,KAAK,KAAK,UAAU,KAAK,OAAO,aAAa,MAAM,aAAa;;CAGhF,MAAa,UAAyB;EAClC,MAAM,UAAU,KAAK,WAAW;AAEhC,MAAI,WAAW,KAAK,+BAChB,MAAK,OAAO,UAAU,KAAK,+BAA+B,OAAO,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QAAQ,OAAO,CAC7C,WAAU,OAAO,eAAe,MAAM;AAG1C,YAAO,KAAK,UAAU,UAAU;YAC5B;AACJ,YAAO,OAAO,OAAO"}
|
|
1
|
+
{"version":3,"file":"RecipleRegistryCache.mjs","names":[],"sources":["../../../src/classes/modules/RecipleRegistryCache.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { BaseModule, CommandType, type AnyCommandData, type Config, type MessageCommand } from 'reciple';\n\nexport class RecipleRegistryCache extends BaseModule implements RecipleRegistryCache.Options {\n public readonly id: string = 'org.reciple.js.registry-cache';\n\n public createCacheEntryEvenIfDisabled: boolean = true;\n public cacheDir: string = path.join(process.cwd(), '.cache/reciple-registry/');\n public maxCacheAgeMs?: number;\n public cacheEnabledEnv: string = 'RECIPLE_REGISTRY_CACHE';\n public cached: boolean = false;\n\n private readonly logger = useLogger().clone({ label: 'RegistryCache' });\n\n constructor(options?: RecipleRegistryCache.Options) {\n super();\n Object.assign(this, options ?? {});\n }\n\n get cachePath(): string {\n return path.join(this.cacheDir, this.client.application?.id ?? 'cache.json');\n }\n\n public async onReady(): Promise<void> {\n const enabled = this.isEnabled();\n\n if (enabled || this.createCacheEntryEvenIfDisabled) {\n this.client.commands?.once('applicationCommandsRegister', async (commands, guildId) => {\n await this.writeCacheEntry();\n });\n }\n\n if (!enabled) {\n this.client.modules.on('readyModules', async () => {\n this.logger.warn(`Registry cache is disabled. Cache is not used.`);\n });\n\n return;\n }\n\n this.logger.debug('Looking for a application commands cache entry...');\n const cachedEntry = await this.readCacheEntry();\n\n this.logger.debug('Creating current application commands cache entry...');\n const currentEntry = await this.createCacheEntry();\n\n if (cachedEntry && this.isCacheHit(cachedEntry, currentEntry)) {\n this.client.config!.applicationCommandsRegister = {\n ...this.client.config!.applicationCommandsRegister,\n registerGlobally: false,\n registerToGuilds: false\n }\n\n this.cached = true;\n }\n\n this.client.modules.on('readyModules', async () => {\n this.logger.warn(`Application commands are ${this.cached ? '' : 'not '}cached. ${this.cached ? 'Skipping' : 'Proceeding with'} registration.`);\n });\n }\n\n public async readCacheEntry(): Promise<RecipleRegistryCache.CacheEntry|null> {\n const stats = await stat(this.cachePath).catch(() => null);\n if (!stats) return null;\n\n return await readFile(this.cachePath, 'utf-8').then(JSON.parse).catch(() => null);\n }\n\n public async writeCacheEntry(entry?: RecipleRegistryCache.CacheEntry): Promise<void> {\n entry ??= await this.createCacheEntry();\n\n this.logger.debug('Writing application commands cache entry...');\n await mkdir(this.cacheDir, { recursive: true });\n await writeFile(this.cachePath, JSON.stringify(entry, null, 4), 'utf-8');\n\n this.logger.debug(`Application commands cache entry written to \"${this.cachePath}\".`);\n }\n\n public async clearCacheEntry(): Promise<void> {\n await rm(this.cachePath).catch(() => null);\n }\n\n public async createCacheEntry(): Promise<RecipleRegistryCache.CacheEntry> {\n this.logger.debug('Creating current application commands cache entry...');\n const commands = Array.from(this.client.commands?.cache.filter(cmd => cmd.type !== CommandType.Message).map(cmd => cmd.toJSON()).values() ?? []);\n\n for (const command of commands) {\n Object.assign(command, { id: \"[cache_value]\" });\n }\n\n const commandsHash = RecipleRegistryCache.createCommandsHash(commands);\n const configHash = RecipleRegistryCache.createConfigHash(this.client.config?.applicationCommandsRegister ?? {});\n\n this.logger.debug(`Commands hash: ${commandsHash}`);\n this.logger.debug(`Config hash: ${configHash}`);\n this.logger.debug('Current application commands cache entry created.');\n\n return {\n createdAt: Date.now(),\n commandsHash,\n configHash\n };\n }\n\n public isCacheHit(cached: RecipleRegistryCache.CacheEntry, current: RecipleRegistryCache.CacheEntry): boolean {\n this.logger.debug('Comparing cache entry with current application commands and configuration...');\n if (this.maxCacheAgeMs) {\n const age = Date.now() - cached.createdAt;\n if (age > this.maxCacheAgeMs) {\n this.logger.debug(`Cache entry is too old (age: ${age}ms, max age: ${this.maxCacheAgeMs}ms).`);\n return false;\n }\n }\n\n if (cached.commandsHash !== current.commandsHash) {\n this.logger.debug(`Cache entry commands hash doesn't match (cached: ${cached.commandsHash}, current: ${current.commandsHash}).`);\n return false;\n }\n if (cached.configHash !== current.configHash) {\n this.logger.debug(`Cache entry config hash doesn't match (cached: ${cached.configHash}, current: ${current.configHash}).`);\n return false;\n }\n\n this.logger.debug('Cache entry matches current application commands and configuration.');\n return true;\n }\n\n private isEnabled(): boolean {\n if (process.env[this.cacheEnabledEnv] !== 'false' && process.env[this.cacheEnabledEnv] !== '0') {\n return RecipleRegistryCache.checkClientIfEnabled(this.client.config ?? {});\n }\n\n return false;\n }\n}\n\nexport namespace RecipleRegistryCache {\n export interface Options {\n /**\n * @default true\n */\n createCacheEntryEvenIfDisabled?: boolean;\n /**\n * @default '.cache/reciple-registry/'\n */\n cacheDir?: string;\n /**\n * @default 86400000 // 24 hours in milliseconds\n */\n maxCacheAgeMs?: number;\n /**\n * @default 'RECIPLE_REGISTRY_CACHE'\n */\n cacheEnabledEnv?: string;\n }\n\n export interface CacheEntry {\n commandsHash: string;\n configHash: string;\n createdAt: number;\n }\n\n export type CommandData = Exclude<AnyCommandData, MessageCommand.Data>;\n\n export function checkClientIfEnabled(config: Config): boolean {\n return config.applicationCommandsRegister?.registerGlobally\n || config.applicationCommandsRegister?.registerToGuilds === true\n || (\n Array.isArray(config.applicationCommandsRegister?.registerToGuilds)\n && config.applicationCommandsRegister?.registerToGuilds.length > 0\n );\n }\n\n export function createCommandsHash(commands: Exclude<AnyCommandData, MessageCommand.Data>[]): string {\n const hash = createHash('sha256');\n\n hash.update(stringifyValue(commands));\n\n return hash.digest('hex');\n }\n\n export function createConfigHash(config: Config): string {\n const hash = createHash('sha256');\n const relevantConfig = { applicationCommandsRegister: config.applicationCommandsRegister };\n\n hash.update(stringifyValue(relevantConfig));\n\n return hash.digest('hex');\n }\n\n export function stringifyValue(object: any): string {\n switch (typeof object) {\n case 'string':\n return `\"${object}\"`;\n case 'number':\n case 'bigint':\n case 'boolean':\n case 'symbol':\n case 'function':\n return `\"${object.toString()}\"`;\n case 'undefined':\n return 'undefined';\n case 'object':\n if (object === null) {\n return 'null';\n }\n\n if (Array.isArray(object)) {\n return `[${object.map(s => stringifyValue(s)).join(', ')}]`;\n }\n\n if (object instanceof Map) {\n return `{${Array.from(object.entries()).map(([k, v]) => `${stringifyValue(k)}: ${stringifyValue(v)}`).join(', ')}}`;\n }\n\n if (object instanceof Set) {\n return `{${Array.from(object.values()).map(v => stringifyValue(v)).join(', ')}}`;\n }\n\n if (object instanceof Date) {\n return `\"${object.toISOString()}\"`;\n }\n\n try {\n const newObject: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(object)) {\n newObject[key] = stringifyValue(value);\n }\n\n return JSON.stringify(newObject);\n } catch {\n return String(object);\n }\n }\n }\n}\n"],"mappings":";;;;;;AAKA,IAAa,uBAAb,MAAa,6BAA6B,WAAmD;CACzF,AAAgB,KAAa;CAE7B,AAAO,iCAA0C;CACjD,AAAO,WAAmB,KAAK,KAAK,QAAQ,KAAK,EAAE,2BAA2B;CAC9E,AAAO;CACP,AAAO,kBAA0B;CACjC,AAAO,SAAkB;CAEzB,AAAiB,SAAS,WAAW,CAAC,MAAM,EAAE,OAAO,iBAAiB,CAAC;CAEvE,YAAY,SAAwC;AAChD,SAAO;AACP,SAAO,OAAO,MAAM,WAAW,EAAE,CAAC;;CAGtC,IAAI,YAAoB;AACpB,SAAO,KAAK,KAAK,KAAK,UAAU,KAAK,OAAO,aAAa,MAAM,aAAa;;CAGhF,MAAa,UAAyB;EAClC,MAAM,UAAU,KAAK,WAAW;AAEhC,MAAI,WAAW,KAAK,+BAChB,MAAK,OAAO,UAAU,KAAK,+BAA+B,OAAO,UAAU,YAAY;AACnF,SAAM,KAAK,iBAAiB;IAC9B;AAGN,MAAI,CAAC,SAAS;AACV,QAAK,OAAO,QAAQ,GAAG,gBAAgB,YAAY;AAC/C,SAAK,OAAO,KAAK,iDAAiD;KACpE;AAEF;;AAGJ,OAAK,OAAO,MAAM,oDAAoD;EACtE,MAAM,cAAc,MAAM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":["export enum InteractionListenerType {\n Autocomplete = 1,\n ContextMenu,\n ChatInput,\n Button,\n ModalSubmit,\n SelectMenu,\n PrimaryEntryPoint\n}\n"],"mappings":";AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/helpers/constants.ts"],"sourcesContent":["export enum InteractionListenerType {\n Autocomplete = 1,\n ContextMenu,\n ChatInput,\n Button,\n ModalSubmit,\n SelectMenu,\n PrimaryEntryPoint\n}\n"],"mappings":";AAAA,IAAY,0BAAL;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;KACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reciple/modules",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.30",
|
|
4
4
|
"license": "LGPL-3.0-only",
|
|
5
5
|
"description": "A collection of useful modules for reciple",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"discord.js": "^14.25.1",
|
|
33
|
-
"reciple": "^10.0.
|
|
33
|
+
"reciple": "^10.0.28"
|
|
34
34
|
},
|
|
35
35
|
"peerDependenciesMeta": {
|
|
36
36
|
"discord.js": {
|