@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
1 lines • 3.22 kB
Source Map (JSON)
{"version":3,"sources":["../../../../src/lib/precondition-resolvers/runIn.ts"],"names":["isNullish","Command","CommandPreConditions"],"mappings":";;;;;;;;AAcO,SAAS,kCAAA,CACf,KACA,EAAA,sCAAA,EACA,0BACC,EAAA;AAED,EAAI,IAAAA,mBAAA,CAAU,KAAK,CAAG,EAAA;AAEtB,EAAI,IAAAC,mBAAA,CAAQ,0BAA2B,CAAA,KAAK,CAAG,EAAA;AAC9C,IAAM,MAAA,eAAA,GAAkB,sCAAuC,CAAA,KAAA,CAAM,UAAU,CAAA;AAC/E,IAAM,MAAA,iBAAA,GAAoB,sCAAuC,CAAA,KAAA,CAAM,YAAY,CAAA;AACnF,IAAM,MAAA,mBAAA,GAAsB,sCAAuC,CAAA,KAAA,CAAM,cAAc,CAAA;AAEvF,IAAA,IAAI,eAAoB,KAAA,IAAA,IAAQ,iBAAsB,KAAA,IAAA,IAAQ,wBAAwB,IAAM,EAAA;AAC3F,MAAA,0BAAA,CAA2B,MAAO,CAAA;AAAA,QACjC,MAAMC,8BAAqB,CAAA,KAAA;AAAA,QAC3B,OAAS,EAAA;AAAA,UACR,KAAO,EAAA;AAAA,YACN,UAAA,EAAY,mBAAmB,EAAC;AAAA,YAChC,YAAA,EAAc,qBAAqB,EAAC;AAAA,YACpC,cAAA,EAAgB,uBAAuB;AAAC;AACzC;AACD,OACA,CAAA;AAAA;AACF,GACM,MAAA;AACN,IAAM,MAAA,KAAA,GAAQ,uCAAuC,KAAK,CAAA;AAC1D,IAAA,IAAI,UAAU,IAAM,EAAA;AACnB,MAA2B,0BAAA,CAAA,MAAA,CAAO,EAAE,IAAM,EAAAA,8BAAA,CAAqB,OAAO,OAAS,EAAA,EAAE,KAAM,EAAA,EAAG,CAAA;AAAA;AAC3F;AAEF;AA/BgB,MAAA,CAAA,kCAAA,EAAA,oCAAA,CAAA","file":"runIn.cjs","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"]}