UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 27.7 kB
{"version":3,"sources":["../../../../src/lib/structures/Command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAgCA,IAAM,YAAA,GAAe,MAAO,CAAA,MAAA,CAAO,WAAW,CAAA,CAAE,OAAO,CAAC,IAAA,KAAS,OAAO,IAAA,KAAS,QAAQ,CAAA;AACzF,IAAM,iBAAA,GAAoB,YAAa,CAAA,MAAA,CAAO,CAAC,IAAA,KAAS,SAAS,WAAY,CAAA,EAAA,IAAM,IAAS,KAAA,WAAA,CAAY,OAAO,CAAA;AAExG,IAAM,QAAA,GAAN,MAAM,QAAA,SAA0F,UAAgC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuE/H,WAAY,CAAA,OAAA,EAAgC,OAAmB,GAAA,EAAe,EAAA;AACpF,IAAM,MAAA,IAAA,GAAO,OAAQ,CAAA,IAAA,IAAQ,OAAQ,CAAA,IAAA;AACrC,IAAM,KAAA,CAAA,OAAA,EAAS,EAAE,GAAG,OAAA,EAAS,MAAM,IAAK,CAAA,WAAA,IAAe,CAAA;AAhBxD;AAAA;AAAA;AAAA;AAAA,IAAgB,IAAA,CAAA,0BAAA,GAA6B,OAAQ,CAAA,IAAA,CAAK,IAAI,CAAA;AAkB7D,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA;AACf,IAAK,IAAA,CAAA,WAAA,GAAc,QAAQ,WAAe,IAAA,EAAA;AAC1C,IAAK,IAAA,CAAA,mBAAA,GAAsB,QAAQ,mBAAuB,IAAA,EAAA;AAC1D,IAAK,IAAA,CAAA,QAAA,GAAW,IAAI,qBAAA,CAAsB,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,YAAe,GAAA,OAAA,CAAQ,YAAgB,IAAA,IAAA,CAAK,QAAS,CAAA,WAAA;AAC1D,IAAK,IAAA,CAAA,MAAA,GAAS,QAAQ,MAAU,IAAA,IAAA;AAEhC,IAAK,IAAA,CAAA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EAAA;AACtC,IAAA,KAAA,MAAW,kBAAkB,KAAO,EAAA;AACnC,MAAW,KAAA,MAAA,IAAA,IAAQ,KAAK,sCAAuC,CAAA,cAAc,KAAK,EAAC,EAAY,QAAA,CAAA,GAAA,CAAI,IAAI,CAAA;AAAA;AAIxG,IAAA,IAAI,QAAS,CAAA,IAAA,KAAS,YAAa,CAAA,MAAA,EAAe,OAAA,IAAA;AAGlD,IAAO,OAAA,CAAC,GAAG,QAAQ,CAAA,CAAE,KAAK,CAAC,CAAA,EAAG,CAAM,KAAA,CAAA,GAAI,CAAC,CAAA;AAAA;AAC1C,EAEA,OAAc,2BAA2B,KAAgE,EAAA;AACxG,IAAI,IAAA,CAAC,QAAS,CAAA,KAAK,CAAG,EAAA;AACrB,MAAO,OAAA,KAAA;AAAA;AAGR,IAAA,MAAM,aAAgB,GAAA,KAAA;AACtB,IAAA,OAAO,QAAQ,aAAc,CAAA,YAAA,IAAgB,aAAc,CAAA,UAAA,IAAc,cAAc,cAAc,CAAA;AAAA;AAEvG,CAAA;AA3buI,MAAA,CAAA,QAAA,EAAA,SAAA,CAAA;AAAhI,IAAM,OAAN,GAAA","file":"Command.mjs","sourcesContent":["import { ArgumentStream, Lexer, Parser, type IUnorderedStrategy } from '@sapphire/lexure';\nimport { AliasPiece } from '@sapphire/pieces';\nimport { isFunction, isNullish, isObject, type Awaitable } from '@sapphire/utilities';\nimport { ChannelType, ChatInputCommandInteraction, ContextMenuCommandInteraction, type AutocompleteInteraction, type Message } from 'discord.js';\nimport { Args } from '../parsers/Args';\nimport {\n\tparseConstructorPreConditionsCooldown,\n\tparseConstructorPreConditionsNsfw,\n\tparseConstructorPreConditionsRequiredClientPermissions,\n\tparseConstructorPreConditionsRequiredUserPermissions,\n\tparseConstructorPreConditionsRunIn\n} from '../precondition-resolvers/index';\nimport type {\n\tAutocompleteCommand,\n\tChatInputCommand,\n\tCommandJSON,\n\tCommandOptions,\n\tCommandOptionsRunType,\n\tCommandRunInUnion,\n\tCommandSpecificRunIn,\n\tContextMenuCommand,\n\tDetailedDescriptionCommand,\n\tMessageCommand\n} from '../types/CommandTypes';\nimport { RegisterBehavior } from '../types/Enums';\nimport { acquire, getDefaultBehaviorWhenNotIdentical, handleBulkOverwrite } from '../utils/application-commands/ApplicationCommandRegistries';\nimport type { ApplicationCommandRegistry } from '../utils/application-commands/ApplicationCommandRegistry';\nimport { getNeededRegistryParameters } from '../utils/application-commands/getNeededParameters';\nimport { emitPerRegistryError } from '../utils/application-commands/registriesErrors';\nimport { PreconditionContainerArray } from '../utils/preconditions/PreconditionContainerArray';\nimport { FlagUnorderedStrategy } from '../utils/strategies/FlagUnorderedStrategy';\n\nconst ChannelTypes = Object.values(ChannelType).filter((type) => typeof type === 'number') as readonly ChannelType[];\nconst GuildChannelTypes = ChannelTypes.filter((type) => type !== ChannelType.DM && type !== ChannelType.GroupDM) as readonly ChannelType[];\n\nexport class Command<PreParseReturn = Args, Options extends Command.Options = Command.Options> extends AliasPiece<Options, 'commands'> {\n\t/**\n\t * The raw name of the command as provided through file name or constructor options.\n\t *\n\t * This is exactly what is set by the developer, completely unmodified internally by the framework.\n\t * Unlike the `name` which gets lowercased for storing it uniquely in the {@link CommandStore}.\n\t */\n\tpublic rawName: string;\n\n\t/**\n\t * A basic summary about the command\n\t * @since 1.0.0\n\t */\n\tpublic description: string;\n\n\t/**\n\t * The preconditions to be run.\n\t * @since 1.0.0\n\t */\n\tpublic preconditions: PreconditionContainerArray;\n\n\t/**\n\t * Longer version of command's summary and how to use it\n\t * @since 1.0.0\n\t */\n\tpublic detailedDescription: DetailedDescriptionCommand;\n\n\t/**\n\t * The full category for the command, can be overridden by setting the {@link Command.Options.fullCategory} option.\n\t *\n\t * If {@link Command.Options.fullCategory} is not set, then:\n\t * - If the command is loaded from the file system, then this is the command's location in file system relative to\n\t * the commands folder. For example, if you have a command located at `commands/General/Information/info.ts` then\n\t * this property will be `['General', 'Info']`.\n\t * - If the command is virtual, then this will be `[]`.\n\t *\n\t * @since 2.0.0\n\t */\n\tpublic readonly fullCategory: readonly string[];\n\n\t/**\n\t * The strategy to use for the lexer.\n\t * @since 1.0.0\n\t */\n\tpublic strategy: IUnorderedStrategy;\n\n\t/**\n\t * If {@link SapphireClient.typing} is true, it can be overridden for a specific command using this property, set via its options.\n\t * Otherwise, this property will be ignored.\n\t * @default true\n\t */\n\tpublic typing: boolean;\n\n\t/**\n\t * The application command registry associated with this command.\n\t * @since 3.0.0\n\t */\n\tpublic readonly applicationCommandRegistry = acquire(this.name);\n\n\t/**\n\t * The lexer to be used for command parsing\n\t * @since 1.0.0\n\t * @private\n\t */\n\tprotected lexer: Lexer;\n\n\t/**\n\t * @since 1.0.0\n\t * @param context The context.\n\t * @param options Optional Command settings.\n\t */\n\tpublic constructor(context: Command.LoaderContext, options: Options = {} as Options) {\n\t\tconst name = options.name ?? context.name;\n\t\tsuper(context, { ...options, name: name.toLowerCase() });\n\n\t\tthis.rawName = name;\n\t\tthis.description = options.description ?? '';\n\t\tthis.detailedDescription = options.detailedDescription ?? '';\n\t\tthis.strategy = new FlagUnorderedStrategy(options);\n\t\tthis.fullCategory = options.fullCategory ?? this.location.directories;\n\t\tthis.typing = options.typing ?? true;\n\n\t\tthis.lexer = new Lexer({\n\t\t\tquotes: options.quotes ?? [\n\t\t\t\t['\"', '\"'], // Double quotes\n\t\t\t\t['“', '”'], // Fancy quotes (on iOS)\n\t\t\t\t['「', '」'], // Corner brackets (CJK)\n\t\t\t\t['«', '»'] // French quotes (guillemets)\n\t\t\t]\n\t\t});\n\n\t\tif (options.generateDashLessAliases) {\n\t\t\tconst dashLessAliases: string[] = [];\n\t\t\tif (this.name.includes('-')) dashLessAliases.push(this.name.replace(/-/g, ''));\n\t\t\tfor (const alias of this.aliases) if (alias.includes('-')) dashLessAliases.push(alias.replace(/-/g, ''));\n\n\t\t\tthis.aliases = [...this.aliases, ...dashLessAliases];\n\t\t}\n\n\t\tif (options.generateUnderscoreLessAliases) {\n\t\t\tconst underscoreLessAliases: string[] = [];\n\t\t\tif (this.name.includes('_')) underscoreLessAliases.push(this.name.replace(/_/g, ''));\n\t\t\tfor (const alias of this.aliases) if (alias.includes('_')) underscoreLessAliases.push(alias.replace(/_/g, ''));\n\n\t\t\tthis.aliases = [...this.aliases, ...underscoreLessAliases];\n\t\t}\n\n\t\tthis.preconditions = new PreconditionContainerArray(options.preconditions);\n\t\tthis.parseConstructorPreConditions(options);\n\t}\n\n\t/**\n\t * The message pre-parse method. This method can be overridden by plugins to define their own argument parser.\n\t * @param message The message that triggered the command.\n\t * @param parameters The raw parameters as a single string.\n\t * @param context The command-context used in this execution.\n\t */\n\tpublic messagePreParse(message: Message, parameters: string, context: MessageCommand.RunContext): Awaitable<PreParseReturn> {\n\t\tconst parser = new Parser(this.strategy);\n\t\tconst args = new ArgumentStream(parser.run(this.lexer.run(parameters)));\n\t\treturn new Args(message, this as MessageCommand, args, context) as PreParseReturn;\n\t}\n\n\t/**\n\t * The main category for the command, if any.\n\t *\n\t * This getter retrieves the first value of {@link Command.fullCategory}, if it has at least one item, otherwise it\n\t * returns `null`.\n\t *\n\t * @note You can set {@link Command.Options.fullCategory} to override the built-in category resolution.\n\t */\n\tpublic get category(): string | null {\n\t\treturn this.fullCategory.at(0) ?? null;\n\t}\n\n\t/**\n\t * The sub-category for the command, if any.\n\t *\n\t * This getter retrieves the second value of {@link Command.fullCategory}, if it has at least two items, otherwise\n\t * it returns `null`.\n\t *\n\t * @note You can set {@link Command.Options.fullCategory} to override the built-in category resolution.\n\t */\n\tpublic get subCategory(): string | null {\n\t\treturn this.fullCategory.at(1) ?? null;\n\t}\n\n\t/**\n\t * The parent category for the command.\n\t *\n\t * This getter retrieves the last value of {@link Command.fullCategory}, if it has at least one item, otherwise it\n\t * returns `null`.\n\t *\n\t * @note You can set {@link Command.Options.fullCategory} to override the built-in category resolution.\n\t */\n\tpublic get parentCategory(): string | null {\n\t\treturn this.fullCategory.at(-1) ?? null;\n\t}\n\n\t/**\n\t * Executes the message command's logic.\n\t * @param message The message that triggered the command.\n\t * @param args The value returned by {@link Command.messagePreParse}, by default an instance of {@link Args}.\n\t * @param context The context in which the command was executed.\n\t */\n\tpublic messageRun?(message: Message, args: PreParseReturn, context: MessageCommand.RunContext): Awaitable<unknown>;\n\n\t/**\n\t * Executes the application command's logic.\n\t * @param interaction The interaction that triggered the command.\n\t * @param context The chat input command run context.\n\t */\n\tpublic chatInputRun?(interaction: ChatInputCommandInteraction, context: ChatInputCommand.RunContext): Awaitable<unknown>;\n\n\t/**\n\t * Executes the context menu's logic.\n\t * @param interaction The interaction that triggered the command.\n\t * @param context The context menu command run context.\n\t */\n\tpublic contextMenuRun?(interaction: ContextMenuCommandInteraction, context: ContextMenuCommand.RunContext): Awaitable<unknown>;\n\n\t/**\n\t * Executes the autocomplete logic.\n\t *\n\t * :::tip\n\t *\n\t * You may use this, or alternatively create an {@link InteractionHandler interaction handler} to handle autocomplete interactions.\n\t * Keep in mind that commands take precedence over interaction handlers.\n\t *\n\t * :::\n\t *\n\t * @param interaction The interaction that triggered the autocomplete.\n\t */\n\tpublic autocompleteRun?(interaction: AutocompleteInteraction): Awaitable<unknown>;\n\n\t/**\n\t * Defines the JSON.stringify behavior of the command.\n\t */\n\tpublic override toJSON(): CommandJSON {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\tdescription: this.description,\n\t\t\tdetailedDescription: this.detailedDescription,\n\t\t\tcategory: this.category\n\t\t};\n\t}\n\n\t/**\n\t * Registers the application commands that should be handled by this command.\n\t * @param registry This command's registry\n\t */\n\tpublic registerApplicationCommands?(registry: ApplicationCommandRegistry): Awaitable<void>;\n\n\t/**\n\t * Type-guard that ensures the command supports message commands by checking if the handler for it is present\n\t */\n\tpublic supportsMessageCommands(): this is MessageCommand {\n\t\treturn isFunction(Reflect.get(this, 'messageRun'));\n\t}\n\n\t/**\n\t * Type-guard that ensures the command supports chat input commands by checking if the handler for it is present\n\t */\n\tpublic supportsChatInputCommands(): this is ChatInputCommand {\n\t\treturn isFunction(Reflect.get(this, 'chatInputRun'));\n\t}\n\n\t/**\n\t * Type-guard that ensures the command supports context menu commands by checking if the handler for it is present\n\t */\n\tpublic supportsContextMenuCommands(): this is ContextMenuCommand {\n\t\treturn isFunction(Reflect.get(this, 'contextMenuRun'));\n\t}\n\n\t/**\n\t * Type-guard that ensures the command supports handling autocomplete interactions by checking if the handler for it is present\n\t */\n\tpublic supportsAutocompleteInteractions(): this is AutocompleteCommand {\n\t\treturn isFunction(Reflect.get(this, 'autocompleteRun'));\n\t}\n\n\tpublic override async reload() {\n\t\t// Remove the aliases from the command store\n\t\tconst { store } = this;\n\t\tconst registry = this.applicationCommandRegistry;\n\n\t\tfor (const nameOrId of registry.chatInputCommands) {\n\t\t\tconst aliasedPiece = store.aliases.get(nameOrId);\n\t\t\tif (aliasedPiece === this) {\n\t\t\t\tstore.aliases.delete(nameOrId);\n\t\t\t}\n\t\t}\n\n\t\tfor (const nameOrId of registry.contextMenuCommands) {\n\t\t\tconst aliasedPiece = store.aliases.get(nameOrId);\n\t\t\tif (aliasedPiece === this) {\n\t\t\t\tstore.aliases.delete(nameOrId);\n\t\t\t}\n\t\t}\n\n\t\t// Reset the registry's contents\n\t\tregistry.chatInputCommands.clear();\n\t\tregistry.contextMenuCommands.clear();\n\t\tregistry.guildIdsToFetch.clear();\n\t\tregistry['apiCalls'].length = 0;\n\n\t\t// Reload the command\n\t\tawait super.reload();\n\n\t\t// Get the command from the store to get any changes from the reload\n\t\tconst updatedPiece = store.get(this.name);\n\n\t\t// This likely shouldn't happen but not worth continuing if the piece is somehow no longer available\n\t\tif (!updatedPiece) return;\n\n\t\tconst updatedRegistry = updatedPiece.applicationCommandRegistry;\n\n\t\tif (updatedPiece.registerApplicationCommands) {\n\t\t\t// Rerun the registry\n\t\t\ttry {\n\t\t\t\tawait updatedPiece.registerApplicationCommands(updatedRegistry);\n\t\t\t} catch (err) {\n\t\t\t\temitPerRegistryError(err, updatedPiece);\n\t\t\t\t// No point on continuing\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// If there are no API calls to execute then exit out early\n\t\tif (!updatedRegistry['apiCalls'].length) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the default behavior is set to bulk overwrite, handle it as such and return.\n\t\tif (getDefaultBehaviorWhenNotIdentical() === RegisterBehavior.BulkOverwrite) {\n\t\t\tawait handleBulkOverwrite(store, this.container.client.application!.commands);\n\t\t\treturn;\n\t\t}\n\n\t\t// Re-initialize the store and the API data (insert in the store handles the register method)\n\t\tconst { applicationCommands, globalCommands, guildCommands } = await getNeededRegistryParameters(updatedRegistry.guildIdsToFetch);\n\n\t\t// Handle the API calls\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\tawait updatedRegistry['runAPICalls'](applicationCommands, globalCommands, guildCommands);\n\n\t\t// Re-set the aliases\n\t\tfor (const nameOrId of updatedRegistry.chatInputCommands) {\n\t\t\tstore.aliases.set(nameOrId, updatedPiece);\n\t\t}\n\n\t\tfor (const nameOrId of updatedRegistry.contextMenuCommands) {\n\t\t\tstore.aliases.set(nameOrId, updatedPiece);\n\t\t}\n\t}\n\n\t/**\n\t * Parses the command's options and processes them, calling {@link Command#parseConstructorPreConditionsRunIn},\n\t * {@link Command#parseConstructorPreConditionsNsfw},\n\t * {@link Command#parseConstructorPreConditionsRequiredClientPermissions}, and\n\t * {@link Command#parseConstructorPreConditionsCooldown}.\n\t * @since 2.0.0\n\t * @param options The command options given from the constructor.\n\t */\n\tprotected parseConstructorPreConditions(options: Command.Options): void {\n\t\tthis.parseConstructorPreConditionsRunIn(options);\n\t\tthis.parseConstructorPreConditionsNsfw(options);\n\t\tthis.parseConstructorPreConditionsRequiredClientPermissions(options);\n\t\tthis.parseConstructorPreConditionsRequiredUserPermissions(options);\n\t\tthis.parseConstructorPreConditionsCooldown(options);\n\t}\n\n\t/**\n\t * Appends the `NSFW` precondition if {@link Command.Options.nsfw} is set to true.\n\t * @param options The command options given from the constructor.\n\t */\n\tprotected parseConstructorPreConditionsNsfw(options: Command.Options) {\n\t\tparseConstructorPreConditionsNsfw(options.nsfw, this.preconditions);\n\t}\n\n\t/**\n\t * Appends the `RunIn` precondition based on the values passed, defaulting to `null`, which doesn't add a\n\t * precondition.\n\t * @param options The command options given from the constructor.\n\t */\n\tprotected parseConstructorPreConditionsRunIn(options: Command.Options) {\n\t\tparseConstructorPreConditionsRunIn(options.runIn, this.resolveConstructorPreConditionsRunType.bind(this), this.preconditions);\n\t}\n\n\t/**\n\t * Appends the `ClientPermissions` precondition when {@link Command.Options.requiredClientPermissions} resolves to a\n\t * non-zero bitfield.\n\t * @param options The command options given from the constructor.\n\t */\n\tprotected parseConstructorPreConditionsRequiredClientPermissions(options: Command.Options) {\n\t\tparseConstructorPreConditionsRequiredClientPermissions(options.requiredClientPermissions, this.preconditions);\n\t}\n\n\t/**\n\t * Appends the `UserPermissions` precondition when {@link Command.Options.requiredUserPermissions} resolves to a\n\t * non-zero bitfield.\n\t * @param options The command options given from the constructor.\n\t */\n\tprotected parseConstructorPreConditionsRequiredUserPermissions(options: Command.Options) {\n\t\tparseConstructorPreConditionsRequiredUserPermissions(options.requiredUserPermissions, this.preconditions);\n\t}\n\n\t/**\n\t * Appends the `Cooldown` precondition when {@link Command.Options.cooldownLimit} and\n\t * {@link Command.Options.cooldownDelay} are both non-zero.\n\t * @param options The command options given from the constructor.\n\t */\n\tprotected parseConstructorPreConditionsCooldown(options: Command.Options) {\n\t\tparseConstructorPreConditionsCooldown(\n\t\t\tthis,\n\t\t\toptions.cooldownLimit,\n\t\t\toptions.cooldownDelay,\n\t\t\toptions.cooldownScope,\n\t\t\toptions.cooldownFilteredUsers,\n\t\t\tthis.preconditions\n\t\t);\n\t}\n\n\t/**\n\t * Resolves the {@link Command.Options.runIn} option into a {@link Command.RunInTypes} array.\n\t * @param types The types to resolve.\n\t * @returns The resolved types, or `null` if no types were resolved.\n\t */\n\tprotected resolveConstructorPreConditionsRunType(types: CommandRunInUnion): readonly ChannelType[] | null {\n\t\tif (isNullish(types)) return null;\n\t\tif (typeof types === 'number') return [types];\n\t\tif (typeof types === 'string') {\n\t\t\tswitch (types) {\n\t\t\t\tcase 'DM':\n\t\t\t\t\treturn [ChannelType.DM];\n\t\t\t\tcase 'GUILD_TEXT':\n\t\t\t\t\treturn [ChannelType.GuildText];\n\t\t\t\tcase 'GUILD_VOICE':\n\t\t\t\t\treturn [ChannelType.GuildVoice];\n\t\t\t\tcase 'GUILD_NEWS':\n\t\t\t\t\treturn [ChannelType.GuildAnnouncement];\n\t\t\t\tcase 'GUILD_NEWS_THREAD':\n\t\t\t\t\treturn [ChannelType.AnnouncementThread];\n\t\t\t\tcase 'GUILD_PUBLIC_THREAD':\n\t\t\t\t\treturn [ChannelType.PublicThread];\n\t\t\t\tcase 'GUILD_PRIVATE_THREAD':\n\t\t\t\t\treturn [ChannelType.PrivateThread];\n\t\t\t\tcase 'GUILD_ANY':\n\t\t\t\t\treturn GuildChannelTypes;\n\t\t\t\tdefault:\n\t\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// If there's no channel it can run on, throw an error:\n\t\tif (types.length === 0) {\n\t\t\tthrow new Error(`${this.constructor.name}[${this.name}]: \"runIn\" was specified as an empty array.`);\n\t\t}\n\n\t\tif (types.length === 1) {\n\t\t\treturn this.resolveConstructorPreConditionsRunType(types[0]);\n\t\t}\n\n\t\tconst resolved = new Set<ChannelType>();\n\t\tfor (const typeResolvable of types) {\n\t\t\tfor (const type of this.resolveConstructorPreConditionsRunType(typeResolvable) ?? []) resolved.add(type);\n\t\t}\n\n\t\t// If all types were resolved, optimize to null:\n\t\tif (resolved.size === ChannelTypes.length) return null;\n\n\t\t// Return the resolved types in ascending order:\n\t\treturn [...resolved].sort((a, b) => a - b);\n\t}\n\n\tpublic static runInTypeIsSpecificsObject(types: Command.Options['runIn']): types is CommandSpecificRunIn {\n\t\tif (!isObject(types)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst specificTypes = types as CommandSpecificRunIn;\n\t\treturn Boolean(specificTypes.chatInputRun || specificTypes.messageRun || specificTypes.contextMenuRun);\n\t}\n}\n\nexport namespace Command {\n\texport type Options = CommandOptions;\n\texport type JSON = CommandJSON;\n\t/** @deprecated Use {@linkcode LoaderContext} instead. */\n\texport type Context = LoaderContext;\n\texport type LoaderContext = AliasPiece.LoaderContext<'commands'>;\n\texport type RunInTypes = CommandOptionsRunType;\n\texport type RunInUnion = CommandRunInUnion;\n\texport type SpecificRunIn = CommandSpecificRunIn;\n\texport type ChatInputCommandInteraction<Cached extends import('discord.js').CacheType = import('discord.js').CacheType> =\n\t\timport('discord.js').ChatInputCommandInteraction<Cached>;\n\texport type ContextMenuCommandInteraction<Cached extends import('discord.js').CacheType = import('discord.js').CacheType> =\n\t\timport('discord.js').ContextMenuCommandInteraction<Cached>;\n\texport type AutocompleteInteraction<Cached extends import('discord.js').CacheType = import('discord.js').CacheType> =\n\t\timport('discord.js').AutocompleteInteraction<Cached>;\n\texport type Registry = ApplicationCommandRegistry;\n}\n"]}