@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
1 lines • 2.83 kB
Source Map (JSON)
{"version":3,"file":"runIn.cjs","names":["Command","CommandPreConditions"],"sources":["../../../../src/lib/precondition-resolvers/runIn.ts"],"sourcesContent":["import { isNullish } from '@sapphire/utilities';\nimport type { ChannelType } from 'discord.js';\nimport { Command } from '../structures/Command';\nimport type { CommandRunInUnion, CommandSpecificRunIn } from '../types/CommandTypes';\nimport { CommandPreConditions } from '../types/Enums';\nimport type { PreconditionContainerArray } from '../utils/preconditions/PreconditionContainerArray';\n\n/**\n * Appends the `RunIn` precondition based on the values passed, defaulting to `null`, which doesn't add a\n * precondition.\n * @param runIn The command's `runIn` option field from the constructor.\n * @param resolveConstructorPreConditionsRunType The function to resolve the run type from the constructor.\n * @param preconditionContainerArray The precondition container array to append the precondition to.\n */\nexport function parseConstructorPreConditionsRunIn(\n\trunIn: CommandRunInUnion | CommandSpecificRunIn,\n\tresolveConstructorPreConditionsRunType: (types: CommandRunInUnion) => readonly ChannelType[] | null,\n\tpreconditionContainerArray: PreconditionContainerArray\n) {\n\t// Early return if there's no runIn option:\n\tif (isNullish(runIn)) return;\n\n\tif (Command.runInTypeIsSpecificsObject(runIn)) {\n\t\tconst messageRunTypes = resolveConstructorPreConditionsRunType(runIn.messageRun);\n\t\tconst chatInputRunTypes = resolveConstructorPreConditionsRunType(runIn.chatInputRun);\n\t\tconst contextMenuRunTypes = resolveConstructorPreConditionsRunType(runIn.contextMenuRun);\n\n\t\tif (messageRunTypes !== null || chatInputRunTypes !== null || contextMenuRunTypes !== null) {\n\t\t\tpreconditionContainerArray.append({\n\t\t\t\tname: CommandPreConditions.RunIn,\n\t\t\t\tcontext: {\n\t\t\t\t\ttypes: {\n\t\t\t\t\t\tmessageRun: messageRunTypes ?? [],\n\t\t\t\t\t\tchatInputRun: chatInputRunTypes ?? [],\n\t\t\t\t\t\tcontextMenuRun: contextMenuRunTypes ?? []\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t} else {\n\t\tconst types = resolveConstructorPreConditionsRunType(runIn);\n\t\tif (types !== null) {\n\t\t\tpreconditionContainerArray.append({ name: CommandPreConditions.RunIn, context: { types } });\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,mCACf,OACA,wCACA,4BACC;AAED,yCAAc,MAAM,CAAE;AAEtB,KAAIA,uCAAQ,2BAA2B,MAAM,EAAE;EAC9C,MAAM,kBAAkB,uCAAuC,MAAM,WAAW;EAChF,MAAM,oBAAoB,uCAAuC,MAAM,aAAa;EACpF,MAAM,sBAAsB,uCAAuC,MAAM,eAAe;AAExF,MAAI,oBAAoB,QAAQ,sBAAsB,QAAQ,wBAAwB,KACrF,4BAA2B,OAAO;GACjC,MAAMC,6CAAqB;GAC3B,SAAS,EACR,OAAO;IACN,YAAY,mBAAmB,EAAE;IACjC,cAAc,qBAAqB,EAAE;IACrC,gBAAgB,uBAAuB,EAAE;IACzC,EACD;GACD,CAAC;QAEG;EACN,MAAM,QAAQ,uCAAuC,MAAM;AAC3D,MAAI,UAAU,KACb,4BAA2B,OAAO;GAAE,MAAMA,6CAAqB;GAAO,SAAS,EAAE,OAAO;GAAE,CAAC"}