UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

39 lines (37 loc) 1.9 kB
"use strict"; const require_lib_types_Enums = require('../types/Enums.cjs'); const require_lib_structures_Command = require('../structures/Command.cjs'); let __sapphire_utilities = require("@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 ((0, __sapphire_utilities.isNullish)(runIn)) return; if (require_lib_structures_Command.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: require_lib_types_Enums.CommandPreConditions.RunIn, context: { types: { messageRun: messageRunTypes ?? [], chatInputRun: chatInputRunTypes ?? [], contextMenuRun: contextMenuRunTypes ?? [] } } }); } else { const types = resolveConstructorPreConditionsRunType(runIn); if (types !== null) preconditionContainerArray.append({ name: require_lib_types_Enums.CommandPreConditions.RunIn, context: { types } }); } } //#endregion exports.parseConstructorPreConditionsRunIn = parseConstructorPreConditionsRunIn; //# sourceMappingURL=runIn.cjs.map