UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

65 lines (62 loc) 2.32 kB
'use strict'; var result = require('@sapphire/result'); // src/lib/utils/preconditions/conditions/PreconditionConditionOr.ts var PreconditionConditionOr = { async messageSequential(message, command, entries, context) { let error = null; for (const child of entries) { const result = await child.messageRun(message, command, context); if (result.isOk()) return result; error = result; } return error ?? result.Result.ok(); }, async messageParallel(message, command, entries, context) { const results = await Promise.all(entries.map((entry) => entry.messageRun(message, command, context))); let error = null; for (const result of results) { if (result.isOk()) return result; error = result; } return error ?? result.Result.ok(); }, async chatInputSequential(interaction, command, entries, context) { let error = null; for (const child of entries) { const result = await child.chatInputRun(interaction, command, context); if (result.isOk()) return result; error = result; } return error ?? result.Result.ok(); }, async chatInputParallel(interaction, command, entries, context) { const results = await Promise.all(entries.map((entry) => entry.chatInputRun(interaction, command, context))); let error = null; for (const result of results) { if (result.isOk()) return result; error = result; } return error ?? result.Result.ok(); }, async contextMenuSequential(interaction, command, entries, context) { let error = null; for (const child of entries) { const result = await child.contextMenuRun(interaction, command, context); if (result.isOk()) return result; error = result; } return error ?? result.Result.ok(); }, async contextMenuParallel(interaction, command, entries, context) { const results = await Promise.all(entries.map((entry) => entry.contextMenuRun(interaction, command, context))); let error = null; for (const result of results) { if (result.isOk()) return result; error = result; } return error ?? result.Result.ok(); } }; exports.PreconditionConditionOr = PreconditionConditionOr; //# sourceMappingURL=PreconditionConditionOr.cjs.map //# sourceMappingURL=PreconditionConditionOr.cjs.map