UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

38 lines (36 loc) 1.71 kB
import { CommandPreConditions } from "../types/Enums.mjs"; import { Command } from "../structures/Command.mjs"; import { isNullish } from "@sapphire/utilities"; //#region src/lib/precondition-resolvers/runIn.ts /** * Appends the `RunIn` precondition based on the values passed, defaulting to `null`, which doesn't add a * precondition. * @param runIn The command's `runIn` option field from the constructor. * @param resolveConstructorPreConditionsRunType The function to resolve the run type from the constructor. * @param preconditionContainerArray The precondition container array to append the precondition to. */ function parseConstructorPreConditionsRunIn(runIn, resolveConstructorPreConditionsRunType, preconditionContainerArray) { if (isNullish(runIn)) return; if (Command.runInTypeIsSpecificsObject(runIn)) { const messageRunTypes = resolveConstructorPreConditionsRunType(runIn.messageRun); const chatInputRunTypes = resolveConstructorPreConditionsRunType(runIn.chatInputRun); const contextMenuRunTypes = resolveConstructorPreConditionsRunType(runIn.contextMenuRun); if (messageRunTypes !== null || chatInputRunTypes !== null || contextMenuRunTypes !== null) preconditionContainerArray.append({ name: CommandPreConditions.RunIn, context: { types: { messageRun: messageRunTypes ?? [], chatInputRun: chatInputRunTypes ?? [], contextMenuRun: contextMenuRunTypes ?? [] } } }); } else { const types = resolveConstructorPreConditionsRunType(runIn); if (types !== null) preconditionContainerArray.append({ name: CommandPreConditions.RunIn, context: { types } }); } } //#endregion export { parseConstructorPreConditionsRunIn }; //# sourceMappingURL=runIn.mjs.map