UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

44 lines (42 loc) 1.93 kB
"use strict"; let __sapphire_result = require("@sapphire/result"); //#region src/lib/utils/preconditions/conditions/PreconditionConditionAnd.ts /** * An {@link IPreconditionCondition} which runs all containers similarly to doing (V0 && V1 [&& V2 [&& V3 ...]]). * @since 1.0.0 */ const PreconditionConditionAnd = { async messageSequential(message, command, entries, context) { for (const child of entries) { const result = await child.messageRun(message, command, context); if (result.isErr()) return result; } return __sapphire_result.Result.ok(); }, async messageParallel(message, command, entries, context) { return (await Promise.all(entries.map((entry) => entry.messageRun(message, command, context)))).find((res) => res.isErr()) ?? __sapphire_result.Result.ok(); }, async chatInputSequential(interaction, command, entries, context) { for (const child of entries) { const result = await child.chatInputRun(interaction, command, context); if (result.isErr()) return result; } return __sapphire_result.Result.ok(); }, async chatInputParallel(interaction, command, entries, context) { return (await Promise.all(entries.map((entry) => entry.chatInputRun(interaction, command, context)))).find((res) => res.isErr()) ?? __sapphire_result.Result.ok(); }, async contextMenuSequential(interaction, command, entries, context) { for (const child of entries) { const result = await child.contextMenuRun(interaction, command, context); if (result.isErr()) return result; } return __sapphire_result.Result.ok(); }, async contextMenuParallel(interaction, command, entries, context) { return (await Promise.all(entries.map((entry) => entry.contextMenuRun(interaction, command, context)))).find((res) => res.isErr()) ?? __sapphire_result.Result.ok(); } }; //#endregion exports.PreconditionConditionAnd = PreconditionConditionAnd; //# sourceMappingURL=PreconditionConditionAnd.cjs.map