@pikokr/command.ts 4.0.6 → 4.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ jobs:
11
11
  - uses: actions/checkout@v1
12
12
  - uses: actions/setup-node@v1
13
13
  with:
14
- node-version: 16.6
14
+ node-version: 16.14
15
15
  - run: yarn
16
16
  - uses: JS-DevTools/npm-publish@v1
17
17
  with:
@@ -11,7 +11,7 @@ jobs:
11
11
  - uses: actions/checkout@v1
12
12
  - uses: actions/setup-node@v1
13
13
  with:
14
- node-version: 16.6
14
+ node-version: 16.14
15
15
  - run: yarn
16
16
  - run: COMMIT_ID=$(git rev-parse --short HEAD) node publish-version.js
17
17
  - uses: JS-DevTools/npm-publish@v1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/home/runner/work/command.ts/command.ts/src/index.ts","../src/home/runner/work/command.ts/command.ts/src/constants.ts","../src/structures/home/runner/work/command.ts/command.ts/src/structures/Module.ts","../src/structures/home/runner/work/command.ts/command.ts/src/structures/CommandClient.ts","../src/structures/home/runner/work/command.ts/command.ts/src/structures/Registry.ts","../src/error/home/runner/work/command.ts/command.ts/src/error/InvalidTargetError.ts","../src/error/home/runner/work/command.ts/command.ts/src/error/ModuleError.ts","../src/error/home/runner/work/command.ts/command.ts/src/error/ArgumentNotProvided.ts","../src/error/home/runner/work/command.ts/command.ts/src/error/ArgumentConverterNotFound.ts","../src/error/home/runner/work/command.ts/command.ts/src/error/CommandCheckFailed.ts","../src/error/home/runner/work/command.ts/command.ts/src/error/PermissionRequired.ts","../src/error/checks/home/runner/work/command.ts/command.ts/src/error/checks/OwnerOnlyCommand.ts","../src/error/checks/home/runner/work/command.ts/command.ts/src/error/checks/GuildOnlyCommand.ts","../src/error/checks/home/runner/work/command.ts/command.ts/src/error/checks/DMOnlyCommand.ts","../src/error/checks/home/runner/work/command.ts/command.ts/src/error/checks/SlashCommandGlobalCheckError.ts","../src/error/home/runner/work/command.ts/command.ts/src/error/CommandNotFound.ts","../src/builtinModules/home/runner/work/command.ts/command.ts/src/builtinModules/BuiltInModule.ts","../src/listener/home/runner/work/command.ts/command.ts/src/listener/Listener.ts","../src/home/runner/work/command.ts/command.ts/src/utils.ts","../src/listener/home/runner/work/command.ts/command.ts/src/listener/decorator.ts","../src/builtinModules/home/runner/work/command.ts/command.ts/src/builtinModules/CommandHandler.ts","../src/command/home/runner/work/command.ts/command.ts/src/command/Command.ts","../src/command/home/runner/work/command.ts/command.ts/src/command/ArgumentConverter.ts","../src/command/home/runner/work/command.ts/command.ts/src/command/utils.ts","../src/command/home/runner/work/command.ts/command.ts/src/command/decorator.ts","../src/command/cooldown/home/runner/work/command.ts/command.ts/src/command/cooldown/type.ts","../src/command/cooldown/home/runner/work/command.ts/command.ts/src/command/cooldown/decorator.ts","../src/command/cooldown/home/runner/work/command.ts/command.ts/src/command/cooldown/error.ts","../src/command/cooldown/home/runner/work/command.ts/command.ts/src/command/cooldown/adapter.ts","../src/builtinModules/home/runner/work/command.ts/command.ts/src/builtinModules/BuiltinCommandConverters.ts","../src/builtinModules/home/runner/work/command.ts/command.ts/src/builtinModules/BuiltinApplicationCommandConverters.ts","../src/applicationCommand/home/runner/work/command.ts/command.ts/src/applicationCommand/decorator.ts","../src/applicationCommand/home/runner/work/command.ts/command.ts/src/applicationCommand/AppCommand.ts","../src/messageComponents/home/runner/work/command.ts/command.ts/src/messageComponents/base.ts","../src/messageComponents/home/runner/work/command.ts/command.ts/src/messageComponents/button.ts","../src/messageComponents/home/runner/work/command.ts/command.ts/src/messageComponents/selectMenu.ts"],"sourcesContent":["/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport 'reflect-metadata'\nimport './typings'\n\nexport * from './interface'\nexport * from './structures'\nexport * from './error'\nexport * from './command'\nexport * from './listener'\nexport * from './builtinModules/BuiltInModule'\nexport * from './applicationCommand'\nexport * from './messageComponents'\nexport * from './error'\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport const KCommands = Symbol('Command.TS Commands')\n\nexport const KApplicationCommands = Symbol('Command.TS Slash Commands')\n\nexport const KSlashCommandOptions = Symbol('Command.TS Slash Command Options')\n\nexport const KListeners = Symbol('Command.TS Listeners')\n\nexport const KModulePath = Symbol('Command.TS Module Path')\n\nexport const KListenerExecuteCache = Symbol('Command.TS Module Identifier')\n\nexport const KBuiltInModule = Symbol('Command.TS Built-In Module')\n\nexport const KOptionals = Symbol('Command.TS Optional Parameters')\n\nexport const KRest = Symbol('Command.TS Rest Parameter')\n\nexport const KArgumentConverters = Symbol('Command.TS Argument Converter')\n\nexport const KSlashArgumentConverters = Symbol('Command.TS Slash Argument Converter')\n\nexport const KCommandChecks = Symbol('Command.TS Command Checks')\n\nexport const KApplicationCommandChecks = Symbol('Command.TS Slash Command Checks')\n\nexport const KMessageComponentHandlers = Symbol('Command.TS Message Component Handlers')\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { KArgumentConverters, KCommands, KListeners, KMessageComponentHandlers, KModulePath, KSlashArgumentConverters, KApplicationCommands } from '../constants'\nimport type { Command } from '../command'\nimport { Listener } from '../listener'\nimport { ArgumentConverter, ApplicationCommandArgumentConverter } from '../command'\nimport { AppCommand } from '../applicationCommand'\nimport { CommandClient } from './CommandClient'\nimport { MessageComponentHandler } from '../messageComponents/base'\n\nexport abstract class Module {\n commandClient!: CommandClient\n\n get logger() {\n return this.commandClient.logger.getChildLogger({\n name: this.constructor.name,\n })\n }\n\n get commands(): Command[] {\n return Reflect.getMetadata(KCommands, this) || []\n }\n\n get listeners(): Listener[] {\n return Reflect.getMetadata(KListeners, this) || []\n }\n\n get argumentConverters(): ArgumentConverter[] {\n return Reflect.getMetadata(KArgumentConverters, this) || []\n }\n\n get applicationCommandArgumentConverters(): ApplicationCommandArgumentConverter[] {\n return Reflect.getMetadata(KSlashArgumentConverters, this) || []\n }\n\n get applicationCommands(): AppCommand[] {\n return Reflect.getMetadata(KApplicationCommands, this) || []\n }\n\n get messageComponentHandlers(): MessageComponentHandler[] {\n return Reflect.getMetadata(KMessageComponentHandlers, this) || []\n }\n\n get path(): string | undefined {\n return Reflect.getMetadata(KModulePath, this)\n }\n\n load() {}\n unload() {}\n beforeReload() {}\n afterReload() {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport _ from 'lodash'\nimport { Registry } from './Registry'\nimport { Client, CommandInteraction, Interaction, Message, Snowflake, User } from 'discord.js'\nimport { BuiltinCommandConverters, BuiltinApplicationCommandConverters, CommandHandler } from '../builtinModules'\nimport { CoolDownAdapter, DefaultCoolDownAdapter } from '../command'\nimport { Logger } from 'tslog'\n\nexport interface CommandOptions {\n prefix: string | ((msg: any) => string | Promise<string | string[]> | string[]) | string[]\n check: (msg: Message) => boolean | Promise<boolean>\n}\n\nexport interface SlashCommandOptions {\n check: (i: CommandInteraction) => boolean | Promise<boolean>\n}\n\nexport interface ApplicationCommandOptions {\n guild?: Snowflake | Snowflake[]\n autoSync: boolean\n beforeRunCheck: (i: Interaction) => void | Promise<void>\n}\n\nexport interface CommandClientOptions {\n command: CommandOptions\n owners: 'auto' | Snowflake[]\n slashCommands: SlashCommandOptions\n applicationCommands: ApplicationCommandOptions\n}\n\nexport interface CommandClientOptionsParam {\n command: Partial<CommandOptions>\n owners: 'auto' | string[]\n slashCommands: Partial<SlashCommandOptions>\n applicationCommands: Partial<ApplicationCommandOptions>\n}\n\nexport class CommandClient {\n options: CommandClientOptions\n owners: string[] = []\n registry = new Registry(this)\n client: Client\n coolDownAdapter: CoolDownAdapter\n logger: Logger\n\n private _isReady = false\n\n private async fetchOwners(): Promise<string[]> {\n await this.client.application?.fetch()\n const o = this.client.application?.owner\n if (!o) return []\n if (o instanceof User) return [o.id]\n else return o.members.map((x) => x.id)\n }\n\n async ready() {\n if (this._isReady) return\n this._isReady = true\n if (this.options.owners === 'auto') {\n const owners = await this.fetchOwners()\n this.owners.push(...owners)\n }\n if (this.options.applicationCommands.autoSync) {\n await this.registry.syncCommands()\n }\n }\n\n constructor({ client, coolDownAdapter, logger, ...options }: Partial<CommandClientOptionsParam> & { client: Client; coolDownAdapter?: CoolDownAdapter; logger?: Logger }) {\n this.client = client\n this.coolDownAdapter = coolDownAdapter || new DefaultCoolDownAdapter()\n this.options = _.merge<CommandClientOptions, Partial<CommandClientOptionsParam>>(\n {\n command: {\n prefix: '!',\n check: () => true,\n },\n owners: 'auto',\n slashCommands: {\n check: () => true,\n },\n applicationCommands: {\n autoSync: false,\n beforeRunCheck: () => {},\n },\n },\n options,\n )\n\n this.logger = logger ?? new Logger({ name: 'Command.TS' })\n\n if (this.options.owners !== 'auto') {\n this.owners = this.options.owners\n }\n\n this.client.once('ready', () => this.ready())\n this.registry.registerModule(new CommandHandler(this.registry))\n this.registry.registerModule(new BuiltinCommandConverters(this))\n this.registry.registerModule(new BuiltinApplicationCommandConverters(this))\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandClient } from './CommandClient'\nimport { Module } from './Module'\nimport { Command, ApplicationCommandArgumentConverter } from '../command'\nimport { KBuiltInModule, KListenerExecuteCache, KModulePath } from '../constants'\nimport path from 'path'\nimport { InvalidModuleError, InvalidTargetError, ModuleLoadError } from '../error'\nimport { Collection, Guild } from 'discord.js'\nimport walkSync from 'walk-sync'\nimport { ArgumentConverter } from '../command'\nimport { AppCommand } from '../applicationCommand'\nimport * as fs from 'fs'\nimport { MessageComponentHandler } from '../messageComponents/base'\n\ntype ListenerExecutor = {\n event: string\n execute: any\n}\n\nexport class Registry {\n constructor(public client: CommandClient) {}\n\n modules: Collection<symbol, Module> = new Collection()\n\n private get logger() {\n return this.client.logger.getChildLogger({\n name: 'Registry',\n })\n }\n\n get commands(): Command[] {\n const result: Command[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.commands)\n }\n\n return result\n }\n\n get argumentConverters(): ArgumentConverter[] {\n const result: ArgumentConverter[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.argumentConverters)\n }\n\n return result\n }\n\n get applicationCommandArgumentConverters(): ApplicationCommandArgumentConverter[] {\n const result: ApplicationCommandArgumentConverter[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.applicationCommandArgumentConverters)\n }\n\n return result\n }\n\n get applicationCommands(): AppCommand[] {\n const result: AppCommand[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.applicationCommands)\n }\n\n return result\n }\n\n get messageComponentHandlers(): MessageComponentHandler[] {\n const result: MessageComponentHandler[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.messageComponentHandlers)\n }\n\n return result\n }\n\n registerModule(module: Module) {\n module.commandClient = this.client\n\n this.modules.set(Symbol(module.constructor.name), module)\n\n const list: ListenerExecutor[] = []\n\n for (const listener of module.listeners) {\n const bound = listener.execute.bind(module)\n list.push({ event: listener.name, execute: bound })\n this.client.client.on(listener.name, bound)\n }\n\n Reflect.defineMetadata(KListenerExecuteCache, list, module)\n\n return module\n }\n\n async loadModulesIn(dir: string, absolute = false) {\n let p = absolute ? dir : path.join(require.main!.path, dir)\n\n for (const i of walkSync(p)) {\n if (fs.lstatSync(path.join(p, i)).isFile()) {\n if (i.endsWith('.map')) continue\n await this.loadModule(path.join(p, i), true)\n }\n }\n }\n\n async loadModule(file: string, absolute: boolean = false) {\n let p = absolute ? file : path.join(require.main!.path, file)\n\n let m\n\n try {\n m = require(p)\n } catch (e: any) {\n throw new ModuleLoadError(p, e)\n }\n\n if (m.loaded) throw new Error('MODULE_ALREADY_LOADED')\n\n if (!m.install) throw new InvalidModuleError('Install function not found.')\n\n const mod = m.install(this.client)\n\n if (!(mod instanceof Module)) throw new InvalidTargetError()\n\n Reflect.defineMetadata(KModulePath, require.resolve(p), mod)\n\n this.registerModule(mod)\n\n await mod.load()\n\n m.loaded = true\n\n return mod\n }\n\n async syncCommands() {\n this.logger.debug(`Syncing commands...`)\n const commands = this.applicationCommands.filter((x) => !x.guild)\n const guild = this.client.options.applicationCommands.guild\n const syncForGuild = async (g: Guild, commands: AppCommand[]) => {\n this.logger.debug(`Syncing for guild ${g.name}(${g.id})`)\n const commandsToRegister = commands.map((x) => x.command)\n this.logger.debug(`Command List: ${commandsToRegister.map((x) => x.name).join(', ')}`)\n await g.commands.set(commandsToRegister)\n }\n const commandsWithGuild = this.applicationCommands.filter((x) => !!x.guild)\n\n if (guild) {\n if (typeof guild === 'string') {\n await syncForGuild(await this.client.client.guilds.fetch(guild), [\n ...commands,\n ...commandsWithGuild.filter((x) => x.guild && (typeof x.guild === 'string' ? guild === x.guild : x.guild.includes(guild))),\n ])\n } else {\n for (const g of guild) {\n await syncForGuild(await this.client.client.guilds.fetch(g), [\n ...commands,\n ...commandsWithGuild.filter((x) => x.guild && (typeof x.guild === 'string' ? g === x.guild : x.guild.includes(g))),\n ])\n }\n }\n } else {\n this.logger.debug('Syncing global...')\n await this.client.client.application?.commands.set(commands.map((x) => x.command))\n }\n\n const guilds = new Set<string>()\n\n for (const command of commandsWithGuild) {\n if (!command.guild) continue\n if (typeof command.guild === 'string') {\n guilds.add(command.guild)\n } else {\n for (const guild of command.guild) {\n guilds.add(guild)\n }\n }\n }\n\n for (const guild of guilds) {\n if (this.client.options.applicationCommands.guild?.includes(guild)) continue\n await syncForGuild(\n await this.client.client.guilds.fetch(guild),\n commandsWithGuild.filter((x) => x.guild && (typeof x.guild === 'string' ? guild === x.guild : x.guild.includes(guild))),\n )\n }\n\n this.logger.debug('Syncing ended.')\n }\n\n async unregisterModule(module: Module) {\n if (Reflect.getMetadata(KBuiltInModule, module)) throw new Error('Built-in modules cannot be unloaded')\n const symbol = this.modules.findKey((x) => x === module)\n if (!symbol) return module\n await module.unload()\n const list: ListenerExecutor[] = Reflect.getMetadata(KListenerExecuteCache, module)\n for (const listener of list) {\n this.client.client.removeListener(listener.event, listener.execute)\n }\n this.modules.delete(symbol)\n return module\n }\n\n async unloadModule(module: Module) {\n const p = Reflect.getMetadata(KModulePath, module)\n\n if (!p) throw new InvalidModuleError('This module is not loaded by loadModule.')\n\n await this.unregisterModule(module)\n delete require.cache[p]\n }\n\n async reloadModule(module: Module) {\n await module.beforeReload()\n const p = Reflect.getMetadata(KModulePath, module)\n await this.unloadModule(module)\n const mod = await this.loadModule(p, true)\n await mod.afterReload()\n return true\n }\n\n async reloadAll() {\n const results: {\n path: string\n success: boolean\n error?: Error\n }[] = []\n\n for (const [, module] of this.modules.filter((x) => !!x.path && !Reflect.getMetadata(KBuiltInModule, x))) {\n try {\n await this.reloadModule(module)\n results.push({\n path: module.path!,\n success: true,\n })\n } catch (e: any) {\n results.push({\n error: e,\n path: module.path!,\n success: false,\n })\n }\n }\n return results\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class InvalidTargetError extends Error {\n constructor() {\n super('Class does not extend \"Module\" class.')\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class ModuleLoadError extends Error {\n constructor(file: string, public error: Error) {\n super('Failed to load module ' + file)\n }\n}\n\nexport class InvalidModuleError extends Error {}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Message } from 'discord.js'\nimport { Command } from '../command'\n\nexport class ArgumentNotProvided extends Error {\n constructor(public index: number, public command: Command, public msg: Message) {\n super(`Required argument #${index} not provided.`)\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'\nimport type { Argument } from '../command'\nimport type { AppCommandArgument } from '../applicationCommand'\n\nexport class ArgumentConverterNotFound extends Error {\n constructor(public type: Argument, public msg: Message) {\n super(`Argument converter ${type.type.name} not found.`)\n }\n}\nexport class ApplicationCommandArgumentConverterNotFound extends Error {\n constructor(public type: AppCommandArgument, public interaction: CommandInteraction | ContextMenuInteraction) {\n super(`Argument converter ${type.type.name} not found.`)\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandInteraction, ContextMenuInteraction, Message, MessageComponentInteraction } from 'discord.js'\nimport { Command } from '../command'\nimport { AppCommand } from '../applicationCommand'\n\nexport class CommandCheckFailed extends Error {\n constructor(public msg: Message, public command: Command) {\n super()\n }\n}\n\nexport class ApplicationCommandCheckFailed extends Error {\n constructor(public interaction: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction, public command: AppCommand) {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { GuildMember, Permissions } from 'discord.js'\n\nexport class UserPermissionRequired extends Error {\n constructor(public user: GuildMember, public permissions: Permissions) {\n super()\n }\n}\n\nexport class ClientPermissionRequired extends Error {\n constructor(public permissions: Permissions) {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class OwnerOnlyCommandError extends Error {\n constructor() {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class GuildOnlyCommandError extends Error {\n constructor() {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class DMOnlyCommandError extends Error {\n constructor() {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandInteraction } from 'discord.js'\n\nexport class SlashCommandGlobalCheckError extends Error {\n constructor(public i: CommandInteraction) {\n super('Slash command before-run check failed.')\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Message } from 'discord.js'\n\nexport class CommandNotFound extends Error {\n constructor(public commandName: string, public msg: Message, public args: string[]) {\n super(`Command ${commandName} not found.`)\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from '../structures'\nimport { KBuiltInModule } from '../constants'\n\nexport class BuiltInModule extends Module {\n constructor() {\n super()\n Reflect.defineMetadata(KBuiltInModule, true, this)\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class Listener {\n constructor(public name: string, public execute: Function) {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from './structures'\nimport { InvalidTargetError } from './error'\n\nexport const checkTarget = (target: Object) => {\n if (!(target instanceof Module)) throw new InvalidTargetError()\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { checkTarget } from '../utils'\nimport { KListeners } from '../constants'\nimport { Listener } from './Listener'\nimport { Module } from '../structures'\n\nexport const listener = (event: string) => {\n return (\n target: Module,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: Listener[] = Reflect.getMetadata(KListeners, target)\n\n const listener = new Listener(event, Reflect.get(target, propertyKey))\n\n if (properties) {\n properties.push(listener)\n } else {\n properties = [listener]\n Reflect.defineMetadata(KListeners, properties, target)\n }\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { BuiltInModule } from './BuiltInModule'\nimport { Registry } from '../structures'\nimport { listener } from '../listener'\nimport {\n CommandInteraction,\n CommandInteractionOptionResolver,\n GuildMember,\n Interaction,\n Message,\n MessageComponentInteraction,\n MessageContextMenuInteraction,\n Role,\n User,\n UserContextMenuInteraction,\n} from 'discord.js'\nimport { CommandClient } from '../structures'\nimport { Command } from '../command'\nimport { ArgumentConverterNotFound, ArgumentNotProvided, CommandCheckFailed, ApplicationCommandArgumentConverterNotFound, ApplicationCommandCheckFailed } from '../error'\nimport { CommandNotFound } from '../error/CommandNotFound'\nimport { SlashCommandGlobalCheckError } from '../error/checks/SlashCommandGlobalCheckError'\nimport { MessageComponentHandler } from '../messageComponents/base'\n\nexport class CommandHandler extends BuiltInModule {\n private readonly client: CommandClient\n\n constructor(private registry: Registry) {\n super()\n this.client = registry.client\n }\n\n // region message command handler\n @listener('messageCreate')\n async message(msg: Message) {\n const error = (error: Error) => this.client.client.emit('commandError', error, msg)\n\n try {\n const prefixList: string[] | string =\n typeof this.client.options.command.prefix === 'string'\n ? this.client.options.command.prefix\n : typeof this.client.options.command.prefix === 'function'\n ? await this.client.options.command.prefix(msg)\n : this.client.options.command.prefix\n let prefix: string\n if (typeof prefixList === 'object') {\n const res = prefixList.find((x) => msg.content.includes(x))\n\n if (!res) return\n\n prefix = res\n } else {\n if (!msg.content.includes(prefixList)) return\n prefix = prefixList\n }\n\n if (!msg.content.startsWith(prefix)) return\n\n const args = msg.content.slice(prefix.length).split(' ')\n\n const command = args.shift()\n\n if (!command) return\n\n let cmd: Command | null = null\n\n for (const c of this.registry.commands) {\n const aliases = typeof c.aliases === 'function' ? await c.aliases(msg) : c.aliases\n if ([...aliases, c.name].some((x) => x === command)) {\n cmd = c\n break\n }\n }\n\n msg.data = {\n cts: this.client,\n command: cmd,\n prefix: prefix,\n }\n\n if (!(await this.client.options.command.check(msg))) {\n return\n }\n\n if (!cmd) return error(new CommandNotFound(command, msg, args))\n\n const module = this.registry.modules.find((x) => x.commands.includes(cmd!))\n\n if (!module) return\n\n const argList: any[] = []\n\n for (const check of cmd.checks) {\n if (!(await check(msg))) return error(new CommandCheckFailed(msg, cmd))\n }\n\n for (let i = 0; i < cmd.argTypes.length; i++) {\n const argType = cmd.argTypes[i]\n const converter = this.registry.argumentConverters.find((x) => x.type === argType.type)\n\n if (argType.rest) {\n const i = args.join(' ')\n argList.push(i)\n break\n }\n\n if (!converter) return error(new ArgumentConverterNotFound(argType, msg))\n\n const converterModule = this.registry.modules.find((x) => x.argumentConverters.includes(converter))\n\n if (!converterModule) return error(new ArgumentConverterNotFound(argType, msg))\n\n if (converter.withoutParameter) {\n argList.push(await converter.execute(converterModule, msg))\n continue\n }\n const arg = args.shift()\n if (argType.optional && !arg) {\n break\n }\n if (!arg) {\n return error(new ArgumentNotProvided(i, cmd, msg))\n }\n const executed = await converter.execute(converterModule, msg, arg)\n if ((executed === undefined || executed === null) && !argType.optional) {\n return error(new ArgumentNotProvided(i, cmd, msg))\n }\n argList.push(executed)\n }\n\n try {\n await cmd.execute(module, argList)\n } catch (e: any) {\n return error(e)\n }\n } catch (e) {\n return error(e)\n }\n }\n // endregion\n\n // region slash command handler\n private async command(i: CommandInteraction) {\n const error = (error: Error) => this.client.client.emit('applicationCommandError', error, i)\n try {\n const cmd = this.registry.applicationCommands.find((x) => x.command.type === 'CHAT_INPUT' && x.command.name === i.commandName)\n\n if (!cmd) return\n\n const module = this.registry.modules.find((x) => x.applicationCommands.includes(cmd))\n\n if (!module) return\n\n const argList: any[] = []\n\n i.data = {\n cts: this.client,\n command: cmd,\n }\n\n if (!(await this.client.options.slashCommands.check(i))) {\n return error(new SlashCommandGlobalCheckError(i))\n }\n for (const check of cmd.checks) {\n if (!(await check(i))) return error(new ApplicationCommandCheckFailed(i, cmd))\n }\n\n for (let j = 0; j < cmd.params.length; j++) {\n const argType = cmd.params[j]\n const converter = this.registry.applicationCommandArgumentConverters.find((x) => x.type === argType.type)\n\n if (argType.type === CommandInteraction) {\n argList.push(i)\n continue\n }\n\n if (argType.type === CommandInteractionOptionResolver) {\n argList.push(i.options)\n continue\n }\n\n if (argType.name) {\n switch (argType.type) {\n case String:\n argList.push(i.options.getString(argType.name, false) || undefined)\n break\n case Role:\n argList.push(i.options.getRole(argType.name, false) || undefined)\n break\n case User:\n argList.push(i.options.getUser(argType.name, false) || undefined)\n break\n case GuildMember:\n argList.push(i.options.getMember(argType.name, false) || undefined)\n break\n case Boolean:\n argList.push(i.options.getBoolean(argType.name, false) || undefined)\n break\n case Number:\n const opt = i.options.get(argType.name, false)\n if (!opt) {\n argList.push(undefined)\n break\n }\n if (opt.type == 'NUMBER') {\n argList.push(i.options.getNumber(argType.name, false) ?? undefined)\n break\n }\n if (opt.type == 'INTEGER') {\n argList.push(i.options.getInteger(argType.name, false) ?? undefined)\n break\n }\n }\n continue\n }\n\n if (!converter) return error(new ApplicationCommandArgumentConverterNotFound(argType, i))\n\n argList.push(await converter.execute(module, i))\n }\n\n await cmd.execute(module, argList)\n } catch (e) {\n return error(e)\n }\n }\n // endregion\n\n private async messageComponent(i: MessageComponentInteraction) {\n const error = (e: any) => this.client.client.emit('messageComponentError', e)\n\n try {\n const handlers: MessageComponentHandler[] = []\n\n for (const handler of this.registry.messageComponentHandlers) {\n if (handler.componentId === handler.componentId && handler.componentType === i.componentType) {\n handlers.push(handler)\n }\n }\n\n for (const handler of handlers) {\n const module = this.registry.modules.find((x) => x.messageComponentHandlers.includes(handler))\n if (!module) continue\n await handler.run(module, i)\n }\n } catch (e) {\n error(e)\n }\n }\n\n private async userContextMenu(i: UserContextMenuInteraction) {\n const error = (error: Error) => this.client.client.emit('applicationCommandError', error, i)\n try {\n const cmd = this.registry.applicationCommands.find((x) => x.command.type === 'USER' && x.command.name === i.commandName)\n\n if (!cmd) return\n\n const module = this.registry.modules.find((x) => x.applicationCommands.includes(cmd))\n\n if (!module) return\n\n i.data = {\n cts: this.client,\n command: cmd,\n }\n\n for (const check of cmd.checks) {\n if (!(await check(i))) return error(new ApplicationCommandCheckFailed(i, cmd))\n }\n\n let argList: any[] = []\n\n for (let j = 0; j < cmd.params.length; j++) {\n const argType = cmd.params[j]\n const converter = this.registry.applicationCommandArgumentConverters.find((x) => x.type === argType.type)\n\n if (argType.type === UserContextMenuInteraction) {\n argList.push(i)\n continue\n }\n\n if (!converter) return error(new ApplicationCommandArgumentConverterNotFound(argType, i))\n\n argList.push(await converter.execute(module, i))\n }\n\n await cmd.execute(module, argList)\n } catch (e) {\n return error(e)\n }\n }\n\n private async messageContextMenu(i: MessageContextMenuInteraction) {\n const error = (error: Error) => this.client.client.emit('applicationCommandError', error, i)\n try {\n const cmd = this.registry.applicationCommands.find((x) => x.command.type === 'MESSAGE' && x.command.name === i.commandName)\n\n if (!cmd) return\n\n const module = this.registry.modules.find((x) => x.applicationCommands.includes(cmd))\n\n if (!module) return\n\n i.data = {\n cts: this.client,\n command: cmd,\n }\n\n for (const check of cmd.checks) {\n if (!(await check(i))) return error(new ApplicationCommandCheckFailed(i, cmd))\n }\n\n let argList: any[] = []\n\n for (let j = 0; j < cmd.params.length; j++) {\n const argType = cmd.params[j]\n const converter = this.registry.applicationCommandArgumentConverters.find((x) => x.type === argType.type)\n\n if (argType.type === MessageContextMenuInteraction) {\n argList.push(i)\n continue\n }\n\n if (!converter) return error(new ApplicationCommandArgumentConverterNotFound(argType, i))\n\n argList.push(await converter.execute(module, i))\n }\n\n await cmd.execute(module, argList)\n } catch (e) {\n return error(e)\n }\n }\n\n @listener('interactionCreate')\n async interaction(i: Interaction) {\n const error = (e: any) => this.client.client.emit('interactionError', e, i)\n\n try {\n await this.client.options.applicationCommands.beforeRunCheck(i)\n if (i.isCommand()) {\n await this.command(i)\n return\n }\n if (i.isMessageComponent()) {\n await this.messageComponent(i)\n return\n }\n if (i.isMessageContextMenu()) {\n await this.messageContextMenu(i)\n return\n }\n if (i.isUserContextMenu()) {\n await this.userContextMenu(i)\n return\n }\n } catch (e) {\n return error(e)\n }\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from '../structures'\nimport { CommandInteraction, ContextMenuInteraction, Message, MessageComponentInteraction } from 'discord.js'\nimport { KCommandChecks } from '../constants'\n\nexport type Argument = {\n optional: boolean\n type: any\n rest: boolean\n}\n\nexport type CheckFunction = (msg: Message) => boolean | Promise<boolean>\nexport type ApplicationCommandCheckFunction = (i: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction) => boolean | Promise<boolean>\n\nexport class Command {\n execute(module: Module, args: any[]) {\n return this.run.apply(module, args)\n }\n\n get checks(): CheckFunction[] {\n return Reflect.getMetadata(KCommandChecks, this.module, this.key) || []\n }\n\n constructor(\n private run: Function,\n public argTypes: Argument[],\n public name: string,\n public aliases: string[] | ((msg: Message) => string[] | Promise<string[]>),\n public module: Module,\n public key: symbol | string,\n ) {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from '../structures'\nimport { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'\n\nexport class ArgumentConverter {\n execute(module: Module, msg: Message, arg?: string) {\n return this.run.apply(module, [msg, arg])\n }\n\n constructor(public type: object, private run: Function, public withoutParameter: boolean) {}\n}\n\nexport class ApplicationCommandArgumentConverter {\n execute(module: Module, interaction: CommandInteraction | ContextMenuInteraction) {\n return this.run.apply(module, [interaction])\n }\n\n constructor(public type: object, private run: Function) {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandInteraction, ContextMenuInteraction, Message, MessageComponentInteraction } from 'discord.js'\nimport type { CheckFunction, ApplicationCommandCheckFunction } from './Command'\nimport { KCommandChecks, KApplicationCommandChecks } from '../constants'\n\nexport const createCheckDecorator = (\n execute: ((msg: Message) => boolean | Promise<boolean>) | null,\n executeApplicationCommand?: (i: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction) => boolean | Promise<boolean>,\n): MethodDecorator => {\n return (target, propertyKey) => {\n if (execute) {\n let properties: CheckFunction[] = Reflect.getMetadata(KCommandChecks, target, propertyKey)\n if (properties) {\n properties.push(execute)\n } else {\n properties = [execute]\n Reflect.defineMetadata(KCommandChecks, properties, target, propertyKey)\n }\n }\n if (executeApplicationCommand) {\n let properties: ApplicationCommandCheckFunction[] = Reflect.getMetadata(KApplicationCommandChecks, target, propertyKey)\n if (properties) {\n properties.push(executeApplicationCommand)\n } else {\n properties = [executeApplicationCommand]\n Reflect.defineMetadata(KApplicationCommandChecks, properties, target, propertyKey)\n }\n }\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { KArgumentConverters, KCommands, KOptionals, KRest, KSlashArgumentConverters } from '../constants'\nimport { Command } from './Command'\nimport { checkTarget } from '../utils'\nimport { ArgumentConverter, ApplicationCommandArgumentConverter } from './ArgumentConverter'\nimport { Module } from '../structures'\nimport { createCheckDecorator } from './utils'\nimport { GuildMember, Message, PermissionResolvable, Permissions, TextChannel } from 'discord.js'\nimport { ClientPermissionRequired, DMOnlyCommandError, GuildOnlyCommandError, OwnerOnlyCommandError, UserPermissionRequired } from '../error'\n\ntype CommandOptions = {\n name: string\n aliases: string[] | ((msg: Message) => string[])\n optionTypes?: any[]\n}\n\nexport const command = (options: Partial<CommandOptions> = {}) => {\n return (\n target: Object,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: Command[] = Reflect.getMetadata(KCommands, target)\n\n const params: any[] = options.optionTypes ?? Reflect.getMetadata('design:paramtypes', target, propertyKey)\n\n const optionals: number = Reflect.getMetadata(KOptionals, target, propertyKey) || -1\n\n const rest = Reflect.getMetadata(KRest, target, propertyKey) || -1\n\n const command = new Command(\n Reflect.get(target, propertyKey),\n params.map((x, i) => ({\n type: x,\n optional: optionals === -1 ? false : optionals <= i,\n rest: rest === -1 ? false : rest === i,\n })),\n options.name || propertyKey,\n options.aliases || [],\n target as Module,\n propertyKey,\n )\n\n if (properties) {\n properties.push(command)\n } else {\n properties = [command]\n Reflect.defineMetadata(KCommands, properties, target)\n }\n }\n}\n\nexport const argumentConverter = (type: object, requireParameter = true) => {\n return (\n target: Object,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: ArgumentConverter[] = Reflect.getMetadata(KArgumentConverters, target)\n\n const converter = new ArgumentConverter(type, Reflect.get(target, propertyKey), !requireParameter)\n\n if (properties) {\n properties.push(converter)\n } else {\n properties = [converter]\n Reflect.defineMetadata(KArgumentConverters, properties, target)\n }\n }\n}\n\nexport const applicationCommandArgumentConverter = (type: object) => {\n return (\n target: Object,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: ApplicationCommandArgumentConverter[] = Reflect.getMetadata(KSlashArgumentConverters, target)\n\n const converter = new ApplicationCommandArgumentConverter(type, Reflect.get(target, propertyKey))\n\n if (properties) {\n properties.push(converter)\n } else {\n properties = [converter]\n Reflect.defineMetadata(KSlashArgumentConverters, properties, target)\n }\n }\n}\n\nexport const optional: ParameterDecorator = (target, propertyKey, parameterIndex) => {\n checkTarget(target)\n\n Reflect.defineMetadata(KOptionals, parameterIndex, target, propertyKey)\n}\n\nexport const rest: ParameterDecorator = (target, propertyKey, parameterIndex) => {\n checkTarget(target)\n\n const params: any[] = Reflect.getMetadata('design:paramtypes', target, propertyKey)\n\n if (params.length - 1 !== parameterIndex) throw new Error('Rest decorator must be used at last argument.')\n\n if (params[parameterIndex] !== String) throw new Error('Rest argument type must be \"String\"')\n\n Reflect.defineMetadata(KRest, parameterIndex, target, propertyKey)\n}\n\nexport const ownerOnly = createCheckDecorator(\n (msg) => {\n if (msg.data.cts.owners.includes(msg.author.id)) return true\n throw new OwnerOnlyCommandError()\n },\n (i) => {\n if (i.data.cts.owners.includes(i.user.id)) return true\n throw new OwnerOnlyCommandError()\n },\n)\n\nexport const guildOnly = createCheckDecorator(\n (msg) => {\n if (!!msg.guild) return true\n throw new GuildOnlyCommandError()\n },\n (i) => {\n if (!!i.guildId) return true\n throw new GuildOnlyCommandError()\n },\n)\n\nexport const dmOnly = createCheckDecorator(\n (msg) => {\n if (!msg.guild) return true\n throw new DMOnlyCommandError()\n },\n (i) => {\n if (!i.guildId) return true\n throw new DMOnlyCommandError()\n },\n)\n\nexport const requireUserPermissions = (permission: PermissionResolvable) =>\n createCheckDecorator(\n (msg) => {\n if (!msg.guild || !msg.member) throw new Error('This command must be used in guild.')\n if (msg.member.permissionsIn(msg.channel as TextChannel).has(permission)) {\n return true\n }\n throw new UserPermissionRequired(msg.member, new Permissions(permission))\n },\n (i) => {\n if (!i.guild || !i.member) throw new Error('This command must be used in guild.')\n if (!(i.member instanceof GuildMember) || i.member.permissionsIn(i.channel as TextChannel).has(permission)) {\n return true\n }\n throw new UserPermissionRequired(i.member, new Permissions(permission))\n },\n )\n\nexport const requireClientPermissions = (permission: PermissionResolvable) =>\n createCheckDecorator(\n (msg) => {\n if (!msg.guild) throw new Error('This command must be used in guild.')\n if (msg.guild.me!.permissionsIn(msg.channel as TextChannel).has(permission)) {\n return true\n }\n throw new ClientPermissionRequired(new Permissions(permission))\n },\n (i) => {\n if (!i.guild) throw new Error('This command must be used in guild.')\n if (i.guild.me!.permissionsIn(i.channel as TextChannel).has(permission)) {\n return true\n }\n throw new ClientPermissionRequired(new Permissions(permission))\n },\n )\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport enum CoolDownType {\n USER,\n CHANNEL,\n GUILD,\n ROLE,\n CATEGORY,\n MEMBER,\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { createCheckDecorator } from '../utils'\nimport { CoolDownType } from './type'\nimport { DMChannel, GuildMember, TextChannel } from 'discord.js'\nimport { CoolDownError } from './error'\n\nexport const coolDown = (type: CoolDownType, seconds: number) =>\n createCheckDecorator(\n async (msg) => {\n const a = msg.data.cts.coolDownAdapter\n const getKey = (): string => {\n switch (type) {\n case CoolDownType.USER:\n return msg.author.id\n case CoolDownType.GUILD:\n return (msg.guild || msg.author).id\n case CoolDownType.CHANNEL:\n return msg.channel.id\n case CoolDownType.MEMBER:\n return `${msg.guild?.id}.${msg.author.id}`\n case CoolDownType.ROLE:\n return (msg.channel instanceof DMChannel ? msg.channel : msg.member!.roles.highest).id\n case CoolDownType.CATEGORY:\n return ((msg.channel as TextChannel).parent || msg.channel).id\n }\n }\n const key = getKey() + '-command-' + msg.data.command?.name\n const data = await a.get(key)\n const now = Date.now()\n if (!data || !(now - data < seconds * 1000)) {\n await a.set(key, now)\n return true\n }\n throw new CoolDownError(new Date(data + seconds * 1000))\n },\n async (i) => {\n if (i.isMessageComponent()) return true\n const a = i.data.cts.coolDownAdapter\n const getKey = (): string => {\n switch (type) {\n case CoolDownType.USER:\n return i.user.id + '.user'\n case CoolDownType.GUILD:\n return (i.guild || i.user).id + '.guild'\n case CoolDownType.CHANNEL:\n return i.channel!.id + '.channel'\n case CoolDownType.MEMBER:\n return `${i.guild?.id}.${i.user.id}`\n case CoolDownType.ROLE:\n return (i.channel instanceof DMChannel ? i.channel : (i.member as GuildMember)!.roles.highest).id + '.role'\n case CoolDownType.CATEGORY:\n return ((i.channel as TextChannel).parent || i.channel!).id + '.category'\n }\n }\n const key = getKey() + '-appCommand-' + i.commandName\n const data = await a.get(key)\n const now = Date.now()\n if (!data || !(now - data < seconds * 1000)) {\n await a.set(key, now)\n return true\n }\n throw new CoolDownError(new Date(data + seconds * 1000))\n },\n )\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class CoolDownError extends Error {\n constructor(public endsAt: Date) {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Collection } from 'discord.js'\n\nexport interface CoolDownAdapter {\n get(id: string): Promise<number | undefined>\n set(id: string, value: number): Promise<void>\n}\n\nexport class DefaultCoolDownAdapter implements CoolDownAdapter {\n map = new Collection<string, number>()\n async get(id: string): Promise<number | undefined> {\n return this.map.get(id)\n }\n\n async set(id: string, value: number) {\n this.map.set(id, value)\n return\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { BuiltInModule } from './BuiltInModule'\nimport { argumentConverter } from '../command'\nimport { Client, GuildMember, Message, User, Role } from 'discord.js'\nimport { CommandClient } from '../structures'\n\nexport class BuiltinCommandConverters extends BuiltInModule {\n client: Client\n\n constructor(private cts: CommandClient) {\n super()\n this.client = cts.client\n }\n\n @argumentConverter(Message, false)\n message(msg: Message) {\n return msg\n }\n\n @argumentConverter(String)\n string(msg: Message, arg: string) {\n return arg\n }\n\n getUserIDByMention(mention: string): `${bigint}` | undefined {\n if (!mention) return\n if (mention.startsWith('<@') && mention.endsWith('>')) {\n mention = mention.slice(2, -1)\n if (mention.startsWith('!')) {\n mention = mention.slice(1)\n }\n return mention as `${bigint}`\n }\n }\n\n @argumentConverter(User)\n user(msg: Message, value: string): User | null {\n let user = this.client.users.cache.get(value)\n if (user) return user\n user = this.client.users.cache.find((x) => x.tag === value || x.username === value)\n if (user) return user\n const id = this.getUserIDByMention(value)\n if (!id) return null\n user = this.client.users.cache.get(id)\n return user || null\n }\n\n @argumentConverter(GuildMember)\n member(msg: Message, value: string): GuildMember | undefined {\n let user = msg.guild?.members.cache.get(value)\n if (!user) return user\n user = msg.guild?.members.cache.find((x) => x.user.tag === value)\n if (user) return user\n const id = this.getUserIDByMention(value)\n if (!id) return\n user = msg.guild?.members.cache.get(id)\n return user || undefined\n }\n\n @argumentConverter(Number)\n number(msg: Message, value: string) {\n const n = Number(value)\n return isNaN(n) ? undefined : n\n }\n\n getRoleIDByMention(mention: string): `${bigint}` | undefined {\n if (!mention) return\n if (mention.startsWith('<@') && mention.endsWith('>')) {\n mention = mention.slice(2, -1)\n if (mention.startsWith('&')) {\n mention = mention.slice(1)\n }\n return mention as `${bigint}`\n }\n }\n\n @argumentConverter(Role)\n role(msg: Message, value: string): Role | undefined {\n const id = this.getRoleIDByMention(value)\n if (!id) return\n const role = msg.guild?.roles.cache.get(id)\n return role || undefined\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { BuiltInModule } from './BuiltInModule'\nimport { Client } from 'discord.js'\nimport { CommandClient } from '../structures'\n\nexport class BuiltinApplicationCommandConverters extends BuiltInModule {\n client: Client\n\n constructor(private cts: CommandClient) {\n super()\n this.client = cts.client\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { ApplicationCommandDataResolvable, Collection, Snowflake } from 'discord.js'\nimport { checkTarget } from '../utils'\nimport { KSlashCommandOptions, KApplicationCommands } from '../constants'\nimport { Module } from '../structures'\nimport { AppCommand } from './AppCommand'\n\ntype ApplicationCommandOptions = {\n guild: Snowflake | Snowflake[]\n optionTypes?: any[]\n}\n\nexport const applicationCommand = (opt: Partial<ApplicationCommandOptions> & { command: ApplicationCommandDataResolvable }) => {\n return (\n target: Object,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: AppCommand[] = Reflect.getMetadata(KApplicationCommands, target)\n\n const params: any[] = opt.optionTypes ?? Reflect.getMetadata('design:paramtypes', target, propertyKey)\n\n const options: Collection<number, string> = Reflect.getMetadata(KSlashCommandOptions, target, propertyKey) || new Collection<number, string>()\n\n const command = new AppCommand(\n opt.command,\n Reflect.get(target, propertyKey),\n target as Module,\n params.map((x, i) => ({\n type: x,\n name: options.get(i),\n })),\n opt.guild,\n propertyKey,\n )\n\n if (properties) {\n properties.push(command)\n } else {\n properties = [command]\n Reflect.defineMetadata(KApplicationCommands, properties, target)\n }\n }\n}\n\nexport const option = (key: string): ParameterDecorator => (target, propertyKey, parameterIndex) => {\n checkTarget(target)\n\n let properties: Collection<number, string> = Reflect.getMetadata(KSlashCommandOptions, target, propertyKey)\n\n if (!properties) {\n properties = new Collection<number, string>()\n Reflect.defineMetadata(KSlashCommandOptions, properties, target, propertyKey)\n }\n\n properties.set(parameterIndex, key)\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from '../structures'\nimport { ApplicationCommandDataResolvable, Snowflake } from 'discord.js'\nimport { KApplicationCommandChecks } from '../constants'\nimport { ApplicationCommandCheckFunction } from '../command'\n\nexport type AppCommandArgument = {\n type: any\n name?: string\n}\n\nexport class AppCommand {\n get checks(): ApplicationCommandCheckFunction[] {\n return Reflect.getMetadata(KApplicationCommandChecks, this.module, this.key) || []\n }\n\n execute(module: Module, args: any[]) {\n return this.run.apply(module, args)\n }\n\n constructor(\n public command: ApplicationCommandDataResolvable,\n private run: Function,\n public module: Module,\n public params: AppCommandArgument[],\n public guild: Snowflake | Snowflake[] | undefined,\n private key: string | symbol,\n ) {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { MessageComponentInteraction, MessageComponentType } from 'discord.js'\nimport { Module } from '../structures'\n\nexport type MessageComponentExecutor = (i: MessageComponentInteraction) => void | Promise<void>\n\nexport class MessageComponentHandler {\n constructor(public componentId: string, public componentType: Exclude<MessageComponentType, 'ACTION_ROW'>, public execute: MessageComponentExecutor) {}\n\n run(module: Module, i: MessageComponentInteraction) {\n return this.execute.apply(module, [i])\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { MessageComponentExecutor, MessageComponentHandler } from './base'\nimport { checkTarget } from '../utils'\nimport { KMessageComponentHandlers } from '../constants'\n\nexport class ButtonInteractionHandler extends MessageComponentHandler {\n constructor(id: string, execute: MessageComponentExecutor) {\n super(id, 'BUTTON', execute)\n }\n}\n\nexport const messageButton = (id: string): MethodDecorator => {\n return (target, propertyKey) => {\n checkTarget(target)\n\n const handler = new ButtonInteractionHandler(id, Reflect.get(target, propertyKey))\n\n let properties: MessageComponentHandler[] = Reflect.getMetadata(KMessageComponentHandlers, target)\n\n if (properties) {\n properties.push(handler)\n } else {\n properties = [handler]\n Reflect.defineMetadata(KMessageComponentHandlers, properties, target)\n }\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { MessageComponentExecutor, MessageComponentHandler } from './base'\nimport { checkTarget } from '../utils'\nimport { KMessageComponentHandlers } from '../constants'\n\nexport class SelectMenuInteractionHandler extends MessageComponentHandler {\n constructor(id: string, execute: MessageComponentExecutor) {\n super(id, 'SELECT_MENU', execute)\n }\n}\n\nexport const messageSelectMenu = (id: string): MethodDecorator => {\n return (target, propertyKey) => {\n checkTarget(target)\n\n const handler = new SelectMenuInteractionHandler(id, Reflect.get(target, propertyKey))\n\n let properties: MessageComponentHandler[] = Reflect.getMetadata(KMessageComponentHandlers, target)\n\n if (properties) {\n properties.push(handler)\n } else {\n properties = [handler]\n Reflect.defineMetadata(KMessageComponentHandlers, properties, target)\n }\n }\n}\n"],"mappings":"m+BAAA,6nCAIA,OAAO,4BCAA,GAAM,GAAY,OAAO,uBAEnB,EAAuB,OAAO,6BAE9B,GAAuB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C,iBCNpB,oBAA4C,EAAuB,aAC3D,EAAY,EAAmC,CACzD,MAAM,EAAI,cAAe,KAFvB,qCAMC,GAAM,IAAiB,EAAI,GAC1B,CAAE,EAAQ,IAAgB,CAC9B,EAAY,GAEZ,GAAM,GAAU,GAAI,IAA6B,EAAI,QAAQ,IAAI,EAAQ,IAErE,EAAwC,QAAQ,YAAY,EAA2B,GAE3F,AAAI,EACF,EAAW,KAAK,GAEhB,GAAa,CAAC,GACd,QAAQ,eAAe,EAA2B,EAAY,KAZtC","names":[]}
1
+ {"version":3,"sources":["../src/home/pikokr/Desktop/Programming/command.ts/src/index.ts","../src/home/pikokr/Desktop/Programming/command.ts/src/constants.ts","../src/structures/home/pikokr/Desktop/Programming/command.ts/src/structures/Module.ts","../src/structures/home/pikokr/Desktop/Programming/command.ts/src/structures/CommandClient.ts","../src/structures/home/pikokr/Desktop/Programming/command.ts/src/structures/Registry.ts","../src/error/home/pikokr/Desktop/Programming/command.ts/src/error/InvalidTargetError.ts","../src/error/home/pikokr/Desktop/Programming/command.ts/src/error/ModuleError.ts","../src/error/home/pikokr/Desktop/Programming/command.ts/src/error/ArgumentNotProvided.ts","../src/error/home/pikokr/Desktop/Programming/command.ts/src/error/ArgumentConverterNotFound.ts","../src/error/home/pikokr/Desktop/Programming/command.ts/src/error/CommandCheckFailed.ts","../src/error/home/pikokr/Desktop/Programming/command.ts/src/error/PermissionRequired.ts","../src/error/checks/home/pikokr/Desktop/Programming/command.ts/src/error/checks/OwnerOnlyCommand.ts","../src/error/checks/home/pikokr/Desktop/Programming/command.ts/src/error/checks/GuildOnlyCommand.ts","../src/error/checks/home/pikokr/Desktop/Programming/command.ts/src/error/checks/DMOnlyCommand.ts","../src/error/checks/home/pikokr/Desktop/Programming/command.ts/src/error/checks/SlashCommandGlobalCheckError.ts","../src/error/home/pikokr/Desktop/Programming/command.ts/src/error/CommandNotFound.ts","../src/builtinModules/home/pikokr/Desktop/Programming/command.ts/src/builtinModules/BuiltInModule.ts","../src/listener/home/pikokr/Desktop/Programming/command.ts/src/listener/Listener.ts","../src/home/pikokr/Desktop/Programming/command.ts/src/utils.ts","../src/listener/home/pikokr/Desktop/Programming/command.ts/src/listener/decorator.ts","../src/builtinModules/home/pikokr/Desktop/Programming/command.ts/src/builtinModules/CommandHandler.ts","../src/command/home/pikokr/Desktop/Programming/command.ts/src/command/Command.ts","../src/command/home/pikokr/Desktop/Programming/command.ts/src/command/ArgumentConverter.ts","../src/command/home/pikokr/Desktop/Programming/command.ts/src/command/utils.ts","../src/command/home/pikokr/Desktop/Programming/command.ts/src/command/decorator.ts","../src/command/cooldown/home/pikokr/Desktop/Programming/command.ts/src/command/cooldown/type.ts","../src/command/cooldown/home/pikokr/Desktop/Programming/command.ts/src/command/cooldown/decorator.ts","../src/command/cooldown/home/pikokr/Desktop/Programming/command.ts/src/command/cooldown/error.ts","../src/command/cooldown/home/pikokr/Desktop/Programming/command.ts/src/command/cooldown/adapter.ts","../src/builtinModules/home/pikokr/Desktop/Programming/command.ts/src/builtinModules/BuiltinCommandConverters.ts","../src/builtinModules/home/pikokr/Desktop/Programming/command.ts/src/builtinModules/BuiltinApplicationCommandConverters.ts","../src/applicationCommand/home/pikokr/Desktop/Programming/command.ts/src/applicationCommand/decorator.ts","../src/applicationCommand/home/pikokr/Desktop/Programming/command.ts/src/applicationCommand/AppCommand.ts","../src/messageComponents/home/pikokr/Desktop/Programming/command.ts/src/messageComponents/base.ts","../src/messageComponents/home/pikokr/Desktop/Programming/command.ts/src/messageComponents/button.ts","../src/messageComponents/home/pikokr/Desktop/Programming/command.ts/src/messageComponents/selectMenu.ts"],"sourcesContent":["/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport 'reflect-metadata'\nimport './typings'\n\nexport * from './interface'\nexport * from './structures'\nexport * from './error'\nexport * from './command'\nexport * from './listener'\nexport * from './builtinModules/BuiltInModule'\nexport * from './applicationCommand'\nexport * from './messageComponents'\nexport * from './error'\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport const KCommands = Symbol('Command.TS Commands')\n\nexport const KApplicationCommands = Symbol('Command.TS Slash Commands')\n\nexport const KSlashCommandOptions = Symbol('Command.TS Slash Command Options')\n\nexport const KListeners = Symbol('Command.TS Listeners')\n\nexport const KModulePath = Symbol('Command.TS Module Path')\n\nexport const KListenerExecuteCache = Symbol('Command.TS Module Identifier')\n\nexport const KBuiltInModule = Symbol('Command.TS Built-In Module')\n\nexport const KOptionals = Symbol('Command.TS Optional Parameters')\n\nexport const KRest = Symbol('Command.TS Rest Parameter')\n\nexport const KArgumentConverters = Symbol('Command.TS Argument Converter')\n\nexport const KSlashArgumentConverters = Symbol('Command.TS Slash Argument Converter')\n\nexport const KCommandChecks = Symbol('Command.TS Command Checks')\n\nexport const KApplicationCommandChecks = Symbol('Command.TS Slash Command Checks')\n\nexport const KMessageComponentHandlers = Symbol('Command.TS Message Component Handlers')\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { KArgumentConverters, KCommands, KListeners, KMessageComponentHandlers, KModulePath, KSlashArgumentConverters, KApplicationCommands } from '../constants'\nimport type { Command } from '../command'\nimport { Listener } from '../listener'\nimport { ArgumentConverter, ApplicationCommandArgumentConverter } from '../command'\nimport { AppCommand } from '../applicationCommand'\nimport { CommandClient } from './CommandClient'\nimport { MessageComponentHandler } from '../messageComponents/base'\n\nexport abstract class Module {\n commandClient!: CommandClient\n\n get logger() {\n return this.commandClient.logger.getChildLogger({\n name: this.constructor.name,\n })\n }\n\n get commands(): Command[] {\n return Reflect.getMetadata(KCommands, this) || []\n }\n\n get listeners(): Listener[] {\n return Reflect.getMetadata(KListeners, this) || []\n }\n\n get argumentConverters(): ArgumentConverter[] {\n return Reflect.getMetadata(KArgumentConverters, this) || []\n }\n\n get applicationCommandArgumentConverters(): ApplicationCommandArgumentConverter[] {\n return Reflect.getMetadata(KSlashArgumentConverters, this) || []\n }\n\n get applicationCommands(): AppCommand[] {\n return Reflect.getMetadata(KApplicationCommands, this) || []\n }\n\n get messageComponentHandlers(): MessageComponentHandler[] {\n return Reflect.getMetadata(KMessageComponentHandlers, this) || []\n }\n\n get path(): string | undefined {\n return Reflect.getMetadata(KModulePath, this)\n }\n\n load() {}\n unload() {}\n beforeReload() {}\n afterReload() {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport _ from 'lodash'\nimport { Registry } from './Registry'\nimport { Client, CommandInteraction, Interaction, Message, Snowflake, User } from 'discord.js'\nimport { BuiltinCommandConverters, BuiltinApplicationCommandConverters, CommandHandler } from '../builtinModules'\nimport { CoolDownAdapter, DefaultCoolDownAdapter } from '../command'\nimport { Logger } from 'tslog'\n\nexport interface CommandOptions {\n prefix: string | ((msg: any) => string | Promise<string | string[]> | string[]) | string[]\n check: (msg: Message) => boolean | Promise<boolean>\n}\n\nexport interface SlashCommandOptions {\n check: (i: CommandInteraction) => boolean | Promise<boolean>\n}\n\nexport interface ApplicationCommandOptions {\n guild?: Snowflake | Snowflake[]\n autoSync: boolean\n beforeRunCheck: (i: Interaction) => void | Promise<void>\n}\n\nexport interface CommandClientOptions {\n command: CommandOptions\n owners: 'auto' | Snowflake[]\n slashCommands: SlashCommandOptions\n applicationCommands: ApplicationCommandOptions\n}\n\nexport interface CommandClientOptionsParam {\n command: Partial<CommandOptions>\n owners: 'auto' | string[]\n slashCommands: Partial<SlashCommandOptions>\n applicationCommands: Partial<ApplicationCommandOptions>\n}\n\nexport class CommandClient {\n options: CommandClientOptions\n owners: string[] = []\n registry = new Registry(this)\n client: Client\n coolDownAdapter: CoolDownAdapter\n logger: Logger\n\n private _isReady = false\n\n private async fetchOwners(): Promise<string[]> {\n await this.client.application?.fetch()\n const o = this.client.application?.owner\n if (!o) return []\n if (o instanceof User) return [o.id]\n else return o.members.map((x) => x.id)\n }\n\n async ready() {\n if (this._isReady) return\n this._isReady = true\n if (this.options.owners === 'auto') {\n const owners = await this.fetchOwners()\n this.owners.push(...owners)\n }\n if (this.options.applicationCommands.autoSync) {\n await this.registry.syncCommands()\n }\n }\n\n constructor({ client, coolDownAdapter, logger, ...options }: Partial<CommandClientOptionsParam> & { client: Client; coolDownAdapter?: CoolDownAdapter; logger?: Logger }) {\n this.client = client\n this.coolDownAdapter = coolDownAdapter || new DefaultCoolDownAdapter()\n this.options = _.merge<CommandClientOptions, Partial<CommandClientOptionsParam>>(\n {\n command: {\n prefix: '!',\n check: () => true,\n },\n owners: 'auto',\n slashCommands: {\n check: () => true,\n },\n applicationCommands: {\n autoSync: false,\n beforeRunCheck: () => {},\n },\n },\n options,\n )\n\n this.logger = logger ?? new Logger({ name: 'Command.TS' })\n\n if (this.options.owners !== 'auto') {\n this.owners = this.options.owners\n }\n\n this.client.once('ready', () => this.ready())\n this.registry.registerModule(new CommandHandler(this.registry))\n this.registry.registerModule(new BuiltinCommandConverters(this))\n this.registry.registerModule(new BuiltinApplicationCommandConverters(this))\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandClient } from './CommandClient'\nimport { Module } from './Module'\nimport { Command, ApplicationCommandArgumentConverter } from '../command'\nimport { KBuiltInModule, KListenerExecuteCache, KModulePath } from '../constants'\nimport path from 'path'\nimport { InvalidModuleError, InvalidTargetError, ModuleLoadError } from '../error'\nimport { Collection, Guild } from 'discord.js'\nimport walkSync from 'walk-sync'\nimport { ArgumentConverter } from '../command'\nimport { AppCommand } from '../applicationCommand'\nimport * as fs from 'fs'\nimport { MessageComponentHandler } from '../messageComponents/base'\n\ntype ListenerExecutor = {\n event: string\n execute: any\n}\n\nexport class Registry {\n constructor(public client: CommandClient) {}\n\n modules: Collection<symbol, Module> = new Collection()\n\n private get logger() {\n return this.client.logger.getChildLogger({\n name: 'Registry',\n })\n }\n\n get commands(): Command[] {\n const result: Command[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.commands)\n }\n\n return result\n }\n\n get argumentConverters(): ArgumentConverter[] {\n const result: ArgumentConverter[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.argumentConverters)\n }\n\n return result\n }\n\n get applicationCommandArgumentConverters(): ApplicationCommandArgumentConverter[] {\n const result: ApplicationCommandArgumentConverter[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.applicationCommandArgumentConverters)\n }\n\n return result\n }\n\n get applicationCommands(): AppCommand[] {\n const result: AppCommand[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.applicationCommands)\n }\n\n return result\n }\n\n get messageComponentHandlers(): MessageComponentHandler[] {\n const result: MessageComponentHandler[] = []\n\n for (const [, module] of this.modules) {\n result.push(...module.messageComponentHandlers)\n }\n\n return result\n }\n\n registerModule(module: Module) {\n module.commandClient = this.client\n\n this.modules.set(Symbol(module.constructor.name), module)\n\n const list: ListenerExecutor[] = []\n\n for (const listener of module.listeners) {\n const bound = listener.execute.bind(module)\n list.push({ event: listener.name, execute: bound })\n this.client.client.on(listener.name, bound)\n }\n\n Reflect.defineMetadata(KListenerExecuteCache, list, module)\n\n return module\n }\n\n async loadModulesIn(dir: string, absolute = false) {\n let p = absolute ? dir : path.join(require.main!.path, dir)\n\n for (const i of walkSync(p)) {\n if (fs.lstatSync(path.join(p, i)).isFile()) {\n if (i.endsWith('.map')) continue\n await this.loadModule(path.join(p, i), true)\n }\n }\n }\n\n async loadModule(file: string, absolute: boolean = false) {\n let p = absolute ? file : path.join(require.main!.path, file)\n\n let m\n\n try {\n m = require(p)\n } catch (e: any) {\n throw new ModuleLoadError(p, e)\n }\n\n if (m.loaded) throw new Error('MODULE_ALREADY_LOADED')\n\n if (!m.install) throw new InvalidModuleError('Install function not found.')\n\n const mod = m.install(this.client)\n\n if (!(mod instanceof Module)) throw new InvalidTargetError()\n\n Reflect.defineMetadata(KModulePath, require.resolve(p), mod)\n\n this.registerModule(mod)\n\n await mod.load()\n\n m.loaded = true\n\n return mod\n }\n\n async syncCommands() {\n this.logger.debug(`Syncing commands...`)\n const commands = this.applicationCommands.filter((x) => !x.guild)\n const guild = this.client.options.applicationCommands.guild\n const syncForGuild = async (g: Guild, commands: AppCommand[]) => {\n this.logger.debug(`Syncing for guild ${g.name}(${g.id})`)\n const commandsToRegister = commands.map((x) => x.command)\n this.logger.debug(`Command List: ${commandsToRegister.map((x) => x.name).join(', ')}`)\n await g.commands.set(commandsToRegister)\n }\n const commandsWithGuild = this.applicationCommands.filter((x) => !!x.guild)\n\n if (guild) {\n if (typeof guild === 'string') {\n await syncForGuild(await this.client.client.guilds.fetch(guild), [\n ...commands,\n ...commandsWithGuild.filter((x) => x.guild && (typeof x.guild === 'string' ? guild === x.guild : x.guild.includes(guild))),\n ])\n } else {\n for (const g of guild) {\n await syncForGuild(await this.client.client.guilds.fetch(g), [\n ...commands,\n ...commandsWithGuild.filter((x) => x.guild && (typeof x.guild === 'string' ? g === x.guild : x.guild.includes(g))),\n ])\n }\n }\n } else {\n this.logger.debug('Syncing global...')\n await this.client.client.application?.commands.set(commands.map((x) => x.command))\n }\n\n const guilds = new Set<string>()\n\n for (const command of commandsWithGuild) {\n if (!command.guild) continue\n if (typeof command.guild === 'string') {\n guilds.add(command.guild)\n } else {\n for (const guild of command.guild) {\n guilds.add(guild)\n }\n }\n }\n\n for (const guild of guilds) {\n if (this.client.options.applicationCommands.guild?.includes(guild)) continue\n await syncForGuild(\n await this.client.client.guilds.fetch(guild),\n commandsWithGuild.filter((x) => x.guild && (typeof x.guild === 'string' ? guild === x.guild : x.guild.includes(guild))),\n )\n }\n\n this.logger.debug('Syncing ended.')\n }\n\n async unregisterModule(module: Module) {\n if (Reflect.getMetadata(KBuiltInModule, module)) throw new Error('Built-in modules cannot be unloaded')\n const symbol = this.modules.findKey((x) => x === module)\n if (!symbol) return module\n await module.unload()\n const list: ListenerExecutor[] = Reflect.getMetadata(KListenerExecuteCache, module)\n for (const listener of list) {\n this.client.client.removeListener(listener.event, listener.execute)\n }\n this.modules.delete(symbol)\n return module\n }\n\n async unloadModule(module: Module) {\n const p = Reflect.getMetadata(KModulePath, module)\n\n if (!p) throw new InvalidModuleError('This module is not loaded by loadModule.')\n\n await this.unregisterModule(module)\n delete require.cache[p]\n }\n\n async reloadModule(module: Module) {\n await module.beforeReload()\n const p = Reflect.getMetadata(KModulePath, module)\n await this.unloadModule(module)\n const mod = await this.loadModule(p, true)\n await mod.afterReload()\n return true\n }\n\n async reloadAll() {\n const results: {\n path: string\n success: boolean\n error?: Error\n }[] = []\n\n for (const [, module] of this.modules.filter((x) => !!x.path && !Reflect.getMetadata(KBuiltInModule, x))) {\n try {\n await this.reloadModule(module)\n results.push({\n path: module.path!,\n success: true,\n })\n } catch (e: any) {\n results.push({\n error: e,\n path: module.path!,\n success: false,\n })\n }\n }\n return results\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class InvalidTargetError extends Error {\n constructor() {\n super('Class does not extend \"Module\" class.')\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class ModuleLoadError extends Error {\n constructor(file: string, public error: Error) {\n super('Failed to load module ' + file)\n }\n}\n\nexport class InvalidModuleError extends Error {}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Message } from 'discord.js'\nimport { Command } from '../command'\n\nexport class ArgumentNotProvided extends Error {\n constructor(public index: number, public command: Command, public msg: Message) {\n super(`Required argument #${index} not provided.`)\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'\nimport type { Argument } from '../command'\nimport type { AppCommandArgument } from '../applicationCommand'\n\nexport class ArgumentConverterNotFound extends Error {\n constructor(public type: Argument, public msg: Message) {\n super(`Argument converter ${type.type.name} not found.`)\n }\n}\nexport class ApplicationCommandArgumentConverterNotFound extends Error {\n constructor(public type: AppCommandArgument, public interaction: CommandInteraction | ContextMenuInteraction) {\n super(`Argument converter ${type.type.name} not found.`)\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandInteraction, ContextMenuInteraction, Message, MessageComponentInteraction } from 'discord.js'\nimport { Command } from '../command'\nimport { AppCommand } from '../applicationCommand'\n\nexport class CommandCheckFailed extends Error {\n constructor(public msg: Message, public command: Command) {\n super()\n }\n}\n\nexport class ApplicationCommandCheckFailed extends Error {\n constructor(public interaction: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction, public command: AppCommand) {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { GuildMember, Permissions } from 'discord.js'\n\nexport class UserPermissionRequired extends Error {\n constructor(public user: GuildMember, public permissions: Permissions) {\n super()\n }\n}\n\nexport class ClientPermissionRequired extends Error {\n constructor(public permissions: Permissions) {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class OwnerOnlyCommandError extends Error {\n constructor() {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class GuildOnlyCommandError extends Error {\n constructor() {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class DMOnlyCommandError extends Error {\n constructor() {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandInteraction } from 'discord.js'\n\nexport class SlashCommandGlobalCheckError extends Error {\n constructor(public i: CommandInteraction) {\n super('Slash command before-run check failed.')\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Message } from 'discord.js'\n\nexport class CommandNotFound extends Error {\n constructor(public commandName: string, public msg: Message, public args: string[]) {\n super(`Command ${commandName} not found.`)\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from '../structures'\nimport { KBuiltInModule } from '../constants'\n\nexport class BuiltInModule extends Module {\n constructor() {\n super()\n Reflect.defineMetadata(KBuiltInModule, true, this)\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class Listener {\n constructor(public name: string, public execute: Function) {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from './structures'\nimport { InvalidTargetError } from './error'\n\nexport const checkTarget = (target: Object) => {\n if (!(target instanceof Module)) throw new InvalidTargetError()\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { checkTarget } from '../utils'\nimport { KListeners } from '../constants'\nimport { Listener } from './Listener'\nimport { Module } from '../structures'\n\nexport const listener = (event: string) => {\n return (\n target: Module,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: Listener[] = Reflect.getMetadata(KListeners, target)\n\n const listener = new Listener(event, Reflect.get(target, propertyKey))\n\n if (properties) {\n properties.push(listener)\n } else {\n properties = [listener]\n Reflect.defineMetadata(KListeners, properties, target)\n }\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { BuiltInModule } from './BuiltInModule'\nimport { Registry } from '../structures'\nimport { listener } from '../listener'\nimport {\n CommandInteraction,\n CommandInteractionOptionResolver,\n GuildMember,\n Interaction,\n Message,\n MessageComponentInteraction,\n MessageContextMenuInteraction,\n Role,\n User,\n UserContextMenuInteraction,\n} from 'discord.js'\nimport { CommandClient } from '../structures'\nimport { Command } from '../command'\nimport { ArgumentConverterNotFound, ArgumentNotProvided, CommandCheckFailed, ApplicationCommandArgumentConverterNotFound, ApplicationCommandCheckFailed } from '../error'\nimport { CommandNotFound } from '../error/CommandNotFound'\nimport { SlashCommandGlobalCheckError } from '../error/checks/SlashCommandGlobalCheckError'\nimport { MessageComponentHandler } from '../messageComponents/base'\n\nexport class CommandHandler extends BuiltInModule {\n private readonly client: CommandClient\n\n constructor(private registry: Registry) {\n super()\n this.client = registry.client\n }\n\n // region message command handler\n @listener('messageCreate')\n async message(msg: Message) {\n const error = (error: Error) => this.client.client.emit('commandError', error, msg)\n\n try {\n const prefixList: string[] | string =\n typeof this.client.options.command.prefix === 'string'\n ? this.client.options.command.prefix\n : typeof this.client.options.command.prefix === 'function'\n ? await this.client.options.command.prefix(msg)\n : this.client.options.command.prefix\n let prefix: string\n if (typeof prefixList === 'object') {\n const res = prefixList.find((x) => msg.content.includes(x))\n\n if (!res) return\n\n prefix = res\n } else {\n if (!msg.content.includes(prefixList)) return\n prefix = prefixList\n }\n\n if (!msg.content.startsWith(prefix)) return\n\n const args = msg.content.slice(prefix.length).split(' ')\n\n const command = args.shift()\n\n if (!command) return\n\n let cmd: Command | null = null\n\n for (const c of this.registry.commands) {\n const aliases = typeof c.aliases === 'function' ? await c.aliases(msg) : c.aliases\n if ([...aliases, c.name].some((x) => x === command)) {\n cmd = c\n break\n }\n }\n\n msg.data = {\n cts: this.client,\n command: cmd,\n prefix: prefix,\n }\n\n if (!(await this.client.options.command.check(msg))) {\n return\n }\n\n if (!cmd) return error(new CommandNotFound(command, msg, args))\n\n const module = this.registry.modules.find((x) => x.commands.includes(cmd!))\n\n if (!module) return\n\n const argList: any[] = []\n\n for (const check of cmd.checks) {\n if (!(await check(msg))) return error(new CommandCheckFailed(msg, cmd))\n }\n\n for (let i = 0; i < cmd.argTypes.length; i++) {\n const argType = cmd.argTypes[i]\n const converter = this.registry.argumentConverters.find((x) => x.type === argType.type)\n\n if (argType.rest) {\n const i = args.join(' ')\n argList.push(i)\n break\n }\n\n if (!converter) return error(new ArgumentConverterNotFound(argType, msg))\n\n const converterModule = this.registry.modules.find((x) => x.argumentConverters.includes(converter))\n\n if (!converterModule) return error(new ArgumentConverterNotFound(argType, msg))\n\n if (converter.withoutParameter) {\n argList.push(await converter.execute(converterModule, msg))\n continue\n }\n const arg = args.shift()\n if (argType.optional && !arg) {\n break\n }\n if (!arg) {\n return error(new ArgumentNotProvided(i, cmd, msg))\n }\n const executed = await converter.execute(converterModule, msg, arg)\n if ((executed === undefined || executed === null) && !argType.optional) {\n return error(new ArgumentNotProvided(i, cmd, msg))\n }\n argList.push(executed)\n }\n\n try {\n await cmd.execute(module, argList)\n } catch (e: any) {\n return error(e)\n }\n } catch (e: any) {\n return error(e)\n }\n }\n // endregion\n\n // region slash command handler\n private async command(i: CommandInteraction) {\n const error = (error: Error) => this.client.client.emit('applicationCommandError', error, i)\n try {\n const cmd = this.registry.applicationCommands.find((x) => x.command.type === 'CHAT_INPUT' && x.command.name === i.commandName)\n\n if (!cmd) return\n\n const module = this.registry.modules.find((x) => x.applicationCommands.includes(cmd))\n\n if (!module) return\n\n const argList: any[] = []\n\n i.data = {\n cts: this.client,\n command: cmd,\n }\n\n if (!(await this.client.options.slashCommands.check(i))) {\n return error(new SlashCommandGlobalCheckError(i))\n }\n for (const check of cmd.checks) {\n if (!(await check(i))) return error(new ApplicationCommandCheckFailed(i, cmd))\n }\n\n for (let j = 0; j < cmd.params.length; j++) {\n const argType = cmd.params[j]\n const converter = this.registry.applicationCommandArgumentConverters.find((x) => x.type === argType.type)\n\n if (argType.type === CommandInteraction) {\n argList.push(i)\n continue\n }\n\n if (argType.type === CommandInteractionOptionResolver) {\n argList.push(i.options)\n continue\n }\n\n if (argType.name) {\n switch (argType.type) {\n case String:\n argList.push(i.options.getString(argType.name, false) || undefined)\n break\n case Role:\n argList.push(i.options.getRole(argType.name, false) || undefined)\n break\n case User:\n argList.push(i.options.getUser(argType.name, false) || undefined)\n break\n case GuildMember:\n argList.push(i.options.getMember(argType.name, false) || undefined)\n break\n case Boolean:\n argList.push(i.options.getBoolean(argType.name, false) || undefined)\n break\n case Number:\n const opt = i.options.get(argType.name, false)\n if (!opt) {\n argList.push(undefined)\n break\n }\n if (opt.type == 'NUMBER') {\n argList.push(i.options.getNumber(argType.name, false) ?? undefined)\n break\n }\n if (opt.type == 'INTEGER') {\n argList.push(i.options.getInteger(argType.name, false) ?? undefined)\n break\n }\n }\n continue\n }\n\n if (!converter) return error(new ApplicationCommandArgumentConverterNotFound(argType, i))\n\n argList.push(await converter.execute(module, i))\n }\n\n await cmd.execute(module, argList)\n } catch (e: any) {\n return error(e)\n }\n }\n // endregion\n\n private async messageComponent(i: MessageComponentInteraction) {\n const error = (e: any) => this.client.client.emit('messageComponentError', e)\n\n try {\n const handlers: MessageComponentHandler[] = []\n\n for (const handler of this.registry.messageComponentHandlers) {\n if (handler.componentId === handler.componentId && handler.componentType === i.componentType) {\n handlers.push(handler)\n }\n }\n\n for (const handler of handlers) {\n const module = this.registry.modules.find((x) => x.messageComponentHandlers.includes(handler))\n if (!module) continue\n await handler.run(module, i)\n }\n } catch (e) {\n error(e)\n }\n }\n\n private async userContextMenu(i: UserContextMenuInteraction) {\n const error = (error: Error) => this.client.client.emit('applicationCommandError', error, i)\n try {\n const cmd = this.registry.applicationCommands.find((x) => x.command.type === 'USER' && x.command.name === i.commandName)\n\n if (!cmd) return\n\n const module = this.registry.modules.find((x) => x.applicationCommands.includes(cmd))\n\n if (!module) return\n\n i.data = {\n cts: this.client,\n command: cmd,\n }\n\n for (const check of cmd.checks) {\n if (!(await check(i))) return error(new ApplicationCommandCheckFailed(i, cmd))\n }\n\n let argList: any[] = []\n\n for (let j = 0; j < cmd.params.length; j++) {\n const argType = cmd.params[j]\n const converter = this.registry.applicationCommandArgumentConverters.find((x) => x.type === argType.type)\n\n if (argType.type === UserContextMenuInteraction) {\n argList.push(i)\n continue\n }\n\n if (!converter) return error(new ApplicationCommandArgumentConverterNotFound(argType, i))\n\n argList.push(await converter.execute(module, i))\n }\n\n await cmd.execute(module, argList)\n } catch (e: any) {\n return error(e)\n }\n }\n\n private async messageContextMenu(i: MessageContextMenuInteraction) {\n const error = (error: Error) => this.client.client.emit('applicationCommandError', error, i)\n try {\n const cmd = this.registry.applicationCommands.find((x) => x.command.type === 'MESSAGE' && x.command.name === i.commandName)\n\n if (!cmd) return\n\n const module = this.registry.modules.find((x) => x.applicationCommands.includes(cmd))\n\n if (!module) return\n\n i.data = {\n cts: this.client,\n command: cmd,\n }\n\n for (const check of cmd.checks) {\n if (!(await check(i))) return error(new ApplicationCommandCheckFailed(i, cmd))\n }\n\n let argList: any[] = []\n\n for (let j = 0; j < cmd.params.length; j++) {\n const argType = cmd.params[j]\n const converter = this.registry.applicationCommandArgumentConverters.find((x) => x.type === argType.type)\n\n if (argType.type === MessageContextMenuInteraction) {\n argList.push(i)\n continue\n }\n\n if (!converter) return error(new ApplicationCommandArgumentConverterNotFound(argType, i))\n\n argList.push(await converter.execute(module, i))\n }\n\n await cmd.execute(module, argList)\n } catch (e: any) {\n return error(e)\n }\n }\n\n @listener('interactionCreate')\n async interaction(i: Interaction) {\n const error = (e: any) => this.client.client.emit('interactionError', e, i)\n\n try {\n await this.client.options.applicationCommands.beforeRunCheck(i)\n if (i.isCommand()) {\n await this.command(i)\n return\n }\n if (i.isMessageComponent()) {\n await this.messageComponent(i)\n return\n }\n if (i.isMessageContextMenu()) {\n await this.messageContextMenu(i)\n return\n }\n if (i.isUserContextMenu()) {\n await this.userContextMenu(i)\n return\n }\n } catch (e) {\n return error(e)\n }\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from '../structures'\nimport { CommandInteraction, ContextMenuInteraction, Message, MessageComponentInteraction } from 'discord.js'\nimport { KCommandChecks } from '../constants'\n\nexport type Argument = {\n optional: boolean\n type: any\n rest: boolean\n}\n\nexport type CheckFunction = (msg: Message) => boolean | Promise<boolean>\nexport type ApplicationCommandCheckFunction = (i: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction) => boolean | Promise<boolean>\n\nexport class Command {\n execute(module: Module, args: any[]) {\n return this.run.apply(module, args)\n }\n\n get checks(): CheckFunction[] {\n return Reflect.getMetadata(KCommandChecks, this.module, this.key) || []\n }\n\n constructor(\n private run: Function,\n public argTypes: Argument[],\n public name: string,\n public aliases: string[] | ((msg: Message) => string[] | Promise<string[]>),\n public module: Module,\n public key: symbol | string,\n ) {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from '../structures'\nimport { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'\n\nexport class ArgumentConverter {\n execute(module: Module, msg: Message, arg?: string) {\n return this.run.apply(module, [msg, arg])\n }\n\n constructor(public type: object, private run: Function, public withoutParameter: boolean) {}\n}\n\nexport class ApplicationCommandArgumentConverter {\n execute(module: Module, interaction: CommandInteraction | ContextMenuInteraction) {\n return this.run.apply(module, [interaction])\n }\n\n constructor(public type: object, private run: Function) {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { CommandInteraction, ContextMenuInteraction, Message, MessageComponentInteraction } from 'discord.js'\nimport type { CheckFunction, ApplicationCommandCheckFunction } from './Command'\nimport { KCommandChecks, KApplicationCommandChecks } from '../constants'\n\nexport const createCheckDecorator = (\n execute: ((msg: Message) => boolean | Promise<boolean>) | null,\n executeApplicationCommand?: (i: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction) => boolean | Promise<boolean>,\n): MethodDecorator => {\n return (target, propertyKey) => {\n if (execute) {\n let properties: CheckFunction[] = Reflect.getMetadata(KCommandChecks, target, propertyKey)\n if (properties) {\n properties.push(execute)\n } else {\n properties = [execute]\n Reflect.defineMetadata(KCommandChecks, properties, target, propertyKey)\n }\n }\n if (executeApplicationCommand) {\n let properties: ApplicationCommandCheckFunction[] = Reflect.getMetadata(KApplicationCommandChecks, target, propertyKey)\n if (properties) {\n properties.push(executeApplicationCommand)\n } else {\n properties = [executeApplicationCommand]\n Reflect.defineMetadata(KApplicationCommandChecks, properties, target, propertyKey)\n }\n }\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { KArgumentConverters, KCommands, KOptionals, KRest, KSlashArgumentConverters } from '../constants'\nimport { Command } from './Command'\nimport { checkTarget } from '../utils'\nimport { ArgumentConverter, ApplicationCommandArgumentConverter } from './ArgumentConverter'\nimport { Module } from '../structures'\nimport { createCheckDecorator } from './utils'\nimport { GuildMember, Message, PermissionResolvable, Permissions, TextChannel } from 'discord.js'\nimport { ClientPermissionRequired, DMOnlyCommandError, GuildOnlyCommandError, OwnerOnlyCommandError, UserPermissionRequired } from '../error'\n\ntype CommandOptions = {\n name: string\n aliases: string[] | ((msg: Message) => string[])\n optionTypes?: any[]\n}\n\nexport const command = (options: Partial<CommandOptions> = {}) => {\n return (\n target: Object,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: Command[] = Reflect.getMetadata(KCommands, target)\n\n const params: any[] = options.optionTypes ?? Reflect.getMetadata('design:paramtypes', target, propertyKey)\n\n const optionals: number = Reflect.getMetadata(KOptionals, target, propertyKey) || -1\n\n const rest = Reflect.getMetadata(KRest, target, propertyKey) || -1\n\n const command = new Command(\n Reflect.get(target, propertyKey),\n params.map((x, i) => ({\n type: x,\n optional: optionals === -1 ? false : optionals <= i,\n rest: rest === -1 ? false : rest === i,\n })),\n options.name || propertyKey,\n options.aliases || [],\n target as Module,\n propertyKey,\n )\n\n if (properties) {\n properties.push(command)\n } else {\n properties = [command]\n Reflect.defineMetadata(KCommands, properties, target)\n }\n }\n}\n\nexport const argumentConverter = (type: object, requireParameter = true) => {\n return (\n target: Object,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: ArgumentConverter[] = Reflect.getMetadata(KArgumentConverters, target)\n\n const converter = new ArgumentConverter(type, Reflect.get(target, propertyKey), !requireParameter)\n\n if (properties) {\n properties.push(converter)\n } else {\n properties = [converter]\n Reflect.defineMetadata(KArgumentConverters, properties, target)\n }\n }\n}\n\nexport const applicationCommandArgumentConverter = (type: object) => {\n return (\n target: Object,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: ApplicationCommandArgumentConverter[] = Reflect.getMetadata(KSlashArgumentConverters, target)\n\n const converter = new ApplicationCommandArgumentConverter(type, Reflect.get(target, propertyKey))\n\n if (properties) {\n properties.push(converter)\n } else {\n properties = [converter]\n Reflect.defineMetadata(KSlashArgumentConverters, properties, target)\n }\n }\n}\n\nexport const optional: ParameterDecorator = (target, propertyKey, parameterIndex) => {\n checkTarget(target)\n\n Reflect.defineMetadata(KOptionals, parameterIndex, target, propertyKey)\n}\n\nexport const rest: ParameterDecorator = (target, propertyKey, parameterIndex) => {\n checkTarget(target)\n\n const params: any[] = Reflect.getMetadata('design:paramtypes', target, propertyKey)\n\n if (params.length - 1 !== parameterIndex) throw new Error('Rest decorator must be used at last argument.')\n\n if (params[parameterIndex] !== String) throw new Error('Rest argument type must be \"String\"')\n\n Reflect.defineMetadata(KRest, parameterIndex, target, propertyKey)\n}\n\nexport const ownerOnly = createCheckDecorator(\n (msg) => {\n if (msg.data.cts.owners.includes(msg.author.id)) return true\n throw new OwnerOnlyCommandError()\n },\n (i) => {\n if (i.data.cts.owners.includes(i.user.id)) return true\n throw new OwnerOnlyCommandError()\n },\n)\n\nexport const guildOnly = createCheckDecorator(\n (msg) => {\n if (!!msg.guild) return true\n throw new GuildOnlyCommandError()\n },\n (i) => {\n if (!!i.guildId) return true\n throw new GuildOnlyCommandError()\n },\n)\n\nexport const dmOnly = createCheckDecorator(\n (msg) => {\n if (!msg.guild) return true\n throw new DMOnlyCommandError()\n },\n (i) => {\n if (!i.guildId) return true\n throw new DMOnlyCommandError()\n },\n)\n\nexport const requireUserPermissions = (permission: PermissionResolvable) =>\n createCheckDecorator(\n (msg) => {\n if (!msg.guild || !msg.member) throw new Error('This command must be used in guild.')\n if (msg.member.permissionsIn(msg.channel as TextChannel).has(permission)) {\n return true\n }\n throw new UserPermissionRequired(msg.member, new Permissions(permission))\n },\n (i) => {\n if (!i.guild || !i.member) throw new Error('This command must be used in guild.')\n if (!(i.member instanceof GuildMember) || i.member.permissionsIn(i.channel as TextChannel).has(permission)) {\n return true\n }\n throw new UserPermissionRequired(i.member, new Permissions(permission))\n },\n )\n\nexport const requireClientPermissions = (permission: PermissionResolvable) =>\n createCheckDecorator(\n (msg) => {\n if (!msg.guild) throw new Error('This command must be used in guild.')\n if (msg.guild.me!.permissionsIn(msg.channel as TextChannel).has(permission)) {\n return true\n }\n throw new ClientPermissionRequired(new Permissions(permission))\n },\n (i) => {\n if (!i.guild) throw new Error('This command must be used in guild.')\n if (i.guild.me!.permissionsIn(i.channel as TextChannel).has(permission)) {\n return true\n }\n throw new ClientPermissionRequired(new Permissions(permission))\n },\n )\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport enum CoolDownType {\n USER,\n CHANNEL,\n GUILD,\n ROLE,\n CATEGORY,\n MEMBER,\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { createCheckDecorator } from '../utils'\nimport { CoolDownType } from './type'\nimport { DMChannel, GuildMember, TextChannel } from 'discord.js'\nimport { CoolDownError } from './error'\n\nexport const coolDown = (type: CoolDownType, seconds: number) =>\n createCheckDecorator(\n async (msg) => {\n const a = msg.data.cts.coolDownAdapter\n const getKey = (): string => {\n switch (type) {\n case CoolDownType.USER:\n return msg.author.id\n case CoolDownType.GUILD:\n return (msg.guild || msg.author).id\n case CoolDownType.CHANNEL:\n return msg.channel.id\n case CoolDownType.MEMBER:\n return `${msg.guild?.id}.${msg.author.id}`\n case CoolDownType.ROLE:\n return (msg.channel instanceof DMChannel ? msg.channel : msg.member!.roles.highest).id\n case CoolDownType.CATEGORY:\n return ((msg.channel as TextChannel).parent || msg.channel).id\n }\n }\n const key = getKey() + '-command-' + msg.data.command?.name\n const data = await a.get(key)\n const now = Date.now()\n if (!data || !(now - data < seconds * 1000)) {\n await a.set(key, now)\n return true\n }\n throw new CoolDownError(new Date(data + seconds * 1000))\n },\n async (i) => {\n if (i.isMessageComponent()) return true\n const a = i.data.cts.coolDownAdapter\n const getKey = (): string => {\n switch (type) {\n case CoolDownType.USER:\n return i.user.id + '.user'\n case CoolDownType.GUILD:\n return (i.guild || i.user).id + '.guild'\n case CoolDownType.CHANNEL:\n return i.channel!.id + '.channel'\n case CoolDownType.MEMBER:\n return `${i.guild?.id}.${i.user.id}`\n case CoolDownType.ROLE:\n return (i.channel instanceof DMChannel ? i.channel : (i.member as GuildMember)!.roles.highest).id + '.role'\n case CoolDownType.CATEGORY:\n return ((i.channel as TextChannel).parent || i.channel!).id + '.category'\n }\n }\n const key = getKey() + '-appCommand-' + i.commandName\n const data = await a.get(key)\n const now = Date.now()\n if (!data || !(now - data < seconds * 1000)) {\n await a.set(key, now)\n return true\n }\n throw new CoolDownError(new Date(data + seconds * 1000))\n },\n )\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nexport class CoolDownError extends Error {\n constructor(public endsAt: Date) {\n super()\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Collection } from 'discord.js'\n\nexport interface CoolDownAdapter {\n get(id: string): Promise<number | undefined>\n set(id: string, value: number): Promise<void>\n}\n\nexport class DefaultCoolDownAdapter implements CoolDownAdapter {\n map = new Collection<string, number>()\n async get(id: string): Promise<number | undefined> {\n return this.map.get(id)\n }\n\n async set(id: string, value: number) {\n this.map.set(id, value)\n return\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { BuiltInModule } from './BuiltInModule'\nimport { argumentConverter } from '../command'\nimport { Client, GuildMember, Message, User, Role } from 'discord.js'\nimport { CommandClient } from '../structures'\n\nexport class BuiltinCommandConverters extends BuiltInModule {\n client: Client\n\n constructor(private cts: CommandClient) {\n super()\n this.client = cts.client\n }\n\n @argumentConverter(Message, false)\n message(msg: Message) {\n return msg\n }\n\n @argumentConverter(String)\n string(msg: Message, arg: string) {\n return arg\n }\n\n getUserIDByMention(mention: string): `${bigint}` | undefined {\n if (!mention) return\n if (mention.startsWith('<@') && mention.endsWith('>')) {\n mention = mention.slice(2, -1)\n if (mention.startsWith('!')) {\n mention = mention.slice(1)\n }\n return mention as `${bigint}`\n }\n }\n\n @argumentConverter(User)\n user(msg: Message, value: string): User | null {\n let user = this.client.users.cache.get(value)\n if (user) return user\n user = this.client.users.cache.find((x) => x.tag === value || x.username === value)\n if (user) return user\n const id = this.getUserIDByMention(value)\n if (!id) return null\n user = this.client.users.cache.get(id)\n return user || null\n }\n\n @argumentConverter(GuildMember)\n member(msg: Message, value: string): GuildMember | undefined {\n let user = msg.guild?.members.cache.get(value)\n if (!user) return user\n user = msg.guild?.members.cache.find((x) => x.user.tag === value)\n if (user) return user\n const id = this.getUserIDByMention(value)\n if (!id) return\n user = msg.guild?.members.cache.get(id)\n return user || undefined\n }\n\n @argumentConverter(Number)\n number(msg: Message, value: string) {\n const n = Number(value)\n return isNaN(n) ? undefined : n\n }\n\n getRoleIDByMention(mention: string): `${bigint}` | undefined {\n if (!mention) return\n if (mention.startsWith('<@') && mention.endsWith('>')) {\n mention = mention.slice(2, -1)\n if (mention.startsWith('&')) {\n mention = mention.slice(1)\n }\n return mention as `${bigint}`\n }\n }\n\n @argumentConverter(Role)\n role(msg: Message, value: string): Role | undefined {\n const id = this.getRoleIDByMention(value)\n if (!id) return\n const role = msg.guild?.roles.cache.get(id)\n return role || undefined\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { BuiltInModule } from './BuiltInModule'\nimport { Client } from 'discord.js'\nimport { CommandClient } from '../structures'\n\nexport class BuiltinApplicationCommandConverters extends BuiltInModule {\n client: Client\n\n constructor(private cts: CommandClient) {\n super()\n this.client = cts.client\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { ApplicationCommandDataResolvable, Collection, Snowflake } from 'discord.js'\nimport { checkTarget } from '../utils'\nimport { KSlashCommandOptions, KApplicationCommands } from '../constants'\nimport { Module } from '../structures'\nimport { AppCommand } from './AppCommand'\n\ntype ApplicationCommandOptions = {\n guild: Snowflake | Snowflake[]\n optionTypes?: any[]\n}\n\nexport const applicationCommand = (opt: Partial<ApplicationCommandOptions> & { command: ApplicationCommandDataResolvable }) => {\n return (\n target: Object,\n propertyKey: string,\n // descriptor: TypedPropertyDescriptor<any>,\n ) => {\n checkTarget(target)\n\n let properties: AppCommand[] = Reflect.getMetadata(KApplicationCommands, target)\n\n const params: any[] = opt.optionTypes ?? Reflect.getMetadata('design:paramtypes', target, propertyKey)\n\n const options: Collection<number, string> = Reflect.getMetadata(KSlashCommandOptions, target, propertyKey) || new Collection<number, string>()\n\n const command = new AppCommand(\n opt.command,\n Reflect.get(target, propertyKey),\n target as Module,\n params.map((x, i) => ({\n type: x,\n name: options.get(i),\n })),\n opt.guild,\n propertyKey,\n )\n\n if (properties) {\n properties.push(command)\n } else {\n properties = [command]\n Reflect.defineMetadata(KApplicationCommands, properties, target)\n }\n }\n}\n\nexport const option = (key: string): ParameterDecorator => (target, propertyKey, parameterIndex) => {\n checkTarget(target)\n\n let properties: Collection<number, string> = Reflect.getMetadata(KSlashCommandOptions, target, propertyKey)\n\n if (!properties) {\n properties = new Collection<number, string>()\n Reflect.defineMetadata(KSlashCommandOptions, properties, target, propertyKey)\n }\n\n properties.set(parameterIndex, key)\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { Module } from '../structures'\nimport { ApplicationCommandDataResolvable, Snowflake } from 'discord.js'\nimport { KApplicationCommandChecks } from '../constants'\nimport { ApplicationCommandCheckFunction } from '../command'\n\nexport type AppCommandArgument = {\n type: any\n name?: string\n}\n\nexport class AppCommand {\n get checks(): ApplicationCommandCheckFunction[] {\n return Reflect.getMetadata(KApplicationCommandChecks, this.module, this.key) || []\n }\n\n execute(module: Module, args: any[]) {\n return this.run.apply(module, args)\n }\n\n constructor(\n public command: ApplicationCommandDataResolvable,\n private run: Function,\n public module: Module,\n public params: AppCommandArgument[],\n public guild: Snowflake | Snowflake[] | undefined,\n private key: string | symbol,\n ) {}\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { MessageComponentInteraction, MessageComponentType } from 'discord.js'\nimport { Module } from '../structures'\n\nexport type MessageComponentExecutor = (i: MessageComponentInteraction) => void | Promise<void>\n\nexport class MessageComponentHandler {\n constructor(public componentId: string, public componentType: Exclude<MessageComponentType, 'ACTION_ROW'>, public execute: MessageComponentExecutor) {}\n\n run(module: Module, i: MessageComponentInteraction) {\n return this.execute.apply(module, [i])\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { MessageComponentExecutor, MessageComponentHandler } from './base'\nimport { checkTarget } from '../utils'\nimport { KMessageComponentHandlers } from '../constants'\n\nexport class ButtonInteractionHandler extends MessageComponentHandler {\n constructor(id: string, execute: MessageComponentExecutor) {\n super(id, 'BUTTON', execute)\n }\n}\n\nexport const messageButton = (id: string): MethodDecorator => {\n return (target, propertyKey) => {\n checkTarget(target)\n\n const handler = new ButtonInteractionHandler(id, Reflect.get(target, propertyKey))\n\n let properties: MessageComponentHandler[] = Reflect.getMetadata(KMessageComponentHandlers, target)\n\n if (properties) {\n properties.push(handler)\n } else {\n properties = [handler]\n Reflect.defineMetadata(KMessageComponentHandlers, properties, target)\n }\n }\n}\n","/*\n * Copyright (c) 2022 pikokr. Licensed under the MIT license\n */\n\nimport { MessageComponentExecutor, MessageComponentHandler } from './base'\nimport { checkTarget } from '../utils'\nimport { KMessageComponentHandlers } from '../constants'\n\nexport class SelectMenuInteractionHandler extends MessageComponentHandler {\n constructor(id: string, execute: MessageComponentExecutor) {\n super(id, 'SELECT_MENU', execute)\n }\n}\n\nexport const messageSelectMenu = (id: string): MethodDecorator => {\n return (target, propertyKey) => {\n checkTarget(target)\n\n const handler = new SelectMenuInteractionHandler(id, Reflect.get(target, propertyKey))\n\n let properties: MessageComponentHandler[] = Reflect.getMetadata(KMessageComponentHandlers, target)\n\n if (properties) {\n properties.push(handler)\n } else {\n properties = [handler]\n Reflect.defineMetadata(KMessageComponentHandlers, properties, target)\n }\n }\n}\n"],"mappings":"m+BAAA,6nCAIA,OAAO,4BCAA,GAAM,GAAY,OAAO,uBAEnB,EAAuB,OAAO,6BAE9B,GAAuB,O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iBCNpB,oBAA4C,EAAuB,aAC3D,EAAY,EAAmC,CACzD,MAAM,EAAI,cAAe,KAFvB,qCAMC,GAAM,IAAiB,EAAI,GAC1B,CAAE,EAAQ,IAAgB,CAC9B,EAAY,GAEZ,GAAM,GAAU,GAAI,IAA6B,EAAI,QAAQ,IAAI,EAAQ,IAErE,EAAwC,QAAQ,YAAY,EAA2B,GAE3F,AAAI,EACF,EAAW,KAAK,GAEhB,GAAa,CAAC,GACd,QAAQ,eAAe,EAA2B,EAAY,KAZtC","names":[]}
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": "4.0.6",
4
+ "version": "4.0.7",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "@swc/core": "^1.2.135",
11
11
  "@types/lodash": "^4.14.172",
12
12
  "all-contributors-cli": "^6.20.0",
13
- "discord.js": "^13.6.0",
13
+ "discord.js": "^13.7.0",
14
14
  "prettier": "^2.2.1",
15
15
  "ts-node": "^10.1.0",
16
16
  "tsup": "^5.11.12",
@@ -135,7 +135,7 @@ export class CommandHandler extends BuiltInModule {
135
135
  } catch (e: any) {
136
136
  return error(e)
137
137
  }
138
- } catch (e) {
138
+ } catch (e: any) {
139
139
  return error(e)
140
140
  }
141
141
  }
@@ -222,7 +222,7 @@ export class CommandHandler extends BuiltInModule {
222
222
  }
223
223
 
224
224
  await cmd.execute(module, argList)
225
- } catch (e) {
225
+ } catch (e: any) {
226
226
  return error(e)
227
227
  }
228
228
  }
@@ -287,7 +287,7 @@ export class CommandHandler extends BuiltInModule {
287
287
  }
288
288
 
289
289
  await cmd.execute(module, argList)
290
- } catch (e) {
290
+ } catch (e: any) {
291
291
  return error(e)
292
292
  }
293
293
  }
@@ -329,7 +329,7 @@ export class CommandHandler extends BuiltInModule {
329
329
  }
330
330
 
331
331
  await cmd.execute(module, argList)
332
- } catch (e) {
332
+ } catch (e: any) {
333
333
  return error(e)
334
334
  }
335
335
  }
package/test/index.ts CHANGED
@@ -3,12 +3,12 @@
3
3
  */
4
4
 
5
5
  import { Client, Intents, IntentsString } from 'discord.js'
6
- import { CommandClient } from '../src'
6
+ import { CommandClient } from '../dist'
7
7
 
8
8
  const config = require('./config.json')
9
9
 
10
10
  const client = new Client({
11
- intents: Object.keys(Intents.FLAGS) as IntentsString[],
11
+ intents: ['GUILD_MESSAGES','GUILDS','DIRECT_MESSAGES'],
12
12
  })
13
13
 
14
14
  const cts = new CommandClient({
@@ -19,12 +19,10 @@ const cts = new CommandClient({
19
19
  },
20
20
  applicationCommands: {
21
21
  autoSync: true,
22
- guild: '832938554438844438',
22
+ guild: '969907569592250449',
23
23
  },
24
24
  })
25
25
 
26
- require('./modules/test')
27
-
28
26
  cts.registry.loadModulesIn('modules')
29
27
 
30
28
  client.login(config.token)
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2022 pikokr. Licensed under the MIT license
3
3
  */
4
4
 
5
- import { BuiltInModule, CommandClient, ownerOnly, applicationCommand, listener, ApplicationCommandCheckFailed } from '../../src'
5
+ import { BuiltInModule, CommandClient, ownerOnly, applicationCommand, listener, ApplicationCommandCheckFailed } from '../../dist'
6
6
  import { CommandInteraction } from 'discord.js'
7
7
 
8
8
  export class Dev extends BuiltInModule {
@@ -28,7 +28,6 @@ export class Dev extends BuiltInModule {
28
28
  type: 'CHAT_INPUT',
29
29
  description: '리로드 커맨드',
30
30
  },
31
- guild: ['457841749197586438'],
32
31
  })
33
32
  @ownerOnly
34
33
  async reload(i: CommandInteraction) {
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2022 pikokr. Licensed under the MIT license
3
3
  */
4
4
 
5
- import { CommandClient, coolDown, CoolDownError, CoolDownType, listener, messageButton, messageSelectMenu, Module, option, applicationCommand } from '../../src'
5
+ import { CommandClient, coolDown, CoolDownError, CoolDownType, listener, messageButton, messageSelectMenu, Module, option, applicationCommand } from '../../dist'
6
6
  import {
7
7
  ButtonInteraction,
8
8
  CommandInteraction,