@pikokr/command.ts 5.5.0-dev.f749341 → 5.6.0-dev.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/.eslintrc.js +19 -0
  2. package/.github/workflows/docs.yml +22 -6
  3. package/.github/workflows/lint.yml +41 -0
  4. package/.github/workflows/release.yml +49 -0
  5. package/.vscode/settings.json +6 -3
  6. package/dist/index.d.ts +48 -46
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/package.json +21 -4
  10. package/publish-version.js +1 -23
  11. package/scripts/docs.ts +8 -8
  12. package/src/applicationCommand/ApplicationCommand.ts +1 -9
  13. package/src/applicationCommand/ApplicationCommandExtension.ts +14 -17
  14. package/src/applicationCommand/ApplicationCommandOption.ts +1 -9
  15. package/src/applicationCommand/group.ts +2 -1
  16. package/src/applicationCommand/index.ts +4 -12
  17. package/src/core/components/BaseComponent.ts +3 -11
  18. package/src/core/components/ComponentArgument.ts +1 -9
  19. package/src/core/components/ComponentArgumentDecorator.ts +0 -8
  20. package/src/core/components/decoratorCreator.ts +4 -12
  21. package/src/core/components/index.ts +5 -13
  22. package/src/core/converter/index.ts +8 -15
  23. package/src/core/extensions/CTSExtension.ts +0 -8
  24. package/src/core/extensions/Extension.ts +5 -13
  25. package/src/core/extensions/index.ts +0 -8
  26. package/src/core/hooks/componentHook.ts +4 -11
  27. package/src/core/hooks/index.ts +3 -11
  28. package/src/core/hooks/moduleHook.ts +2 -9
  29. package/src/core/index.ts +0 -8
  30. package/src/core/listener/index.ts +0 -8
  31. package/src/core/structures/CommandClient.ts +7 -12
  32. package/src/core/structures/Registry.ts +8 -16
  33. package/src/core/structures/index.ts +0 -8
  34. package/src/core/symbols.ts +6 -14
  35. package/src/core/utils/checks.ts +5 -12
  36. package/src/core/utils/errors.ts +0 -8
  37. package/src/core/utils/index.ts +3 -11
  38. package/src/index.ts +3 -11
  39. package/src/textCommand/TextCommand.ts +0 -8
  40. package/src/textCommand/TextCommandExtension.ts +11 -32
  41. package/src/textCommand/index.ts +0 -8
  42. package/src/textCommand/parameters.ts +6 -14
  43. package/src/utils/types.ts +1 -0
  44. package/test/index.ts +5 -4
  45. package/tsup.config.ts +8 -8
  46. package/.github/workflows/publish.stable.yml +0 -18
  47. package/.github/workflows/publish.yml +0 -20
  48. package/.yarn/releases/yarn-3.2.3.cjs +0 -783
  49. package/.yarn/sdks/integrations.yml +0 -5
  50. package/.yarn/sdks/prettier/index.js +0 -20
  51. package/.yarn/sdks/prettier/package.json +0 -6
  52. package/.yarn/sdks/typescript/bin/tsc +0 -20
  53. package/.yarn/sdks/typescript/bin/tsserver +0 -20
  54. package/.yarn/sdks/typescript/lib/tsc.js +0 -20
  55. package/.yarn/sdks/typescript/lib/tsserver.js +0 -196
  56. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +0 -196
  57. package/.yarn/sdks/typescript/lib/typescript.js +0 -20
  58. package/.yarn/sdks/typescript/package.json +0 -6
  59. package/.yarnrc.yml +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/symbols.ts","../src/core/hooks/componentHook.ts","../src/core/components/decoratorCreator.ts","../src/core/components/ComponentArgument.ts","../src/core/components/ComponentArgumentDecorator.ts","../src/applicationCommand/ApplicationCommand.ts","../src/applicationCommand/ApplicationCommandOption.ts","../src/core/listener/index.ts","../src/core/converter/index.ts","../src/core/hooks/moduleHook.ts","../src/core/hooks/index.ts","../src/core/structures/Registry.ts","../src/core/structures/index.ts","../src/core/extensions/Extension.ts","../src/core/extensions/CTSExtension.ts","../src/applicationCommand/ApplicationCommandExtension.ts","../src/textCommand/TextCommand.ts","../src/textCommand/parameters.ts","../src/textCommand/TextCommandExtension.ts","../src/core/structures/CommandClient.ts","../src/core/components/BaseComponent.ts","../src/core/components/index.ts","../src/core/utils/errors.ts","../src/core/utils/checks.ts","../src/core/utils/decorators.ts","../src/core/utils/index.ts","../src/core/extensions/index.ts","../src/core/index.ts","../src/index.ts","../src/applicationCommand/group.ts"],"sourcesContent":["/*\r\n * File: symbols.ts\r\n *\r\n * Copyright (c) 2022-2022 pikokr\r\n *\r\n * Licensed under MIT License. Please see more defails in LICENSE file.\r\n */\r\n\r\nexport const ComponentStoreSymbol = Symbol()\r\nexport const ComponentArgStoreSymbol = Symbol()\r\nexport const ModuleHookStoreSymbol = Symbol()\r\nexport const CommandClientSymbol = Symbol()\r\nexport const ComponentHookSymbol = Symbol()\r\nexport const FilePathSymbol = Symbol()\r\n","/*\n * File: componentHook.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport { Collection } from 'discord.js'\nimport { ComponentHookSymbol } from '../symbols'\n\nexport type ComponentHookFn = (...args: any[]) => void | Promise<void>\n\nexport type ComponentHookStore = Collection<string, ComponentHookFn[]>\n\nexport const getComponentHookStore = (target: object, property: string | symbol): ComponentHookStore => {\n let data = Reflect.getMetadata(ComponentHookSymbol, target, property) as ComponentHookStore\n\n if (!data) {\n data = new Collection()\n Reflect.defineMetadata(ComponentHookSymbol, data, target, property)\n }\n\n return data\n}\n\nexport const createComponentHook = (name: string, fn: ComponentHookFn): MethodDecorator => {\n return (target, key) => {\n const store = getComponentHookStore(target, key)\n\n let hooks = store.get(name)\n\n if (!hooks) {\n hooks = []\n store.set(name, hooks)\n }\n\n hooks.unshift(fn)\n }\n}\n","/*\n * File: decoratorCreator.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport { Collection } from 'discord.js'\nimport { ComponentHookStore } from '../hooks'\nimport { getComponentHookStore } from '../hooks/componentHook'\nimport { ComponentStoreSymbol } from '../symbols'\nimport { BaseComponent } from './BaseComponent'\nimport { ComponentArgumentDecorator } from './ComponentArgumentDecorator'\n\nexport type ComponentStore = Collection<string | symbol, BaseComponent>\nexport type ComponentArgumentStore = Collection<number, ComponentArgumentDecorator>\n\nexport const getComponentStore = (target: object): ComponentStore => {\n let result: ComponentStore | null = Reflect.getMetadata(ComponentStoreSymbol, target)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ComponentStoreSymbol, result, target)\n }\n\n return result\n}\n\nexport const getComponent = (target: object, key: string | symbol) => {\n const store = getComponentStore(target)\n\n return store.get(key)\n}\n\nexport const createComponentDecorator = (component: BaseComponent): MethodDecorator => {\n return (target, key) => {\n component._init(Reflect.get(target, key), Reflect.getMetadata('design:paramtypes', target, key))\n\n const componentHookStore: ComponentHookStore = getComponentHookStore(target, key)\n\n component.hooks = componentHookStore\n\n const store = getComponentStore(target)\n\n const decorators = getComponentArgumentStore(target, key)\n\n decorators.forEach((x, i) => {\n component.argTypes.get(i)?.decorators.push(x)\n })\n\n store.set(key, component)\n }\n}\n\nexport const getComponentArgumentStore = (target: object, key: string | symbol): ComponentArgumentStore => {\n let result: ComponentArgumentStore | null = Reflect.getMetadata(ComponentStoreSymbol, target, key)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ComponentStoreSymbol, result, target, key)\n }\n\n return result\n}\n\nexport const createArgumentDecorator = <Options>(type: typeof ComponentArgumentDecorator<Options>) => {\n return (options: Options): ParameterDecorator => {\n return (target, key, idx) => {\n var arg: ComponentArgumentDecorator<Options> = new type(options)\n\n const store = getComponentArgumentStore(target, key)\n\n store.set(idx, arg)\n }\n }\n}\n","/*\r\n* File: ComponentArgument.ts\r\n* \r\n* Copyright (c) 2022-2022 pikokr\r\n* \r\n* Licensed under MIT License. Please see more defails in LICENSE file.\r\n*/\r\n\r\nimport { ComponentArgumentDecorator } from './ComponentArgumentDecorator'\n\nexport class ComponentArgument {\n decorators: ComponentArgumentDecorator[] = []\n\n constructor(public type: unknown) {}\n}\n","/*\r\n* File: ComponentArgumentDecorator.ts\r\n* \r\n* Copyright (c) 2022-2022 pikokr\r\n* \r\n* Licensed under MIT License. Please see more defails in LICENSE file.\r\n*/\r\n\r\nimport _ from 'lodash'\n\nexport class ComponentArgumentDecorator<Options = unknown> {\n options: Options\n\n constructor(options: Partial<Options>) {\n if (typeof options === 'object') {\n this.options = _.merge(this.defaultOptions(), options)\n } else {\n this.options = options\n }\n }\n\n defaultOptions(): Options {\n return {} as unknown as Options\n }\n}\n","/*\n * File: ApplicationCommand.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport type { ApplicationCommandType, ChatInputApplicationCommandData, MessageApplicationCommandData, Snowflake, UserApplicationCommandData } from 'discord.js'\nimport { createComponentDecorator } from '../core/components/decoratorCreator'\nimport { BaseComponent } from '../core/components/BaseComponent'\nimport { SubCommandGroup, SubCommandGroupChild } from './group'\n\ntype Options = (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {\n type: ApplicationCommandType\n guilds?: Snowflake[]\n}\n\nexport class ApplicationCommandComponent extends BaseComponent {\n options: Options\n\n subcommandGroup?: SubCommandGroup\n subcommandGroupChild?: SubCommandGroupChild\n\n constructor(options: UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) {\n super()\n\n this.options = options as Options\n }\n}\n\nexport const applicationCommand = (options: Options) => createComponentDecorator(new ApplicationCommandComponent(options))\n\nexport type { Options as ApplicationCommandComponentOptions }\n","/*\r\n* File: ApplicationCommandOption.ts\r\n* \r\n* Copyright (c) 2022-2022 pikokr\r\n* \r\n* Licensed under MIT License. Please see more defails in LICENSE file.\r\n*/\r\n\r\nimport { APIApplicationCommandOption } from 'discord.js'\nimport { createArgumentDecorator, ComponentArgumentDecorator } from '../core'\n\ntype Options = APIApplicationCommandOption\n\nexport class ApplicationCommandOption extends ComponentArgumentDecorator<Options> {}\n\nexport const option = createArgumentDecorator(ApplicationCommandOption)\n","/*\n * File: index.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport _ from 'lodash'\nimport { BaseComponent } from '../components/BaseComponent'\nimport { createComponentDecorator } from '../components/decoratorCreator'\n\ntype Options = { emitter: string; event: string }\n\ntype OptionsArg = { emitter?: string; event: string }\n\nexport class ListenerComponent extends BaseComponent {\n options: Options\n\n constructor(options: OptionsArg) {\n super()\n\n this.options = _.merge({ emitter: 'discord' }, options)\n }\n}\n\nexport const listener = (options: OptionsArg) => createComponentDecorator(new ListenerComponent(options))\n\nexport { Options as ListenerOptions, OptionsArg as ListenerOptionsArg }\n","/*\n * File: index.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport { BaseComponent } from '../components/BaseComponent'\nimport { createComponentDecorator } from '../components/decoratorCreator'\n\ntype Options = { component: unknown; type: Function; parameterless: boolean }\n\ntype OptionsArg = Omit<Options, 'parameterless'> & { parameterless?: boolean }\n\nexport class ConverterComponent extends BaseComponent {\n options: Options\n\n constructor(options: OptionsArg) {\n super()\n this.options = options as Options\n }\n}\n\nexport const argConverter = (options: OptionsArg) => createComponentDecorator(new ConverterComponent(options))\n\nexport { Options as ArgumentConvertOptions, OptionsArg as ArgumentConvertOptionsArg }\n","/*\n * File: moduleHook.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport { Collection } from 'discord.js'\nimport { ModuleHookStoreSymbol } from '../symbols'\n\nexport type ModuleHookStore = Collection<string, Function[]>\n\nexport const getModuleHookStore = (target: object) => {\n let result: ModuleHookStore | null = Reflect.getMetadata(ModuleHookStoreSymbol, target)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ModuleHookStoreSymbol, result, target)\n }\n\n return result\n}\n\nexport const moduleHook = (name: string): MethodDecorator => {\n return (target, key) => {\n const store = getModuleHookStore(target)\n\n let v = store.get(name)\n\n if (!v) {\n v = []\n store.set(name, v)\n }\n\n v.push(Reflect.get(target, key))\n }\n}\n","/*\r\n * File: index.ts\r\n *\r\n * Copyright (c) 2022-2022 pikokr\r\n *\r\n * Licensed under MIT License. Please see more defails in LICENSE file.\r\n */\r\n\r\nexport * from './moduleHook'\r\nexport { createComponentHook, type ComponentHookFn } from './componentHook'\r\nexport type { ComponentHookStore } from './componentHook'\r\n","/*\n * File: Registry.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport chalk from 'chalk'\nimport { Collection } from 'discord.js'\nimport EventEmitter from 'events'\nimport _, { result } from 'lodash'\nimport { Logger } from 'tslog'\nimport { getComponentStore } from '../components'\nimport { getModuleHookStore } from '../hooks'\nimport { ListenerComponent } from '../listener'\nimport { CommandClientSymbol, FilePathSymbol } from '../symbols'\nimport { CommandClient } from './CommandClient'\nimport walkSync from 'walk-sync'\nimport path from 'path'\nimport { ComponentHookFn } from '../hooks/componentHook'\n\nexport class Registry {\n extensions: object[] = []\n\n emitters: Collection<string, EventEmitter> = new Collection()\n\n logger: Logger<unknown>\n\n globalHooks: Record<string, ComponentHookFn[]> = {}\n\n constructor(logger: Logger<unknown>, public client: CommandClient) {\n this.logger = logger.getSubLogger({\n name: chalk.green('Registry'),\n })\n }\n\n addGlobalHook(name: string, fn: ComponentHookFn) {\n let hooks = this.globalHooks[name]\n\n if (!hooks) {\n hooks = []\n this.globalHooks[name] = hooks\n }\n\n hooks.push(fn)\n }\n\n getComponentsWithTypeGlobal<T>(type: unknown): T[] {\n const result: T[] = []\n\n for (const ext of this.extensions) {\n result.push(...this.getComponentsWithType<T>(ext, type))\n }\n\n return result\n }\n\n getComponentsWithType<T>(ext: object, type: unknown): T[] {\n const componentStore = getComponentStore(ext)\n\n return Array.from(componentStore.filter((x) => (x.constructor as unknown) === type).values() as Iterable<T>)\n }\n\n registerEventListeners(ext: object) {\n const listeners = this.getComponentsWithType<ListenerComponent>(ext, ListenerComponent)\n\n for (const listener of listeners) {\n const emitter = this.emitters.get(listener.options.emitter)\n\n if (emitter) {\n const bound = listener.method.bind(ext)\n\n Reflect.defineMetadata('bound', bound, listener)\n\n emitter.addListener(listener.options.event, bound)\n }\n }\n }\n\n unregisterEventListeners(ext: object) {\n const listeners = this.getComponentsWithType<ListenerComponent>(ext, ListenerComponent)\n\n for (const listener of listeners) {\n const emitter = this.emitters.get(listener.options.emitter)\n const bound = Reflect.getMetadata('bound', listener)\n\n if (emitter && bound) {\n emitter.removeListener(listener.options.event, bound)\n }\n }\n }\n\n async loadAllModulesInDirectory(dir: string, pattern?: RegExp): Promise<object[]> {\n const results: object[] = []\n\n const files = walkSync(dir).filter((x) => (x.endsWith('.ts') || x.endsWith('.js')) && (!pattern || pattern.test(x)))\n\n for (const file of files) {\n if (file.endsWith('.d.ts')) continue\n const p = path.join(dir, file)\n results.push(...(await this.loadModulesAtPath(p)))\n }\n\n return results\n }\n\n async loadModulesAtPath(file: string) {\n this.logger.info(`Loading module at path ${chalk.green(file)}`)\n\n const p = require.resolve(file)\n\n const mod = require(p)\n\n if (typeof mod.setup !== 'function') throw new Error('Extension must have a setup function')\n\n const modules = await mod.setup(this.client)\n\n return this.registerModules(modules, p)\n }\n\n private async registerModules(modules: object | object[], p: string) {\n const results: object[] = []\n if (modules instanceof Array) {\n for (const module of modules) {\n await this.registerModule(module)\n Reflect.defineMetadata(FilePathSymbol, p, module)\n results.push(module)\n }\n } else {\n await this.registerModule(modules)\n Reflect.defineMetadata(FilePathSymbol, p, modules)\n results.push(modules)\n }\n\n return results\n }\n\n async reloadModules() {\n const result: { file: string; result: boolean; error?: Error; extensions?: object[] }[] = []\n const paths = new Set<string>()\n const extensions = [...this.extensions]\n for (const module of extensions) {\n const file = Reflect.getMetadata(FilePathSymbol, module)\n if (!file) continue\n\n this.logger.info(`Unloading module: ${chalk.green(module.constructor.name)}`)\n\n paths.add(file)\n\n await this.unregisterModule(module)\n\n delete require.cache[require.resolve(file)]\n }\n\n for (const path of paths) {\n try {\n const extensions = await this.loadModulesAtPath(path)\n\n result.push({\n file: path,\n result: true,\n extensions,\n })\n } catch (e) {\n result.push({\n file: path,\n result: false,\n error: e as Error,\n })\n }\n }\n\n return result\n }\n\n async registerModule(ext: object) {\n Reflect.defineMetadata(CommandClientSymbol, this.client, ext)\n\n this.registerEventListeners(ext)\n await this.runModuleHook(ext, 'load')\n this.extensions.push(ext)\n this.logger.info(`Module registered: ${chalk.green(ext.constructor.name)}`)\n }\n\n async unregisterModule(ext: object) {\n this.unregisterEventListeners(ext)\n await this.runModuleHook(ext, 'unload')\n _.remove(this.extensions, (x) => x === ext)\n this.logger.info(`Module unregistered: ${chalk.green(ext.constructor.name)}`)\n }\n\n runModuleHook(ext: object, hookName: string, ...args: unknown[]) {\n const hooks = getModuleHookStore(ext)\n\n const functions = hooks.get(hookName)\n\n if (functions) {\n for (const fn of functions) {\n fn.call(ext, ...args)\n }\n }\n }\n\n registerEventEmitter(name: string, emitter: EventEmitter) {\n this.emitters.set(name, emitter)\n }\n}\n","/*\r\n* File: index.ts\r\n* \r\n* Copyright (c) 2022-2022 pikokr\r\n* \r\n* Licensed under MIT License. Please see more defails in LICENSE file.\r\n*/\r\n\r\nexport * from './Registry'\nexport * from './CommandClient'\n","/*\n * File: Extension.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport chalk from 'chalk'\nimport { Collection } from 'discord.js'\nimport { Logger } from 'tslog'\nimport { ComponentArgument } from '../components/ComponentArgument'\nimport { ConverterComponent } from '../converter'\nimport { CommandClient } from '../structures'\n\nexport class Extension {\n protected get commandClient() {\n return CommandClient.getFromModule(this)\n }\n\n protected get client() {\n return this.commandClient.discord\n }\n\n protected _logger?: Logger<unknown>\n\n protected get logger() {\n if (!this._logger) this._logger = this.commandClient.logger.getSubLogger({ name: chalk.green(`${this.constructor.name}`) })\n return this._logger\n }\n\n protected async convertArguments(\n component: unknown,\n argList: unknown[],\n args: Collection<number, ComponentArgument>,\n getConverterArgs: (arg: ComponentArgument, index: number, converter: ConverterComponent) => unknown[] | Promise<unknown[]>,\n ) {\n const items = new Collection<unknown, { ext: object; component: ConverterComponent }>()\n\n for (const extension of this.commandClient.registry.extensions) {\n for (const converter of this.commandClient.registry.getComponentsWithType<ConverterComponent>(extension, ConverterComponent)) {\n if (converter.options.component != component) continue\n\n items.set(converter.options.type, { component: converter, ext: extension })\n }\n }\n\n for (const [index, arg] of args) {\n const converter = items.get(arg.type)\n\n if (!converter) {\n argList[index] = undefined\n continue\n }\n\n const converterArgs = await getConverterArgs(arg, index, converter.component)\n\n argList[index] = await converter.component.execute(converter.ext, converterArgs)\n }\n }\n}\n","/*\n * File: CTSExtension.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport chalk from 'chalk'\nimport { Extension } from './Extension'\n\nexport class CTSExtension extends Extension {\n protected get logger() {\n if (!this._logger) this._logger = this.commandClient.ctsLogger.getSubLogger({ name: chalk.green(`${this.constructor.name}`) })\n return this._logger\n }\n}\n","/*\n * File: ApplicationCommandExtension.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport chalk from 'chalk'\nimport {\n APIApplicationCommandSubcommandGroupOption,\n APIApplicationCommandSubcommandOption,\n ApplicationCommandData,\n ApplicationCommandDataResolvable,\n ApplicationCommandOptionType,\n ApplicationCommandSubCommandData,\n ApplicationCommandType,\n ChatInputApplicationCommandData,\n ChatInputCommandInteraction,\n Collection,\n CommandInteraction,\n Interaction,\n InteractionType,\n MessageContextMenuCommandInteraction,\n Snowflake,\n UserContextMenuCommandInteraction,\n} from 'discord.js'\nimport { ApplicationCommandComponent } from './ApplicationCommand'\nimport { ApplicationCommandOption } from './ApplicationCommandOption'\nimport { listener } from '../core/listener'\nimport { argConverter } from '../core/converter'\nimport { CTSExtension } from '../core/extensions/CTSExtension'\n\nexport type ApplicationCommandExtensionConfig = {\n guilds?: Snowflake[]\n}\n\nexport class ApplicationCommandExtension extends CTSExtension {\n constructor(public config: ApplicationCommandExtensionConfig) {\n super()\n }\n\n unmanagedCommands: (ApplicationCommandData & { guilds?: Snowflake[] })[] = []\n\n registerUnmanagedCommand(command: ApplicationCommandData & { guilds?: Snowflake[] }) {\n this.unmanagedCommands.push(command)\n }\n\n @listener({ event: 'interactionCreate' })\n async interactionCreate(i: Interaction) {\n try {\n if (i.type !== InteractionType.ApplicationCommand) return\n\n let cmd: ApplicationCommandComponent | null = null\n let ext: object | null = null\n\n const extensions = this.commandClient.registry.extensions\n\n let subcommand: string | null = null\n let subcommandGroup: string | null = null\n\n if (i.commandType === ApplicationCommandType.ChatInput) {\n subcommand = i.options.getSubcommand(false)\n subcommandGroup = i.options.getSubcommandGroup(false)\n }\n\n extLoop: for (const extension of extensions) {\n const components = this.commandClient.registry.getComponentsWithType<ApplicationCommandComponent>(extension, ApplicationCommandComponent)\n\n if (subcommand) {\n for (const command of components) {\n if (!command.subcommandGroup && !command.subcommandGroupChild) continue\n\n if (\n command.subcommandGroupChild &&\n command.subcommandGroupChild.parent.options.name === i.commandName &&\n command.subcommandGroupChild.options.name === subcommandGroup &&\n command.options.name === subcommand\n ) {\n ext = extension\n cmd = command\n break extLoop\n }\n if (command.subcommandGroup && !subcommandGroup && command.subcommandGroup.options.name === i.commandName && command.options.name === subcommand) {\n ext = extension\n cmd = command\n break extLoop\n }\n }\n } else {\n for (const command of components) {\n if (command.options.name === i.commandName) {\n ext = extension\n cmd = command\n break extLoop\n }\n }\n }\n }\n\n if (cmd && ext) {\n const argList: unknown[] = []\n\n await this.convertArguments(ApplicationCommandComponent, argList, cmd.argTypes, () => [i])\n\n for (const [idx, arg] of cmd.argTypes) {\n let value: unknown = null\n\n for (const decorator of arg.decorators) {\n if (decorator instanceof ApplicationCommandOption) {\n if ([ApplicationCommandOptionType.Subcommand, ApplicationCommandOptionType.SubcommandGroup].includes(decorator.options.type) && i.isChatInputCommand()) {\n if (decorator.options.type === ApplicationCommandOptionType.Subcommand) {\n value = i.options.getSubcommand() === decorator.options.name\n break\n }\n if (decorator.options.type === ApplicationCommandOptionType.SubcommandGroup) {\n value = i.options.getSubcommandGroup() === decorator.options.name\n break\n }\n }\n\n value = i.options.get(decorator.options.name, false)?.value\n break\n }\n }\n\n if (value) {\n argList[idx] = value\n }\n }\n\n try {\n await cmd.executeGlobalHook(ext, 'beforeApplicationCommandCall', [i])\n await cmd.execute(ext, argList, [i])\n } finally {\n await cmd.executeGlobalHook(ext, 'afterApplicationCommandCall', [i])\n }\n }\n } catch (e) {\n this.commandClient.emit('applicationCommandInvokeError', e, i)\n }\n }\n\n async sync() {\n const client = this.commandClient\n\n this.logger.info('Trying to sync commands...')\n\n let commands: ApplicationCommandData[] = []\n\n const guildCommands = new Collection<Snowflake, ApplicationCommandData[]>()\n\n const subcommandGroups = new Collection<string, ChatInputApplicationCommandData>()\n\n for (const command of client.registry.getComponentsWithTypeGlobal<ApplicationCommandComponent>(ApplicationCommandComponent)) {\n if (command.subcommandGroup) {\n let group = subcommandGroups.get(command.subcommandGroup.options.name)\n\n if (!group) {\n group = {\n ...command.subcommandGroup.options,\n type: ApplicationCommandType.ChatInput,\n }\n\n if (command.subcommandGroup.guilds) {\n for (const guild of command.subcommandGroup.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n }\n } else {\n commands.push(group)\n }\n\n subcommandGroups.set(command.subcommandGroup.options.name, group)\n }\n\n if (!group.options) group.options = []\n\n const options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n options.push(option.options)\n }\n }\n\n group.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as ApplicationCommandSubCommandData)\n\n continue\n } else if (command.subcommandGroupChild) {\n const parent = command.subcommandGroupChild.parent\n let group = subcommandGroups.get(parent.options.name)\n\n if (!group) {\n group = {\n ...parent.options,\n type: ApplicationCommandType.ChatInput,\n }\n\n if (parent.guilds) {\n for (const guild of parent.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n }\n } else {\n commands.push(group)\n }\n\n subcommandGroups.set(parent.options.name, group)\n }\n\n if (!group.options) group.options = []\n\n let child = group.options.find((x) => x.name === command.subcommandGroupChild!.options.name) as APIApplicationCommandSubcommandGroupOption\n\n if (!child) {\n child = { type: ApplicationCommandOptionType.SubcommandGroup, ...(command.subcommandGroupChild.options as Omit<APIApplicationCommandSubcommandGroupOption, 'type'>) }\n group.options.push(child)\n }\n\n if (!child.options) child.options = []\n\n const options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n options.push(option.options)\n }\n }\n\n child.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as APIApplicationCommandSubcommandOption)\n\n continue\n }\n\n const cmd: ApplicationCommandData = { ...command.options }\n\n if (cmd.type === ApplicationCommandType.ChatInput) {\n cmd.options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n cmd.options.push(option.options)\n }\n }\n }\n\n await command.executeHook(this, 'beforeSync', [cmd, command])\n\n if (command.options.guilds) {\n for (const guild of command.options.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n commands.push(cmd)\n }\n continue\n }\n\n commands.push(cmd)\n }\n\n for (const { guilds, ...rest } of this.unmanagedCommands) {\n if (guilds) {\n for (const guild of guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n commands.push(rest)\n }\n continue\n } else {\n commands.push(rest)\n }\n }\n\n if (this.config.guilds) {\n for (const guild of this.config.guilds) {\n let g = guildCommands.get(guild)\n if (!g) {\n g = []\n guildCommands.set(guild, g)\n }\n g.push(...commands)\n }\n\n commands = []\n }\n\n if (guildCommands.size) {\n for (const [guild, commands] of guildCommands) {\n try {\n const g = await this.client.guilds.fetch(guild)\n await g.fetch()\n this.logger.info(\n `Processing ${chalk.green(commands.length)} commands(${commands.map((x) => chalk.blue(x.name)).join(', ')}) for guild ${chalk.green(g.name)}(${chalk.blue(g.id)})`,\n )\n\n await g.commands.set(commands)\n\n this.logger.info(`Successfully registered commands for guild ${chalk.green(g.name)}(${chalk.blue(g.id)})`)\n } catch (e) {\n this.logger.error(`Failed to register commands to guild ${chalk.green(guild)}: ${(e as Error).message}`)\n }\n }\n }\n if (commands.length) {\n try {\n this.logger.info(`Processing ${chalk.green(commands.length)} commands(${commands.map((x) => chalk.blue(x.name)).join(', ')}) for application scope...`)\n\n await this.client.application!.commands.set(commands)\n\n this.logger.info('Successfully registered commands.')\n } catch (e) {\n this.logger.error(`Failed to register commands to global: ${(e as Error).message}`)\n }\n }\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: ChatInputCommandInteraction,\n })\n async chatInteraction(i: ChatInputCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: MessageContextMenuCommandInteraction,\n })\n async messageInteraction(i: MessageContextMenuCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: UserContextMenuCommandInteraction,\n })\n async userInteraction(i: UserContextMenuCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: CommandInteraction,\n })\n async commandInteraction(i: UserContextMenuCommandInteraction) {\n return i\n }\n}\n","/*\n * File: TextCommand.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport { createComponentDecorator } from '../core/components/decoratorCreator'\nimport { BaseComponent } from '../core/components/BaseComponent'\n\nexport type TextCommandOptions = {\n name: string\n aliases?: string[]\n description?: string\n}\n\nexport class TextCommandComponent extends BaseComponent {\n constructor(public options: TextCommandOptions) {\n super()\n }\n}\n\nexport const command = (options: TextCommandOptions) => createComponentDecorator(new TextCommandComponent(options))\n","/*\r\n * File: parameters.ts\r\n *\r\n * Copyright (c) 2022-2022 pikokr\r\n *\r\n * Licensed under MIT License. Please see more defails in LICENSE file.\r\n */\r\n\r\nimport { ComponentArgumentDecorator } from '../core'\r\nimport { createArgumentDecorator } from '../core'\r\n\r\nexport class TextCommandRestOption extends ComponentArgumentDecorator<void> {}\r\n\r\nexport const rest = createArgumentDecorator(TextCommandRestOption)\r\n","/*\n * File: TextCommandExtension.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport { listener } from '../core/listener'\nimport { Message } from 'discord.js'\nimport { CTSExtension } from '../core/extensions/CTSExtension'\nimport { TextCommandComponent } from './TextCommand'\nimport { TextCommandRestOption } from './parameters'\nimport { argConverter } from '../core'\n\nexport type TextCommandConfig = {\n prefix:\n | string\n | string[]\n | ((msg: Message) => Promise<string | string[]> | string | string[])\n}\n\ndeclare module 'discord.js' {\n interface Message {\n command: TextCommandComponent\n }\n}\n\nexport class TextCommandExtension extends CTSExtension {\n constructor(private config: TextCommandConfig) {\n super()\n }\n\n private async processPrefix(msg: Message): Promise<number | null> {\n const content = msg.content\n let prefix = this.config.prefix\n\n if (typeof prefix === 'function') {\n prefix = await prefix(msg)\n }\n\n if (typeof prefix === 'string') {\n if (content.startsWith(prefix)) return prefix.length\n return null\n }\n\n if (prefix instanceof Array) {\n const p = prefix.find((x) => content.startsWith(x))\n\n if (p) return p.length\n return null\n }\n\n return null\n }\n\n @listener({ event: 'messageCreate', emitter: 'discord' })\n private async messageCreate(msg: Message) {\n try {\n const startIndex = await this.processPrefix(msg)\n\n if (startIndex === null) return\n\n const content = msg.content.slice(startIndex)\n\n const commands: TextCommandComponent[] = []\n\n const extensions = new Map<TextCommandComponent, object>()\n\n for (const ext of this.commandClient.registry.extensions) {\n for (const cmd of this.commandClient.registry.getComponentsWithType<TextCommandComponent>(\n ext,\n TextCommandComponent\n )) {\n commands.push(cmd)\n extensions.set(cmd, ext)\n }\n }\n\n let commandNameLength = 0\n\n const command = commands.find((x) => {\n const names = [x.options.name]\n\n if (x.options.aliases) {\n names.push(...x.options.aliases)\n }\n\n for (const name of names) {\n if (content.startsWith(name)) {\n if (content.length === name.length) {\n commandNameLength = name.length\n return true\n }\n commandNameLength = name.length\n return content.startsWith(name + ' ')\n }\n }\n\n return false\n })\n\n if (!command) return\n\n const ext = extensions.get(command)\n\n if (!ext) return\n\n msg.command = command\n\n const args: unknown[] = []\n\n let argStrings = content.slice(commandNameLength + 1).split(/ /g)\n\n await this.convertArguments(\n TextCommandComponent,\n args,\n command.argTypes,\n async (arg, i, converter) => {\n if (converter.options.parameterless) return [msg]\n\n if (\n arg.decorators.find((x) => x.constructor === TextCommandRestOption)\n ) {\n const text = argStrings.join(' ')\n argStrings = []\n return [text, msg]\n }\n return [argStrings.shift(), msg]\n }\n )\n\n await command.execute(ext, args, [msg])\n } catch (e) {\n this.commandClient.emit('textCommandInvokeError', e, msg)\n }\n }\n\n @argConverter({\n component: TextCommandComponent,\n type: Message,\n parameterless: true,\n })\n async mesage(msg: Message) {\n return msg\n }\n\n @argConverter({ component: TextCommandComponent, type: String })\n async str(value: string) {\n return value\n }\n\n @argConverter({ component: TextCommandComponent, type: Number })\n async num(value: string) {\n return Number(value)\n }\n}\n","/*\n * File: CommandClient.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport chalk from 'chalk'\nimport { Client, Snowflake, Team, User } from 'discord.js'\nimport EventEmitter from 'events'\nimport { ISettingsParam, Logger } from 'tslog'\nimport { ApplicationCommandExtension, ApplicationCommandExtensionConfig } from '../../applicationCommand/ApplicationCommandExtension'\nimport { TextCommandConfig } from '../../textCommand'\nimport { TextCommandExtension } from '../../textCommand/TextCommandExtension'\nimport { CommandClientSymbol } from '../symbols'\nimport { Registry } from './Registry'\nexport class CommandClient extends EventEmitter {\n ctsLogger: Logger<unknown>\n registry: Registry\n\n owners: Set<Snowflake> = new Set()\n\n constructor(public discord: Client, public logger: Logger<unknown> = new Logger({ prettyLogTimeZone: 'local' }), loggerOptions: ISettingsParam<unknown> = {}) {\n super()\n\n this.ctsLogger = logger.getSubLogger({\n ...loggerOptions,\n name: 'command.ts',\n })\n\n this.registry = new Registry(this.ctsLogger, this)\n\n this.registry.registerEventEmitter('cts', this)\n this.registry.registerEventEmitter('discord', this.discord)\n }\n\n async isOwner(user: User): Promise<boolean> {\n return this.owners.has(user.id)\n }\n\n async fetchOwners() {\n if (!this.discord.application) throw new Error('The client is not logged in.')\n\n this.ctsLogger.info('Fetching owners...')\n\n await this.discord.application.fetch()\n\n const owner = this.discord.application.owner\n\n if (!owner) throw new Error('Cannot find application owner')\n\n const owners: string[] = []\n\n if (owner instanceof User) {\n this.owners.add(owner.id)\n owners.push(owner.tag)\n } else if (owner instanceof Team) {\n for (const [id, member] of owner.members) {\n this.owners.add(id)\n owners.push(member.user.tag)\n }\n }\n\n this.ctsLogger.info(`Fetched ${chalk.green(owners.length)} owners(${owners.map((x) => chalk.blue(x)).join(', ')})`)\n }\n\n async enableApplicationCommandsExtension(config: ApplicationCommandExtensionConfig) {\n await this.registry.registerModule(new ApplicationCommandExtension(config))\n this.ctsLogger.info('Application command extension enabled.')\n }\n\n async enableTextCommandsExtension(config: TextCommandConfig) {\n await this.registry.registerModule(new TextCommandExtension(config))\n this.ctsLogger.info('Text command extension enabled.')\n }\n\n getApplicationCommandsExtension() {\n return this.registry.extensions.find((x) => x.constructor === ApplicationCommandExtension) as ApplicationCommandExtension | undefined\n }\n\n static getFromModule(ext: object): CommandClient {\n return Reflect.getMetadata(CommandClientSymbol, ext)\n }\n}\n","/*\n * File: BaseComponent.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport { Collection } from 'discord.js'\nimport _ from 'lodash'\nimport type { ComponentHookStore } from '../hooks'\nimport { ComponentArgument } from './ComponentArgument'\n\nexport class BaseComponent {\n method!: Function\n\n hooks: ComponentHookStore = new Collection()\n\n argTypes: Collection<number, ComponentArgument> = new Collection()\n\n _init(method: Function, argTypes: unknown[]) {\n this.method = method\n for (let i = 0; i < argTypes.length; i++) {\n const element = argTypes[i]\n this.argTypes.set(i, new ComponentArgument(element))\n }\n }\n\n async executeGlobalHook(target: object, name: string, args: unknown[]) {\n const { CommandClient } = await import('../structures/CommandClient')\n\n const client = CommandClient.getFromModule(target)\n\n const globalHooks = client.registry.globalHooks[name]\n\n if (globalHooks) {\n for (const fn of globalHooks) {\n await fn.call(null, client, ...args)\n }\n }\n }\n\n async executeHook(target: object, name: string, args: unknown[]) {\n const hook = this.hooks.get(name)\n\n if (!hook) return\n\n const { CommandClient } = await import('../structures/CommandClient')\n\n const client = CommandClient.getFromModule(target)\n\n const globalHooks = client.registry.globalHooks[name]\n\n if (globalHooks) {\n hook.unshift(...globalHooks)\n }\n\n for (const fn of hook) {\n await fn.call(null, client, ...args)\n }\n }\n\n async execute(target: object, args: unknown[], beforeCallArgs: unknown[] = args) {\n await this.executeHook(target, 'beforeCall', beforeCallArgs)\n let result\n try {\n result = await this.method.call(target, ...args)\n await this.executeHook(target, 'afterCall', [...beforeCallArgs, result])\n } catch (e) {\n await this.executeHook(target, 'invokeError', [e, ...beforeCallArgs])\n throw e\n }\n\n return result\n }\n}\n","/*\r\n* File: index.ts\r\n* \r\n* Copyright (c) 2022-2022 pikokr\r\n* \r\n* Licensed under MIT License. Please see more defails in LICENSE file.\r\n*/\r\n\r\nimport 'reflect-metadata'\r\nexport * from './decoratorCreator'\r\nexport * from './ComponentArgument'\r\nexport * from './ComponentArgumentDecorator'\r\nexport * from './BaseComponent'\r\n","/*\r\n* File: errors.ts\r\n* \r\n* Copyright (c) 2022-2022 pikokr\r\n* \r\n* Licensed under MIT License. Please see more defails in LICENSE file.\r\n*/\r\n\r\nexport class OwnerOnlyError {}\n","/*\n * File: checks.ts\n *\n * Copyright (c) 2022-2022 pikokr\n *\n * Licensed under MIT License. Please see more defails in LICENSE file.\n */\n\nimport { BaseInteraction, Interaction, Message } from 'discord.js'\nimport { createComponentHook } from '../hooks'\nimport { ComponentHookFn } from '../hooks/componentHook'\nimport { CommandClient } from '../structures'\nimport { OwnerOnlyError } from './errors'\n\nexport const createCheckDecorator = (fn: ComponentHookFn) => createComponentHook('beforeCall', fn)\n\nexport const ownerOnly = createCheckDecorator(async (client: CommandClient, i: Interaction | Message) => {\n let isOwner = false\n\n if (i instanceof BaseInteraction) {\n client\n isOwner = await client.isOwner(i.user)\n } else if (i instanceof Message) {\n isOwner = await client.isOwner(i.author)\n }\n\n if (!isOwner) throw new OwnerOnlyError()\n})\n","export const mergeMethodDecorators = (decorators: MethodDecorator[]): MethodDecorator => {\n return (target, key, descriptor) => {\n for (const decorator of decorators) {\n decorator(target, key, descriptor)\n }\n }\n}\n","/*\r\n * File: index.ts\r\n *\r\n * Copyright (c) 2022-2022 pikokr\r\n *\r\n * Licensed under MIT License. Please see more defails in LICENSE file.\r\n */\r\n\r\nexport * from './checks'\r\nexport * from './errors'\r\nexport * from './decorators'\r\n","/*\r\n* File: index.ts\r\n* \r\n* Copyright (c) 2022-2022 pikokr\r\n* \r\n* Licensed under MIT License. Please see more defails in LICENSE file.\r\n*/\r\n\r\nexport * from './Extension'\n","/*\r\n* File: index.ts\r\n* \r\n* Copyright (c) 2022-2022 pikokr\r\n* \r\n* Licensed under MIT License. Please see more defails in LICENSE file.\r\n*/\r\n\r\nexport * from './components'\nexport * from './hooks'\nexport * from './converter'\nexport * from './utils'\nexport * from './listener'\nexport * from './structures'\nexport * from './extensions'\n","/*\r\n* File: index.ts\r\n* \r\n* Copyright (c) 2022-2022 pikokr\r\n* \r\n* Licensed under MIT License. Please see more defails in LICENSE file.\r\n*/\r\n\r\nexport * from './core'\r\nexport * from './applicationCommand'\r\nexport * from './textCommand'\r\n","import { APIApplicationCommandSubcommandOption, ApplicationCommandType, ChatInputApplicationCommandData } from 'discord.js'\nimport { createComponentDecorator } from '../core'\nimport { ApplicationCommandComponent } from './ApplicationCommand'\n\nexport class SubCommandGroup {\n constructor(public options: Omit<APIApplicationCommandSubcommandOption, 'type'>, public guilds?: string[]) {}\n\n command(options: Omit<ChatInputApplicationCommandData, 'options' | 'type'>): MethodDecorator {\n const cmd = new ApplicationCommandComponent({\n type: ApplicationCommandType.ChatInput,\n ...options,\n })\n cmd.subcommandGroup = this\n return createComponentDecorator(cmd)\n }\n\n createChild(options: Omit<APIApplicationCommandSubcommandOption, 'type'>) {\n return new SubCommandGroupChild(options, this)\n }\n}\n\nexport class SubCommandGroupChild {\n constructor(public options: Omit<APIApplicationCommandSubcommandOption, 'type'>, public parent: SubCommandGroup) {}\n\n command(options: Omit<ChatInputApplicationCommandData, 'options' | 'type'>): MethodDecorator {\n const cmd = new ApplicationCommandComponent({\n type: ApplicationCommandType.ChatInput,\n ...options,\n })\n cmd.subcommandGroupChild = this\n return createComponentDecorator(cmd)\n }\n}\n"],"mappings":"+pBAAA,oBAAA,8FCAA,GAQA,IAOa,GAWA,GA1Bb,uBAQA,GAA2B,sBAC3B,IAMO,AAAM,GAAwB,GAAC,EAAgB,IAAkD,CACtG,GAAI,GAAO,QAAQ,YAAY,GAAqB,EAAQ,CAAQ,EAEpE,MAAK,IACH,GAAO,GAAI,eACX,QAAQ,eAAe,GAAqB,EAAM,EAAQ,CAAQ,GAG7D,GAR4B,yBAWxB,GAAsB,GAAC,EAAc,IACzC,CAAC,EAAQ,IAAQ,CACtB,GAAM,GAAQ,GAAsB,EAAQ,CAAG,EAE3C,EAAQ,EAAM,IAAI,CAAI,EAE1B,AAAK,GACH,GAAQ,CAAA,EACR,EAAM,IAAI,EAAM,CAAK,GAGvB,EAAM,QAAQ,CAAE,GAXe,yBC1BnC,GAQA,IAUa,EAYA,GAMA,EAoBA,GAYA,EApEb,sBAQA,GAA2B,sBAE3B,KACA,IAOO,AAAM,EAAoB,EAAC,GAAmC,CACnE,GAAI,GAA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hooks/componentHook.ts","../src/core/components/decoratorCreator.ts","../src/core/components/ComponentArgument.ts","../src/core/components/ComponentArgumentDecorator.ts","../src/applicationCommand/ApplicationCommand.ts","../src/applicationCommand/ApplicationCommandOption.ts","../src/core/listener/index.ts","../src/core/converter/index.ts","../src/core/hooks/moduleHook.ts","../src/core/hooks/index.ts","../src/core/structures/Registry.ts","../src/core/structures/index.ts","../src/core/extensions/Extension.ts","../src/core/extensions/CTSExtension.ts","../src/applicationCommand/ApplicationCommandExtension.ts","../src/textCommand/TextCommand.ts","../src/textCommand/parameters.ts","../src/textCommand/TextCommandExtension.ts","../src/core/structures/CommandClient.ts","../src/core/components/BaseComponent.ts","../src/core/components/index.ts","../src/core/utils/errors.ts","../src/core/utils/checks.ts","../src/core/utils/decorators.ts","../src/core/utils/index.ts","../src/core/extensions/index.ts","../src/core/index.ts","../src/index.ts","../src/applicationCommand/index.ts","../src/applicationCommand/group.ts","../src/textCommand/index.ts"],"sourcesContent":["export const ComponentStoreSymbol = Symbol()\nexport const ComponentArgStoreSymbol = Symbol()\nexport const ModuleHookStoreSymbol = Symbol()\nexport const CommandClientSymbol = Symbol()\nexport const ComponentHookSymbol = Symbol()\nexport const FilePathSymbol = Symbol()\n","import { Collection } from 'discord.js'\nimport { ComponentHookSymbol } from '../symbols'\n\nexport type ComponentHookFn<T extends unknown[]> = (...args: T) => void | Promise<void>\n\nexport type ComponentHookStore = Collection<string, ComponentHookFn<unknown[]>[]>\n\nexport const getComponentHookStore = (target: object, property: string | symbol): ComponentHookStore => {\n let data = Reflect.getMetadata(ComponentHookSymbol, target, property) as ComponentHookStore\n\n if (!data) {\n data = new Collection()\n Reflect.defineMetadata(ComponentHookSymbol, data, target, property)\n }\n\n return data\n}\n\nexport const createComponentHook = <T extends unknown[]>(name: string, fn: ComponentHookFn<T>): MethodDecorator => {\n return (target, key) => {\n const store = getComponentHookStore(target, key)\n\n let hooks = store.get(name)\n\n if (!hooks) {\n hooks = []\n store.set(name, hooks)\n }\n\n // @ts-expect-error unknown type\n hooks.unshift(fn)\n }\n}\n","import { Collection } from 'discord.js'\nimport type { ComponentHookStore } from '../hooks'\nimport { getComponentHookStore } from '../hooks/componentHook'\nimport { ComponentStoreSymbol } from '../symbols'\nimport type { BaseComponent } from './BaseComponent'\nimport type { ComponentArgumentDecorator } from './ComponentArgumentDecorator'\n\nexport type ComponentStore = Collection<string | symbol, BaseComponent>\nexport type ComponentArgumentStore = Collection<number, ComponentArgumentDecorator>\n\nexport const getComponentStore = (target: object): ComponentStore => {\n let result: ComponentStore | null = Reflect.getMetadata(ComponentStoreSymbol, target)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ComponentStoreSymbol, result, target)\n }\n\n return result\n}\n\nexport const getComponent = (target: object, key: string | symbol) => {\n const store = getComponentStore(target)\n\n return store.get(key)\n}\n\nexport const createComponentDecorator = (component: BaseComponent): MethodDecorator => {\n return (target, key) => {\n component._init(Reflect.get(target, key), Reflect.getMetadata('design:paramtypes', target, key))\n\n const componentHookStore: ComponentHookStore = getComponentHookStore(target, key)\n\n component.hooks = componentHookStore\n\n const store = getComponentStore(target)\n\n const decorators = getComponentArgumentStore(target, key)\n\n decorators.forEach((x, i) => {\n component.argTypes.get(i)?.decorators.push(x)\n })\n\n store.set(key, component)\n }\n}\n\nexport const getComponentArgumentStore = (target: object, key: string | symbol): ComponentArgumentStore => {\n let result: ComponentArgumentStore | null = Reflect.getMetadata(ComponentStoreSymbol, target, key)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ComponentStoreSymbol, result, target, key)\n }\n\n return result\n}\n\nexport const createArgumentDecorator = <Options>(type: typeof ComponentArgumentDecorator<Options>) => {\n return (options: Options): ParameterDecorator => {\n return (target, key, idx) => {\n const arg: ComponentArgumentDecorator<Options> = new type(options)\n\n const store = getComponentArgumentStore(target, key)\n\n store.set(idx, arg)\n }\n }\n}\n","import type { ComponentArgumentDecorator } from './ComponentArgumentDecorator'\n\nexport class ComponentArgument {\n decorators: ComponentArgumentDecorator[] = []\n\n constructor(public type: unknown) {}\n}\n","import _ from 'lodash'\n\nexport class ComponentArgumentDecorator<Options = unknown> {\n options: Options\n\n constructor(options: Partial<Options>) {\n if (typeof options === 'object') {\n this.options = _.merge(this.defaultOptions(), options)\n } else {\n this.options = options\n }\n }\n\n defaultOptions(): Options {\n return {} as unknown as Options\n }\n}\n","import type { ApplicationCommandType, ChatInputApplicationCommandData, MessageApplicationCommandData, Snowflake, UserApplicationCommandData } from 'discord.js'\nimport { createComponentDecorator } from '../core/components/decoratorCreator'\nimport { BaseComponent } from '../core/components/BaseComponent'\nimport type { SubCommandGroup, SubCommandGroupChild } from './group'\n\ntype Options = (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {\n type: ApplicationCommandType\n guilds?: Snowflake[]\n}\n\nexport class ApplicationCommandComponent extends BaseComponent {\n options: Options\n\n subcommandGroup?: SubCommandGroup\n subcommandGroupChild?: SubCommandGroupChild\n\n constructor(options: UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) {\n super()\n\n this.options = options as Options\n }\n}\n\nexport const applicationCommand = (options: Options) => createComponentDecorator(new ApplicationCommandComponent(options))\n\nexport type { Options as ApplicationCommandComponentOptions }\n","import type { APIApplicationCommandOption } from 'discord.js'\nimport { createArgumentDecorator, ComponentArgumentDecorator } from '../core'\n\ntype Options = APIApplicationCommandOption\n\nexport class ApplicationCommandOption extends ComponentArgumentDecorator<Options> {}\n\nexport const option = createArgumentDecorator(ApplicationCommandOption)\n","import _ from 'lodash'\nimport { BaseComponent } from '../components/BaseComponent'\nimport { createComponentDecorator } from '../components/decoratorCreator'\n\ntype Options = { emitter: string; event: string }\n\ntype OptionsArg = { emitter?: string; event: string }\n\nexport class ListenerComponent extends BaseComponent {\n options: Options\n\n constructor(options: OptionsArg) {\n super()\n\n this.options = _.merge({ emitter: 'discord' }, options)\n }\n}\n\nexport const listener = (options: OptionsArg) => createComponentDecorator(new ListenerComponent(options))\n\nexport { Options as ListenerOptions, OptionsArg as ListenerOptionsArg }\n","import { BaseComponent } from '../components/BaseComponent'\nimport { createComponentDecorator } from '../components/decoratorCreator'\n\ntype Options<T> = { component: unknown; type: T; parameterless: boolean }\n\ntype OptionsArg<T> = Omit<Options<T>, 'parameterless'> & { parameterless?: boolean }\n\nexport class ConverterComponent<T> extends BaseComponent {\n options: Options<T>\n\n constructor(options: OptionsArg<T>) {\n super()\n this.options = options as Options<T>\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const argConverter = <T>(options: OptionsArg<T>) => createComponentDecorator(new ConverterComponent(options))\n\nexport { Options as ArgumentConvertOptions, OptionsArg as ArgumentConvertOptionsArg }\n","import { Collection } from 'discord.js'\nimport { ModuleHookStoreSymbol } from '../symbols'\nimport type { ComponentHookFn } from './componentHook'\n\nexport type ModuleHookStore = Collection<string, ComponentHookFn<unknown[]>[]>\n\nexport const getModuleHookStore = (target: object) => {\n let result: ModuleHookStore | null = Reflect.getMetadata(ModuleHookStoreSymbol, target)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ModuleHookStoreSymbol, result, target)\n }\n\n return result\n}\n\nexport const moduleHook = (name: string): MethodDecorator => {\n return (target, key) => {\n const store = getModuleHookStore(target)\n\n let v = store.get(name)\n\n if (!v) {\n v = []\n store.set(name, v)\n }\n\n v.push(Reflect.get(target, key))\n }\n}\n","export * from './moduleHook'\nexport { createComponentHook, type ComponentHookFn } from './componentHook'\nexport type { ComponentHookStore } from './componentHook'\n","import chalk from 'chalk'\nimport { Collection } from 'discord.js'\nimport type EventEmitter from 'events'\nimport _ from 'lodash'\nimport type { Logger } from 'tslog'\nimport { getComponentStore } from '../components'\nimport { getModuleHookStore } from '../hooks'\nimport { ListenerComponent } from '../listener'\nimport { CommandClientSymbol, FilePathSymbol } from '../symbols'\nimport type { CommandClient } from './CommandClient'\nimport walkSync from 'walk-sync'\nimport path from 'path'\nimport type { ComponentHookFn } from '../hooks/componentHook'\n\nexport class Registry {\n extensions: object[] = []\n\n emitters: Collection<string, EventEmitter> = new Collection()\n\n logger: Logger<unknown>\n\n globalHooks: Record<string, ComponentHookFn<unknown[]>[]> = {}\n\n constructor(logger: Logger<unknown>, public client: CommandClient) {\n this.logger = logger.getSubLogger({\n name: chalk.green('Registry'),\n })\n }\n\n addGlobalHook(name: string, fn: ComponentHookFn<unknown[]>) {\n let hooks = this.globalHooks[name]\n\n if (!hooks) {\n hooks = []\n this.globalHooks[name] = hooks\n }\n\n hooks.push(fn)\n }\n\n getComponentsWithTypeGlobal<T>(type: unknown): T[] {\n const result: T[] = []\n\n for (const ext of this.extensions) {\n result.push(...this.getComponentsWithType<T>(ext, type))\n }\n\n return result\n }\n\n getComponentsWithType<T>(ext: object, type: unknown): T[] {\n const componentStore = getComponentStore(ext)\n\n return Array.from(componentStore.filter((x) => (x.constructor as unknown) === type).values() as Iterable<T>)\n }\n\n registerEventListeners(ext: object) {\n const listeners = this.getComponentsWithType<ListenerComponent>(ext, ListenerComponent)\n\n for (const listener of listeners) {\n const emitter = this.emitters.get(listener.options.emitter)\n\n if (emitter) {\n const bound = listener.method.bind(ext)\n\n Reflect.defineMetadata('bound', bound, listener)\n\n emitter.addListener(listener.options.event, bound)\n }\n }\n }\n\n unregisterEventListeners(ext: object) {\n const listeners = this.getComponentsWithType<ListenerComponent>(ext, ListenerComponent)\n\n for (const listener of listeners) {\n const emitter = this.emitters.get(listener.options.emitter)\n const bound = Reflect.getMetadata('bound', listener)\n\n if (emitter && bound) {\n emitter.removeListener(listener.options.event, bound)\n }\n }\n }\n\n async loadAllModulesInDirectory(dir: string, pattern?: RegExp): Promise<object[]> {\n const results: object[] = []\n\n const files = walkSync(dir).filter((x) => (x.endsWith('.ts') || x.endsWith('.js')) && (!pattern || pattern.test(x)))\n\n for (const file of files) {\n if (file.endsWith('.d.ts')) continue\n const p = path.join(dir, file)\n results.push(...(await this.loadModulesAtPath(p)))\n }\n\n return results\n }\n\n async loadModulesAtPath(file: string) {\n this.logger.info(`Loading module at path ${chalk.green(file)}`)\n\n const p = require.resolve(file)\n\n const mod = await import(p)\n\n if (typeof mod.setup !== 'function') throw new Error('Extension must have a setup function')\n\n const modules = await mod.setup(this.client)\n\n return this.registerModules(modules, p)\n }\n\n private async registerModules(modules: object | object[], p: string) {\n const results: object[] = []\n if (modules instanceof Array) {\n for (const module of modules) {\n await this.registerModule(module)\n Reflect.defineMetadata(FilePathSymbol, p, module)\n results.push(module)\n }\n } else {\n await this.registerModule(modules)\n Reflect.defineMetadata(FilePathSymbol, p, modules)\n results.push(modules)\n }\n\n return results\n }\n\n async reloadModules() {\n const result: { file: string; result: boolean; error?: Error; extensions?: object[] }[] = []\n const paths = new Set<string>()\n const extensions = [...this.extensions]\n for (const module of extensions) {\n const file = Reflect.getMetadata(FilePathSymbol, module)\n if (!file) continue\n\n this.logger.info(`Unloading module: ${chalk.green(module.constructor.name)}`)\n\n paths.add(file)\n\n await this.unregisterModule(module)\n\n delete require.cache[require.resolve(file)]\n }\n\n for (const path of paths) {\n try {\n const extensions = await this.loadModulesAtPath(path)\n\n result.push({\n file: path,\n result: true,\n extensions,\n })\n } catch (e) {\n result.push({\n file: path,\n result: false,\n error: e as Error,\n })\n }\n }\n\n return result\n }\n\n async registerModule(ext: object) {\n Reflect.defineMetadata(CommandClientSymbol, this.client, ext)\n\n this.registerEventListeners(ext)\n await this.runModuleHook(ext, 'load')\n this.extensions.push(ext)\n this.logger.info(`Module registered: ${chalk.green(ext.constructor.name)}`)\n }\n\n async unregisterModule(ext: object) {\n this.unregisterEventListeners(ext)\n await this.runModuleHook(ext, 'unload')\n _.remove(this.extensions, (x) => x === ext)\n this.logger.info(`Module unregistered: ${chalk.green(ext.constructor.name)}`)\n }\n\n runModuleHook(ext: object, hookName: string, ...args: unknown[]) {\n const hooks = getModuleHookStore(ext)\n\n const functions = hooks.get(hookName)\n\n if (functions) {\n for (const fn of functions) {\n fn.call(ext, ...args)\n }\n }\n }\n\n registerEventEmitter(name: string, emitter: EventEmitter) {\n this.emitters.set(name, emitter)\n }\n}\n","export * from './Registry'\nexport * from './CommandClient'\n","import chalk from 'chalk'\nimport { Collection } from 'discord.js'\nimport type { Logger } from 'tslog'\nimport type { ComponentArgument } from '../components/ComponentArgument'\nimport { ConverterComponent } from '../converter'\nimport { CommandClient } from '../structures'\n\nexport class Extension {\n protected get commandClient() {\n return CommandClient.getFromModule(this)\n }\n\n protected get client() {\n return this.commandClient.discord\n }\n\n protected _logger?: Logger<unknown>\n\n protected get logger() {\n if (!this._logger) this._logger = this.commandClient.logger.getSubLogger({ name: chalk.green(`${this.constructor.name}`) })\n return this._logger\n }\n\n protected async convertArguments(\n component: unknown,\n argList: unknown[],\n args: Collection<number, ComponentArgument>,\n getConverterArgs: (arg: ComponentArgument, index: number, converter: ConverterComponent<unknown>) => unknown[] | Promise<unknown[]>,\n ) {\n const items = new Collection<unknown, { ext: object; component: ConverterComponent<unknown> }>()\n\n for (const extension of this.commandClient.registry.extensions) {\n for (const converter of this.commandClient.registry.getComponentsWithType<ConverterComponent<unknown>>(extension, ConverterComponent)) {\n if (converter.options.component != component) continue\n\n items.set(converter.options.type, { component: converter, ext: extension })\n }\n }\n\n for (const [index, arg] of args) {\n const converter = items.get(arg.type)\n\n if (!converter) {\n argList[index] = undefined\n continue\n }\n\n const converterArgs = await getConverterArgs(arg, index, converter.component)\n\n argList[index] = await converter.component.execute(converter.ext, converterArgs)\n }\n }\n}\n","import chalk from 'chalk'\nimport { Extension } from './Extension'\n\nexport class CTSExtension extends Extension {\n protected get logger() {\n if (!this._logger) this._logger = this.commandClient.ctsLogger.getSubLogger({ name: chalk.green(`${this.constructor.name}`) })\n return this._logger\n }\n}\n","import chalk from 'chalk'\nimport type {\n APIApplicationCommandSubcommandGroupOption,\n APIApplicationCommandSubcommandOption,\n ApplicationCommandData,\n ApplicationCommandSubCommandData,\n ChatInputApplicationCommandData,\n Interaction,\n Snowflake,\n} from 'discord.js'\nimport {\n ApplicationCommandOptionType,\n ApplicationCommandType,\n ChatInputCommandInteraction,\n Collection,\n CommandInteraction,\n InteractionType,\n MessageContextMenuCommandInteraction,\n UserContextMenuCommandInteraction,\n} from 'discord.js'\nimport { ApplicationCommandComponent } from './ApplicationCommand'\nimport { ApplicationCommandOption } from './ApplicationCommandOption'\nimport { listener } from '../core/listener'\nimport { argConverter } from '../core/converter'\nimport { CTSExtension } from '../core/extensions/CTSExtension'\n\nexport type ApplicationCommandExtensionConfig = {\n guilds?: Snowflake[]\n}\n\nexport class ApplicationCommandExtension extends CTSExtension {\n constructor(public config: ApplicationCommandExtensionConfig) {\n super()\n }\n\n unmanagedCommands: (ApplicationCommandData & { guilds?: Snowflake[] })[] = []\n\n registerUnmanagedCommand(command: ApplicationCommandData & { guilds?: Snowflake[] }) {\n this.unmanagedCommands.push(command)\n }\n\n @listener({ event: 'interactionCreate' })\n async interactionCreate(i: Interaction) {\n try {\n if (i.type !== InteractionType.ApplicationCommand) return\n\n let cmd: ApplicationCommandComponent | null = null\n let ext: object | null = null\n\n const extensions = this.commandClient.registry.extensions\n\n let subcommand: string | null = null\n let subcommandGroup: string | null = null\n\n if (i.commandType === ApplicationCommandType.ChatInput) {\n subcommand = i.options.getSubcommand(false)\n subcommandGroup = i.options.getSubcommandGroup(false)\n }\n\n extLoop: for (const extension of extensions) {\n const components = this.commandClient.registry.getComponentsWithType<ApplicationCommandComponent>(extension, ApplicationCommandComponent)\n\n if (subcommand) {\n for (const command of components) {\n if (!command.subcommandGroup && !command.subcommandGroupChild) continue\n\n if (\n command.subcommandGroupChild &&\n command.subcommandGroupChild.parent.options.name === i.commandName &&\n command.subcommandGroupChild.options.name === subcommandGroup &&\n command.options.name === subcommand\n ) {\n ext = extension\n cmd = command\n break extLoop\n }\n if (command.subcommandGroup && !subcommandGroup && command.subcommandGroup.options.name === i.commandName && command.options.name === subcommand) {\n ext = extension\n cmd = command\n break extLoop\n }\n }\n } else {\n for (const command of components) {\n if (command.options.name === i.commandName) {\n ext = extension\n cmd = command\n break extLoop\n }\n }\n }\n }\n\n if (cmd && ext) {\n const argList: unknown[] = []\n\n await this.convertArguments(ApplicationCommandComponent, argList, cmd.argTypes, () => [i])\n\n for (const [idx, arg] of cmd.argTypes) {\n let value: unknown = null\n\n for (const decorator of arg.decorators) {\n if (decorator instanceof ApplicationCommandOption) {\n if ([ApplicationCommandOptionType.Subcommand, ApplicationCommandOptionType.SubcommandGroup].includes(decorator.options.type) && i.isChatInputCommand()) {\n if (decorator.options.type === ApplicationCommandOptionType.Subcommand) {\n value = i.options.getSubcommand() === decorator.options.name\n break\n }\n if (decorator.options.type === ApplicationCommandOptionType.SubcommandGroup) {\n value = i.options.getSubcommandGroup() === decorator.options.name\n break\n }\n }\n\n value = i.options.get(decorator.options.name, false)?.value\n break\n }\n }\n\n if (value) {\n argList[idx] = value\n }\n }\n\n try {\n await cmd.executeGlobalHook(ext, 'beforeApplicationCommandCall', [i])\n await cmd.execute(ext, argList, [i])\n } finally {\n await cmd.executeGlobalHook(ext, 'afterApplicationCommandCall', [i])\n }\n }\n } catch (e) {\n this.commandClient.emit('applicationCommandInvokeError', e, i)\n }\n }\n\n async sync() {\n const client = this.commandClient\n\n this.logger.info('Trying to sync commands...')\n\n let commands: ApplicationCommandData[] = []\n\n const guildCommands = new Collection<Snowflake, ApplicationCommandData[]>()\n\n const subcommandGroups = new Collection<string, ChatInputApplicationCommandData>()\n\n for (const command of client.registry.getComponentsWithTypeGlobal<ApplicationCommandComponent>(ApplicationCommandComponent)) {\n if (command.subcommandGroup) {\n let group = subcommandGroups.get(command.subcommandGroup.options.name)\n\n if (!group) {\n group = {\n ...command.subcommandGroup.options,\n type: ApplicationCommandType.ChatInput,\n }\n\n if (command.subcommandGroup.guilds) {\n for (const guild of command.subcommandGroup.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n }\n } else {\n commands.push(group)\n }\n\n subcommandGroups.set(command.subcommandGroup.options.name, group)\n }\n\n if (!group.options) group.options = []\n\n const options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n options.push(option.options)\n }\n }\n\n group.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as ApplicationCommandSubCommandData)\n\n continue\n } else if (command.subcommandGroupChild) {\n const parent = command.subcommandGroupChild.parent\n let group = subcommandGroups.get(parent.options.name)\n\n if (!group) {\n group = {\n ...parent.options,\n type: ApplicationCommandType.ChatInput,\n }\n\n if (parent.guilds) {\n for (const guild of parent.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n }\n } else {\n commands.push(group)\n }\n\n subcommandGroups.set(parent.options.name, group)\n }\n\n if (!group.options) group.options = []\n\n let child = group.options.find((x) => x.name === command.subcommandGroupChild?.options.name) as APIApplicationCommandSubcommandGroupOption | undefined\n\n if (!child) {\n child = { type: ApplicationCommandOptionType.SubcommandGroup, ...(command.subcommandGroupChild.options as Omit<APIApplicationCommandSubcommandGroupOption, 'type'>) }\n group.options.push(child)\n }\n\n if (!child.options) child.options = []\n\n const options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n options.push(option.options)\n }\n }\n\n child.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as APIApplicationCommandSubcommandOption)\n\n continue\n }\n\n const cmd: ApplicationCommandData = { ...command.options }\n\n if (cmd.type === ApplicationCommandType.ChatInput) {\n cmd.options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n cmd.options.push(option.options)\n }\n }\n }\n\n await command.executeHook(this, 'beforeSync', [cmd, command])\n\n if (command.options.guilds) {\n for (const guild of command.options.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n commands.push(cmd)\n }\n continue\n }\n\n commands.push(cmd)\n }\n\n for (const { guilds, ...rest } of this.unmanagedCommands) {\n if (guilds) {\n for (const guild of guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n commands.push(rest)\n }\n continue\n } else {\n commands.push(rest)\n }\n }\n\n if (this.config.guilds) {\n for (const guild of this.config.guilds) {\n let g = guildCommands.get(guild)\n if (!g) {\n g = []\n guildCommands.set(guild, g)\n }\n g.push(...commands)\n }\n\n commands = []\n }\n\n if (guildCommands.size) {\n for (const [guild, commands] of guildCommands) {\n try {\n const g = await this.client.guilds.fetch(guild)\n await g.fetch()\n this.logger.info(\n `Processing ${chalk.green(commands.length)} commands(${commands.map((x) => chalk.blue(x.name)).join(', ')}) for guild ${chalk.green(g.name)}(${chalk.blue(g.id)})`,\n )\n\n await g.commands.set(commands)\n\n this.logger.info(`Successfully registered commands for guild ${chalk.green(g.name)}(${chalk.blue(g.id)})`)\n } catch (e) {\n this.logger.error(`Failed to register commands to guild ${chalk.green(guild)}: ${(e as Error).message}`)\n }\n }\n }\n if (commands.length) {\n try {\n this.logger.info(`Processing ${chalk.green(commands.length)} commands(${commands.map((x) => chalk.blue(x.name)).join(', ')}) for application scope...`)\n\n if (this.client.application) {\n await this.client.application.commands.set(commands)\n\n this.logger.info('Successfully registered commands.')\n } else {\n this.logger.error('Client#application is not yet initialized.')\n }\n } catch (e) {\n this.logger.error(`Failed to register commands to global: ${(e as Error).message}`)\n }\n }\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: ChatInputCommandInteraction,\n })\n async chatInteraction(i: ChatInputCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: MessageContextMenuCommandInteraction,\n })\n async messageInteraction(i: MessageContextMenuCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: UserContextMenuCommandInteraction,\n })\n async userInteraction(i: UserContextMenuCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: CommandInteraction,\n })\n async commandInteraction(i: UserContextMenuCommandInteraction) {\n return i\n }\n}\n","import { createComponentDecorator } from '../core/components/decoratorCreator'\nimport { BaseComponent } from '../core/components/BaseComponent'\n\nexport type TextCommandOptions = {\n name: string\n aliases?: string[]\n description?: string\n}\n\nexport class TextCommandComponent extends BaseComponent {\n constructor(public options: TextCommandOptions) {\n super()\n }\n}\n\nexport const command = (options: TextCommandOptions) => createComponentDecorator(new TextCommandComponent(options))\n","import { ComponentArgumentDecorator } from '../core'\nimport { createArgumentDecorator } from '../core'\n\nexport class TextCommandRestOption extends ComponentArgumentDecorator<void> {}\n\nexport const rest = createArgumentDecorator(TextCommandRestOption)\n","import { listener } from '../core/listener'\nimport { Message } from 'discord.js'\nimport { CTSExtension } from '../core/extensions/CTSExtension'\nimport { TextCommandComponent } from './TextCommand'\nimport { TextCommandRestOption } from './parameters'\nimport { argConverter } from '../core'\n\nexport type TextCommandConfig = {\n prefix: string | string[] | ((msg: Message) => Promise<string | string[]> | string | string[])\n}\n\ndeclare module 'discord.js' {\n interface Message {\n command: TextCommandComponent\n }\n}\n\nexport class TextCommandExtension extends CTSExtension {\n constructor(private config: TextCommandConfig) {\n super()\n }\n\n private async processPrefix(msg: Message): Promise<number | null> {\n const content = msg.content\n let prefix = this.config.prefix\n\n if (typeof prefix === 'function') {\n prefix = await prefix(msg)\n }\n\n if (typeof prefix === 'string') {\n if (content.startsWith(prefix)) return prefix.length\n return null\n }\n\n if (prefix instanceof Array) {\n const p = prefix.find((x) => content.startsWith(x))\n\n if (p) return p.length\n return null\n }\n\n return null\n }\n\n @listener({ event: 'messageCreate', emitter: 'discord' })\n private async messageCreate(msg: Message) {\n try {\n const startIndex = await this.processPrefix(msg)\n\n if (startIndex === null) return\n\n const content = msg.content.slice(startIndex)\n\n const commands: TextCommandComponent[] = []\n\n const extensions = new Map<TextCommandComponent, object>()\n\n for (const ext of this.commandClient.registry.extensions) {\n for (const cmd of this.commandClient.registry.getComponentsWithType<TextCommandComponent>(ext, TextCommandComponent)) {\n commands.push(cmd)\n extensions.set(cmd, ext)\n }\n }\n\n let commandNameLength = 0\n\n const command = commands.find((x) => {\n const names = [x.options.name]\n\n if (x.options.aliases) {\n names.push(...x.options.aliases)\n }\n\n for (const name of names) {\n if (content.startsWith(name)) {\n if (content.length === name.length) {\n commandNameLength = name.length\n return true\n }\n commandNameLength = name.length\n return content.startsWith(name + ' ')\n }\n }\n\n return false\n })\n\n if (!command) return\n\n const ext = extensions.get(command)\n\n if (!ext) return\n\n msg.command = command\n\n const args: unknown[] = []\n\n let argStrings = content.slice(commandNameLength + 1).split(/ /g)\n\n await this.convertArguments(TextCommandComponent, args, command.argTypes, async (arg, i, converter) => {\n if (converter.options.parameterless) return [msg]\n\n if (arg.decorators.find((x) => x.constructor === TextCommandRestOption)) {\n const text = argStrings.join(' ')\n argStrings = []\n return [text, msg]\n }\n return [argStrings.shift(), msg]\n })\n\n await command.execute(ext, args, [msg])\n } catch (e) {\n this.commandClient.emit('textCommandInvokeError', e, msg)\n }\n }\n\n @argConverter({\n component: TextCommandComponent,\n type: Message,\n parameterless: true,\n })\n async mesage(msg: Message) {\n return msg\n }\n\n @argConverter({ component: TextCommandComponent, type: String })\n async str(value: string) {\n return value\n }\n\n @argConverter({ component: TextCommandComponent, type: Number })\n async num(value: string) {\n return Number(value)\n }\n}\n","import chalk from 'chalk'\nimport type { Client, Snowflake } from 'discord.js'\nimport { Team, User } from 'discord.js'\nimport EventEmitter from 'events'\nimport type { ISettingsParam } from 'tslog'\nimport { Logger } from 'tslog'\nimport type { ApplicationCommandExtensionConfig } from '../../applicationCommand/ApplicationCommandExtension'\nimport { ApplicationCommandExtension } from '../../applicationCommand/ApplicationCommandExtension'\nimport type { TextCommandConfig } from '../../textCommand'\nimport { TextCommandExtension } from '../../textCommand/TextCommandExtension'\nimport { CommandClientSymbol } from '../symbols'\nimport { Registry } from './Registry'\nexport class CommandClient extends EventEmitter {\n ctsLogger: Logger<unknown>\n registry: Registry\n\n owners: Set<Snowflake> = new Set()\n\n constructor(public discord: Client, public logger: Logger<unknown> = new Logger({ prettyLogTimeZone: 'local' }), loggerOptions: ISettingsParam<unknown> = {}) {\n super()\n\n this.ctsLogger = logger.getSubLogger({\n ...loggerOptions,\n name: 'command.ts',\n })\n\n this.registry = new Registry(this.ctsLogger, this)\n\n this.registry.registerEventEmitter('cts', this)\n this.registry.registerEventEmitter('discord', this.discord)\n }\n\n async isOwner(user: User): Promise<boolean> {\n return this.owners.has(user.id)\n }\n\n async fetchOwners() {\n if (!this.discord.application) throw new Error('The client is not logged in.')\n\n this.ctsLogger.info('Fetching owners...')\n\n await this.discord.application.fetch()\n\n const owner = this.discord.application.owner\n\n if (!owner) throw new Error('Cannot find application owner')\n\n const owners: string[] = []\n\n if (owner instanceof User) {\n this.owners.add(owner.id)\n owners.push(owner.tag)\n } else if (owner instanceof Team) {\n for (const [id, member] of owner.members) {\n this.owners.add(id)\n owners.push(member.user.tag)\n }\n }\n\n this.ctsLogger.info(`Fetched ${chalk.green(owners.length)} owners(${owners.map((x) => chalk.blue(x)).join(', ')})`)\n }\n\n async enableApplicationCommandsExtension(config: ApplicationCommandExtensionConfig) {\n await this.registry.registerModule(new ApplicationCommandExtension(config))\n this.ctsLogger.info('Application command extension enabled.')\n }\n\n async enableTextCommandsExtension(config: TextCommandConfig) {\n await this.registry.registerModule(new TextCommandExtension(config))\n this.ctsLogger.info('Text command extension enabled.')\n }\n\n getApplicationCommandsExtension() {\n return this.registry.extensions.find((x) => x.constructor === ApplicationCommandExtension) as ApplicationCommandExtension | undefined\n }\n\n static getFromModule(ext: object): CommandClient {\n return Reflect.getMetadata(CommandClientSymbol, ext)\n }\n}\n","import { Collection } from 'discord.js'\nimport type { AnyFunction } from '../../utils/types'\nimport type { ComponentHookStore } from '../hooks'\nimport { ComponentArgument } from './ComponentArgument'\n\nexport class BaseComponent {\n method!: AnyFunction\n\n hooks: ComponentHookStore = new Collection()\n\n argTypes: Collection<number, ComponentArgument> = new Collection()\n\n _init(method: AnyFunction, argTypes: unknown[]) {\n this.method = method\n for (let i = 0; i < argTypes.length; i++) {\n const element = argTypes[i]\n this.argTypes.set(i, new ComponentArgument(element))\n }\n }\n\n async executeGlobalHook(target: object, name: string, args: unknown[]) {\n const { CommandClient } = await import('../structures/CommandClient')\n\n const client = CommandClient.getFromModule(target)\n\n const globalHooks = client.registry.globalHooks[name]\n\n if (globalHooks) {\n for (const fn of globalHooks) {\n await fn.call(null, client, ...args)\n }\n }\n }\n\n async executeHook(target: object, name: string, args: unknown[]) {\n const hook = this.hooks.get(name)\n\n if (!hook) return\n\n const { CommandClient } = await import('../structures/CommandClient')\n\n const client = CommandClient.getFromModule(target)\n\n const globalHooks = client.registry.globalHooks[name]\n\n if (globalHooks) {\n hook.unshift(...globalHooks)\n }\n\n for (const fn of hook) {\n await fn.call(null, client, ...args)\n }\n }\n\n async execute(target: object, args: unknown[], beforeCallArgs: unknown[] = args) {\n await this.executeHook(target, 'beforeCall', beforeCallArgs)\n let result\n try {\n result = await this.method.call(target, ...args)\n await this.executeHook(target, 'afterCall', [...beforeCallArgs, result])\n } catch (e) {\n await this.executeHook(target, 'invokeError', [e, ...beforeCallArgs])\n throw e\n }\n\n return result\n }\n}\n","import 'reflect-metadata'\nexport * from './decoratorCreator'\nexport * from './ComponentArgument'\nexport * from './ComponentArgumentDecorator'\nexport * from './BaseComponent'\n","export class OwnerOnlyError {}\n","import type { Interaction } from 'discord.js'\nimport { BaseInteraction, Message } from 'discord.js'\nimport { createComponentHook } from '../hooks'\nimport type { ComponentHookFn } from '../hooks/componentHook'\nimport type { CommandClient } from '../structures'\nimport { OwnerOnlyError } from './errors'\n\nexport const createCheckDecorator = (fn: ComponentHookFn<[CommandClient, Interaction | Message]>) => createComponentHook('beforeCall', fn)\n\nexport const ownerOnly = createCheckDecorator(async (client: CommandClient, i: Interaction | Message) => {\n let isOwner = false\n\n if (i instanceof BaseInteraction) {\n client\n isOwner = await client.isOwner(i.user)\n } else if (i instanceof Message) {\n isOwner = await client.isOwner(i.author)\n }\n\n if (!isOwner) throw new OwnerOnlyError()\n})\n","export const mergeMethodDecorators = (decorators: MethodDecorator[]): MethodDecorator => {\n return (target, key, descriptor) => {\n for (const decorator of decorators) {\n decorator(target, key, descriptor)\n }\n }\n}\n","export * from './checks'\nexport * from './errors'\nexport * from './decorators'\n","export * from './Extension'\n","export * from './components'\nexport * from './hooks'\nexport * from './converter'\nexport * from './utils'\nexport * from './listener'\nexport * from './structures'\nexport * from './extensions'\n","export * from './core'\nexport * from './applicationCommand'\nexport * from './textCommand'\n","export * from './ApplicationCommand'\nexport { option } from './ApplicationCommandOption'\nexport * from './group'\nexport * from './ApplicationCommandExtension'\n","import type { APIApplicationCommandSubcommandOption, ChatInputApplicationCommandData } from 'discord.js'\nimport { ApplicationCommandType } from 'discord.js'\nimport { createComponentDecorator } from '../core'\nimport { ApplicationCommandComponent } from './ApplicationCommand'\n\nexport class SubCommandGroup {\n constructor(public options: Omit<APIApplicationCommandSubcommandOption, 'type'>, public guilds?: string[]) {}\n\n command(options: Omit<ChatInputApplicationCommandData, 'options' | 'type'>): MethodDecorator {\n const cmd = new ApplicationCommandComponent({\n type: ApplicationCommandType.ChatInput,\n ...options,\n })\n cmd.subcommandGroup = this\n return createComponentDecorator(cmd)\n }\n\n createChild(options: Omit<APIApplicationCommandSubcommandOption, 'type'>) {\n return new SubCommandGroupChild(options, this)\n }\n}\n\nexport class SubCommandGroupChild {\n constructor(public options: Omit<APIApplicationCommandSubcommandOption, 'type'>, public parent: SubCommandGroup) {}\n\n command(options: Omit<ChatInputApplicationCommandData, 'options' | 'type'>): MethodDecorator {\n const cmd = new ApplicationCommandComponent({\n type: ApplicationCommandType.ChatInput,\n ...options,\n })\n cmd.subcommandGroupChild = this\n return createComponentDecorator(cmd)\n }\n}\n","export * from './TextCommand'\nexport type { TextCommandConfig } from './TextCommandExtension'\nexport * from './parameters'\n"],"mappings":"+pBAAA,IAAaA,EACAC,GACAC,GACAC,EACAC,GACAC,GALbC,EAAAC,EAAA,kBAAaP,EAAuBQ,OAAM,EAC7BP,GAA0BO,OAAM,EAChCN,GAAwBM,OAAM,EAC9BL,EAAsBK,OAAM,EAC5BJ,GAAsBI,OAAM,EAC5BH,GAAiBG,OAAM,ICLpC,IAAAC,GAOaC,GAWAC,GAlBbC,GAAAC,EAAA,kBAAAJ,GAA2B,sBAC3BK,IAMaJ,GAAwBK,EAAA,CAACC,EAAgBC,IAAkD,CACtG,IAAIC,EAAOC,QAAQC,YAAYC,GAAqBL,EAAQC,CAAQ,EAEpE,OAAKC,IACHA,EAAO,IAAII,cACXH,QAAQI,eAAeF,GAAqBH,EAAMF,EAAQC,CAAQ,GAG7DC,GAR4B,yBAWxBP,GAAsBI,EAAA,CAAsBS,EAAcC,IAC9D,CAACT,EAAQU,IAAQ,CACtB,IAAMC,EAAQjB,GAAsBM,EAAQU,CAAG,EAE3CE,EAAQD,EAAME,IAAIL,CAAI,EAErBI,IACHA,EAAQ,CAAA,EACRD,EAAMG,IAAIN,EAAMI,CAAK,GAIvBA,EAAMG,QAAQN,CAAE,GAZe,yBClBnC,IAAAO,GAUaC,EAYAC,GAMAC,EAoBAC,GAYAC,EA5DbC,EAAAC,EAAA,kBAAAP,GAA2B,sBAE3BQ,KACAC,IAOaR,EAAoBS,EAACC,GAAmC,CACnE,IAAIC,EAAgCC,QAAQC,YAAYC,EAAsBJ,CAAM,EAEpF,OAAKC,IACHA,EAAS,IAAII,cAEbH,QAAQI,eAAeF,EAAsBH,EAAQD,CAAM,GAGtDC,GATwB,qBAYpBV,GAAeQ,EAAA,CAACC,EAAgBO,IAC7BjB,EAAkBU,CAAM,EAEzBQ,IAAID,CAAG,EAHM,gBAMff,EAA2BO,EAACU,GAChC,CAACT,EAAQO,IAAQ,CACtBE,EAAUC,M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EAAqBX,EAAS,IAAI,IAbpCF,EAAAA,GAAAA,mBAiBN,IAAMa,EAAN,KAA0B,CAC/BZ,YAAmBC,EAAqEY,EAAyB,MAA9FZ,QAAAA,OAAqEY,OAAAA,EAExFV,QAAQF,EAAqF,CAC3F,IAAMG,EAAM,IAAIC,EAA4B,CAC1CC,KAAMC,0BAAuBC,UAC7B,GAAGP,EACJ,EACDG,OAAAA,EAAIU,qBAAuB,KACpBJ,EAAyBN,CAAG,IAT1BQ,EAAAA,EAAAA,wBDnBbG,KEHAC,KAEAC","names":["ComponentStoreSymbol","ComponentArgStoreSymbol","ModuleHookStoreSymbol","CommandClientSymbol","ComponentHookSymbol","FilePathSymbol","init_symbols","__esmMin","Symbol","import_discord","getComponentHookStore","createComponentHook","init_componentHook","__esmMin","init_symbols","__name","target","property","data","Reflect","getMetadata","ComponentHookSymbol","Collection","defineMetadata","name","fn","key","store","hooks","get","set","unshift","import_discord","getComponentStore","getComponent","createComponentDecorator","getComponentArgumentStore","createArgumentDecorator","init_decoratorCreator","__esmMin","init_componentHook","init_symbols","__name","target","result","Reflect","getMetadata","ComponentStoreSymbol","Collection","defineMetadata","key","get","component","_init","componentHookStore","getComponentHookStore","hooks","store","forEach","x","i","_a","argTypes","decorators","push","set","type","options","idx","arg","ComponentArgument","init_ComponentArgument","__esmMin","constructor","type","decorators","import_lodash","ComponentArgumentDecorator","init_ComponentArgumentDecorator","__esmMin","constructor","options","_","merge","defaultOptions","ApplicationCommandComponent","applicationCommand","init_ApplicationCommand","__esmMin","init_decoratorCreator","init_BaseComponent","BaseComponent","constructor","options","__name","createComponentDecorator","ApplicationCommandOption","option","init_ApplicationCommandOption","__esmMin","init_core","ComponentArgumentDecorator","createArgumentDecorator","import_lodash","ListenerComponent","listener","init_listener","__esmMin","init_BaseComponent","init_decoratorCreator","BaseComponent","constructor","options","_","merge","emitter","__name","createComponentDecorator","ConverterComponent","argConverter","init_converter","__esmMin","init_BaseComponent","init_decoratorCreator","BaseComponent","constructor","options","__name","createComponentDecorator","import_discord","getModuleHookStore","moduleHook","init_moduleHook","__esmMin","init_symbols","__name","target","result","Reflect","getMetadata","ModuleHookStoreSymbol","Collection","defineMetadata","name","key","store","v","get","set","push","init_hooks","__esmMin","init_moduleHook","init_componentHook","import_chalk","import_discord","import_lodash","import_walk_sync","import_path","Registry","init_Registry","__esmMin","init_components","init_hooks","init_listener","init_symbols","constructor","logger","client","extensions","emitters","Collection","globalHooks","getSubLogger","name","chalk","green","addGlobalHook","fn","hooks","push","getComponentsWithTypeGlobal","type","result","ext","getComponentsWithType","componentStore","getComponentStore","Array","from","filter","x","values","registerEventListeners","listeners","ListenerComponent","listener","emitter","get","options","bound","method","bind","Reflect","defineMetadata","addListener","event","unregisterEventListeners","getMetadata","removeListener","loadAllModulesInDirectory","dir","pattern","results","files","walkSync","endsWith","test","file","p","path","join","loadModulesAtPath","info","require","resolve","mod","setup","Error","modules","registerModules","module","registerModule","FilePathSymbol","reloadModules","paths","Set","add","unregisterModule","cache","e","error","CommandClientSymbol","runModuleHook","_","remove","hookName","args","functions","getModuleHookStore","call","registerEventEmitter","set","init_structures","__esmMin","init_Registry","init_CommandClient","import_chalk","import_discord","Extension","init_Extension","__esmMin","init_converter","init_structures","commandClient","CommandClient","getFromModule","client","discord","logger","_logger","getSubLogger","name","chalk","green","constructor","convertArguments","component","argList","args","getConverterArgs","items","Collection","extension","registry","extensions","converter","getComponentsWithType","ConverterComponent","options","set","type","ext","index","arg","get","undefined","converterArgs","execute","import_chalk","CTSExtension","init_CTSExtension","__esmMin","init_Extension","Extension","logger","_logger","commandClient","ctsLogger","getSubLogger","name","chalk","green","constructor","import_chalk","import_discord","__decorate","ApplicationCommandExtension","init_ApplicationCommandExtension","__esmMin","init_ApplicationCommand","init_ApplicationCommandOption","init_listener","init_converter","init_CTSExtension","decorators","target","key","desc","CTSExtension","constructor","config","unmanagedCommands","registerUnmanagedCommand","command","push","interactionCreate","i","_a","type","InteractionType","ApplicationCommand","cmd","ext","extensions","commandClient","registry","subcommand","subcommandGroup","commandType","ApplicationCommandType","ChatInput","options","getSubcommand","getSubcommandGroup","extLoop","extension","components","getComponentsWithType","ApplicationCommandComponent","subcommandGroupChild","parent","name","commandName","argList","convertArguments","argTypes","idx","arg","value","decorator","ApplicationCommandOption","ApplicationCommandOptionType","Subcommand","SubcommandGroup","includes","isChatInputCommand","get","executeGlobalHook","execute","e","emit","sync","client","logger","info","commands","guildCommands","Collection","subcommandGroups","getComponentsWithTypeGlobal","group","guilds","guild","set","option","find","x","child","executeHook","rest","g","size","fetch","chalk","green","length","map","blue","join","id","error","message","application","chatInteraction","messageInteraction","userInteraction","commandInteraction","listener","event","argConverter","component","parameterless","ChatInputCommandInteraction","MessageContextMenuCommandInteraction","UserContextMenuCommandInteraction","CommandInteraction","TextCommandComponent","command","init_TextCommand","__esmMin","init_decoratorCreator","init_BaseComponent","BaseComponent","constructor","options","__name","createComponentDecorator","TextCommandRestOption","rest","init_parameters","__esmMin","init_core","ComponentArgumentDecorator","createArgumentDecorator","import_discord","__decorate","TextCommandExtension","init_TextCommandExtension","__esmMin","init_listener","init_CTSExtension","init_TextCommand","init_parameters","init_core","decorators","target","key","desc","CTSExtension","constructor","config","processPrefix","msg","content","prefix","startsWith","length","Array","p","find","x","messageCreate","startIndex","slice","commands","extensions","Map","ext","commandClient","registry","cmd","getComponentsWithType","TextCommandComponent","push","set","commandNameLength","command","names","options","name","aliases","get","args","argStrings","split","convertArguments","argTypes","arg","i","converter","parameterless","TextCommandRestOption","text","join","shift","execute","e","emit","mesage","str","value","num","Number","listener","event","emitter","argConverter","component","type","Message","String","CommandClient_exports","__export","CommandClient","import_chalk","import_discord","import_events","import_tslog","init_CommandClient","__esmMin","init_ApplicationCommandExtension","init_TextCommandExtension","init_symbols","init_Registry","EventEmitter","constructor","discord","logger","Logger","prettyLogTimeZone","loggerOptions","owners","Set","ctsLogger","getSubLogger","name","registry","Registry","registerEventEmitter","isOwner","user","has","id","fetchOwners","application","Error","info","fetch","owner","User","add","push","tag","Team","member","members","chalk","green","length","map","x","blue","join","enableApplicationCommandsExtension","config","registerModule","ApplicationCommandExtension","enableTextCommandsExtension","TextCommandExtension","getApplicationCommandsExtension","extensions","find","getFromModule","ext","Reflect","getMetadata","CommandClientSymbol","import_discord","BaseComponent","init_BaseComponent","__esmMin","init_ComponentArgument","hooks","Collection","argTypes","_init","method","i","length","element","set","ComponentArgument","executeGlobalHook","target","name","args","CommandClient","client","getFromModule","globalHooks","registry","fn","call","executeHook","hook","get","unshift","execute","beforeCallArgs","result","e","import_reflect_metadata","init_components","__esmMin","init_decoratorCreator","init_ComponentArgument","init_ComponentArgumentDecorator","init_BaseComponent","OwnerOnlyError","init_errors","__esmMin","import_discord","createCheckDecorator","ownerOnly","init_checks","__esmMin","init_hooks","init_errors","__name","fn","createComponentHook","client","i","isOwner","BaseInteraction","user","Message","author","OwnerOnlyError","mergeMethodDecorators","init_decorators","__esmMin","__name","decorators","target","key","descriptor","decorator","init_utils","__esmMin","init_checks","init_errors","init_decorators","init_extensions","__esmMin","init_Extension","init_core","__esmMin","init_components","init_hooks","init_converter","init_utils","init_listener","init_structures","init_extensions","src_exports","__export","ApplicationCommandComponent","ApplicationCommandExtension","BaseComponent","CommandClient","ComponentArgument","ComponentArgumentDecorator","ConverterComponent","Extension","ListenerComponent","OwnerOnlyError","Registry","SubCommandGroup","SubCommandGroupChild","TextCommandComponent","TextCommandRestOption","applicationCommand","argConverter","command","createArgumentDecorator","createCheckDecorator","createComponentDecorator","createComponentHook","getComponent","getComponentArgumentStore","getComponentStore","getModuleHookStore","listener","mergeMethodDecorators","moduleHook","option","ownerOnly","rest","__toCommonJS","init_core","init_ApplicationCommand","init_ApplicationCommandOption","import_discord","init_core","init_ApplicationCommand","SubCommandGroup","constructor","options","guilds","command","cmd","ApplicationCommandComponent","type","ApplicationCommandType","ChatInput","subcommandGroup","createComponentDecorator","createChild","SubCommandGroupChild","parent","subcommandGroupChild","init_ApplicationCommandExtension","init_TextCommand","init_parameters"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pikokr/command.ts",
3
3
  "description": "Discord.js command framework for typescript.",
4
- "version": "5.5.0-dev.f749341",
4
+ "version": "5.6.0-dev.2",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -10,16 +10,22 @@
10
10
  "@swc/core": "1.2.223",
11
11
  "@types/chalk": "2.2.0",
12
12
  "@types/lodash": "4.14.184",
13
+ "@typescript-eslint/eslint-plugin": "latest",
14
+ "@typescript-eslint/parser": "latest",
13
15
  "all-contributors-cli": "6.20.0",
14
16
  "discord.js": "14.3.0",
15
17
  "dotenv": "16.0.1",
18
+ "eslint": "latest",
19
+ "eslint-config-prettier": "^8.8.0",
20
+ "eslint-plugin-prettier": "^4.2.1",
16
21
  "prettier": "2.7.1",
17
22
  "rimraf": "3.0.2",
18
23
  "ts-node": "10.9.1",
19
24
  "tslog": "^4.7.1",
20
25
  "tsup": "6.2.1",
21
26
  "typedoc": "^0.23.13",
22
- "typescript": "^4.8.2"
27
+ "typescript": "^4.8.2",
28
+ "semantic-release": "^21.0.0"
23
29
  },
24
30
  "dependencies": {
25
31
  "@types/node": "^16.0.0",
@@ -38,10 +44,21 @@
38
44
  "docs:dev": "typedoc",
39
45
  "docs:build": "typedoc",
40
46
  "docs": "typedoc --json docs/typedoc-out.json --tsconfig tsconfig.prod.json src/index.ts && ts-node scripts/docs",
41
- "test": "yarn ts-node --swc test"
47
+ "test": "yarn ts-node --swc test",
48
+ "lint": "eslint --ignore-path .gitignore .",
49
+ "semantic-release": "semantic-release"
42
50
  },
43
51
  "peerDependencies": {
44
52
  "discord.js": "*",
45
53
  "tslog": "*"
54
+ },
55
+ "release": {
56
+ "branches": [
57
+ "stable",
58
+ {
59
+ "name": "dev",
60
+ "prerelease": true
61
+ }
62
+ ]
46
63
  }
47
- }
64
+ }
@@ -1,26 +1,4 @@
1
- /*
2
- * This is the default license template.
3
- *
4
- * File: publish-version.js
5
- * Author: pikokr
6
- * Copyright (c) 2022 pikokr
7
- *
8
- * To edit this license information: Press Ctrl+Shift+P and press 'Create new License Template...'.
9
- */
10
-
11
- /*
12
- * This is the default license template.
13
- *
14
- * File: publish-version.js
15
- * Author: pikokr
16
- * Copyright (c) 2022 pikokr
17
- *
18
- * To edit this license information: Press Ctrl+Shift+P and press 'Create new License Template...'.
19
- */
20
-
21
- /*
22
- * Copyright (c) 2022 pikokr. Licensed under the MIT license
23
- */
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
24
2
 
