@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
1 lines • 3.68 kB
Source Map (JSON)
{"version":3,"file":"PreconditionConditionAnd.mjs","names":["PreconditionConditionAnd: IPreconditionCondition"],"sources":["../../../../../../src/lib/utils/preconditions/conditions/PreconditionConditionAnd.ts"],"sourcesContent":["import { Result } from '@sapphire/result';\nimport type { IPreconditionCondition } from './IPreconditionCondition';\n\n/**\n * An {@link IPreconditionCondition} which runs all containers similarly to doing (V0 && V1 [&& V2 [&& V3 ...]]).\n * @since 1.0.0\n */\nexport const PreconditionConditionAnd: IPreconditionCondition = {\n\tasync messageSequential(message, command, entries, context) {\n\t\tfor (const child of entries) {\n\t\t\tconst result = await child.messageRun(message, command, context);\n\t\t\tif (result.isErr()) return result;\n\t\t}\n\n\t\treturn Result.ok();\n\t},\n\tasync messageParallel(message, command, entries, context) {\n\t\tconst results = await Promise.all(entries.map((entry) => entry.messageRun(message, command, context)));\n\t\t// This is simplified compared to PreconditionContainerAny, because we're looking for the first error.\n\t\t// However, the base implementation short-circuits with the first Ok.\n\t\treturn results.find((res) => res.isErr()) ?? Result.ok();\n\t},\n\tasync chatInputSequential(interaction, command, entries, context) {\n\t\tfor (const child of entries) {\n\t\t\tconst result = await child.chatInputRun(interaction, command, context);\n\t\t\tif (result.isErr()) return result;\n\t\t}\n\n\t\treturn Result.ok();\n\t},\n\tasync chatInputParallel(interaction, command, entries, context) {\n\t\tconst results = await Promise.all(entries.map((entry) => entry.chatInputRun(interaction, command, context)));\n\t\t// This is simplified compared to PreconditionContainerAny, because we're looking for the first error.\n\t\t// However, the base implementation short-circuits with the first Ok.\n\t\treturn results.find((res) => res.isErr()) ?? Result.ok();\n\t},\n\tasync contextMenuSequential(interaction, command, entries, context) {\n\t\tfor (const child of entries) {\n\t\t\tconst result = await child.contextMenuRun(interaction, command, context);\n\t\t\tif (result.isErr()) return result;\n\t\t}\n\n\t\treturn Result.ok();\n\t},\n\tasync contextMenuParallel(interaction, command, entries, context) {\n\t\tconst results = await Promise.all(entries.map((entry) => entry.contextMenuRun(interaction, command, context)));\n\t\t// This is simplified compared to PreconditionContainerAny, because we're looking for the first error.\n\t\t// However, the base implementation short-circuits with the first Ok.\n\t\treturn results.find((res) => res.isErr()) ?? Result.ok();\n\t}\n};\n"],"mappings":";;;;;;;AAOA,MAAaA,2BAAmD;CAC/D,MAAM,kBAAkB,SAAS,SAAS,SAAS,SAAS;AAC3D,OAAK,MAAM,SAAS,SAAS;GAC5B,MAAM,SAAS,MAAM,MAAM,WAAW,SAAS,SAAS,QAAQ;AAChE,OAAI,OAAO,OAAO,CAAE,QAAO;;AAG5B,SAAO,OAAO,IAAI;;CAEnB,MAAM,gBAAgB,SAAS,SAAS,SAAS,SAAS;AAIzD,UAHgB,MAAM,QAAQ,IAAI,QAAQ,KAAK,UAAU,MAAM,WAAW,SAAS,SAAS,QAAQ,CAAC,CAAC,EAGvF,MAAM,QAAQ,IAAI,OAAO,CAAC,IAAI,OAAO,IAAI;;CAEzD,MAAM,oBAAoB,aAAa,SAAS,SAAS,SAAS;AACjE,OAAK,MAAM,SAAS,SAAS;GAC5B,MAAM,SAAS,MAAM,MAAM,aAAa,aAAa,SAAS,QAAQ;AACtE,OAAI,OAAO,OAAO,CAAE,QAAO;;AAG5B,SAAO,OAAO,IAAI;;CAEnB,MAAM,kBAAkB,aAAa,SAAS,SAAS,SAAS;AAI/D,UAHgB,MAAM,QAAQ,IAAI,QAAQ,KAAK,UAAU,MAAM,aAAa,aAAa,SAAS,QAAQ,CAAC,CAAC,EAG7F,MAAM,QAAQ,IAAI,OAAO,CAAC,IAAI,OAAO,IAAI;;CAEzD,MAAM,sBAAsB,aAAa,SAAS,SAAS,SAAS;AACnE,OAAK,MAAM,SAAS,SAAS;GAC5B,MAAM,SAAS,MAAM,MAAM,eAAe,aAAa,SAAS,QAAQ;AACxE,OAAI,OAAO,OAAO,CAAE,QAAO;;AAG5B,SAAO,OAAO,IAAI;;CAEnB,MAAM,oBAAoB,aAAa,SAAS,SAAS,SAAS;AAIjE,UAHgB,MAAM,QAAQ,IAAI,QAAQ,KAAK,UAAU,MAAM,eAAe,aAAa,SAAS,QAAQ,CAAC,CAAC,EAG/F,MAAM,QAAQ,IAAI,OAAO,CAAC,IAAI,OAAO,IAAI;;CAEzD"}