25
3
  // DO NOT RUN THIS ON DEV ENVIRONMENT
26
4
  // **CI ONLY**
package/scripts/docs.ts CHANGED
@@ -1,11 +1,11 @@
1
- /*
2
- * File: docs.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
1
+ /*
2
+ * File: docs.ts
3
+ *
4
+ * Copyright (c) 2022-2022 pikokr
5
+ *
6
+ * Licensed under MIT License. Please see more defails in LICENSE file.
7
+ */
8
+
9
9
  import { runGenerator } from '@discordjs/ts-docgen'
10
10
 
11
11
  runGenerator({
@@ -1,15 +1,7 @@
1
- /*
2
- * File: ApplicationCommand.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import type { ApplicationCommandType, ChatInputApplicationCommandData, MessageApplicationCommandData, Snowflake, UserApplicationCommandData } from 'discord.js'
10
2
  import { createComponentDecorator } from '../core/components/decoratorCreator'
11
3
  import { BaseComponent } from '../core/components/BaseComponent'
12
- import { SubCommandGroup, SubCommandGroupChild } from './group'
4
+ import type { SubCommandGroup, SubCommandGroupChild } from './group'
13
5
 
14
6
  type Options = (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {
15
7
  type: ApplicationCommandType
@@ -1,28 +1,21 @@
1
- /*
2
- * File: ApplicationCommandExtension.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import chalk from 'chalk'
10
- import {
2
+ import type {
11
3
  APIApplicationCommandSubcommandGroupOption,
12
4
  APIApplicationCommandSubcommandOption,
13
5
  ApplicationCommandData,
14
- ApplicationCommandDataResolvable,
15
- ApplicationCommandOptionType,
16
6
  ApplicationCommandSubCommandData,
17
- ApplicationCommandType,
18
7
  ChatInputApplicationCommandData,
8
+ Interaction,
9
+ Snowflake,
10
+ } from 'discord.js'
11
+ import {
12
+ ApplicationCommandOptionType,
13
+ ApplicationCommandType,
19
14
  ChatInputCommandInteraction,
20
15
  Collection,
21
16
  CommandInteraction,
22
- Interaction,
23
17
  InteractionType,
24
18
  MessageContextMenuCommandInteraction,
25
- Snowflake,
26
19
  UserContextMenuCommandInteraction,
27
20
  } from 'discord.js'
28
21
  import { ApplicationCommandComponent } from './ApplicationCommand'
@@ -219,7 +212,7 @@ export class ApplicationCommandExtension extends CTSExtension {
219
212
 
220
213
  if (!group.options) group.options = []
221
214
 
222
- let child = group.options.find((x) => x.name === command.subcommandGroupChild!.options.name) as APIApplicationCommandSubcommandGroupOption
215
+ let child = group.options.find((x) => x.name === command.subcommandGroupChild?.options.name) as APIApplicationCommandSubcommandGroupOption | undefined
223
216
 
224
217
  if (!child) {
225
218
  child = { type: ApplicationCommandOptionType.SubcommandGroup, ...(command.subcommandGroupChild.options as Omit<APIApplicationCommandSubcommandGroupOption, 'type'>) }
@@ -324,9 +317,13 @@ export class ApplicationCommandExtension extends CTSExtension {
324
317
  try {
325
318
  this.logger.info(`Processing ${chalk.green(commands.length)} commands(${commands.map((x) => chalk.blue(x.name)).join(', ')}) for application scope...`)
326
319
 
327
- await this.client.application!.commands.set(commands)
320
+ if (this.client.application) {
321
+ await this.client.application.commands.set(commands)
328
322
 
329
- this.logger.info('Successfully registered commands.')
323
+ this.logger.info('Successfully registered commands.')
324
+ } else {
325
+ this.logger.error('Client#application is not yet initialized.')
326
+ }
330
327
  } catch (e) {
331
328
  this.logger.error(`Failed to register commands to global: ${(e as Error).message}`)
332
329
  }
@@ -1,12 +1,4 @@
1
- /*
2
- * File: ApplicationCommandOption.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- import { APIApplicationCommandOption } from 'discord.js'
1
+ import type { APIApplicationCommandOption } from 'discord.js'
10
2
  import { createArgumentDecorator, ComponentArgumentDecorator } from '../core'
11
3
 
12
4
  type Options = APIApplicationCommandOption
@@ -1,4 +1,5 @@
1
- import { APIApplicationCommandSubcommandOption, ApplicationCommandType, ChatInputApplicationCommandData } from 'discord.js'
1
+ import type { APIApplicationCommandSubcommandOption, ChatInputApplicationCommandData } from 'discord.js'
2
+ import { ApplicationCommandType } from 'discord.js'
2
3
  import { createComponentDecorator } from '../core'
3
4
  import { ApplicationCommandComponent } from './ApplicationCommand'
4
5
 
@@ -1,12 +1,4 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- export * from './ApplicationCommand'
10
- export { option } from './ApplicationCommandOption'
11
- export * from './group'
12
- export * from './ApplicationCommandExtension'
1
+ export * from './ApplicationCommand'
2
+ export { option } from './ApplicationCommandOption'
3
+ export * from './group'
4
+ export * from './ApplicationCommandExtension'
@@ -1,24 +1,16 @@
1
- /*
2
- * File: BaseComponent.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import { Collection } from 'discord.js'
10
- import _ from 'lodash'
2
+ import type { AnyFunction } from '../../utils/types'
11
3
  import type { ComponentHookStore } from '../hooks'
12
4
  import { ComponentArgument } from './ComponentArgument'
13
5
 
14
6
  export class BaseComponent {
15
- method!: Function
7
+ method!: AnyFunction
16
8
 
17
9
  hooks: ComponentHookStore = new Collection()
18
10
 
19
11
  argTypes: Collection<number, ComponentArgument> = new Collection()
20
12
 
21
- _init(method: Function, argTypes: unknown[]) {
13
+ _init(method: AnyFunction, argTypes: unknown[]) {
22
14
  this.method = method
23
15
  for (let i = 0; i < argTypes.length; i++) {
24
16
  const element = argTypes[i]
@@ -1,12 +1,4 @@
1
- /*
2
- * File: ComponentArgument.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- import { ComponentArgumentDecorator } from './ComponentArgumentDecorator'
1
+ import type { ComponentArgumentDecorator } from './ComponentArgumentDecorator'
10
2
 
11
3
  export class ComponentArgument {
12
4
  decorators: ComponentArgumentDecorator[] = []