UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

42 lines (40 loc) 1.36 kB
"use strict"; let __sapphire_result = require("@sapphire/result"); let __sapphire_lexure = require("@sapphire/lexure"); //#region src/lib/utils/strategies/FlagUnorderedStrategy.ts const never = () => __sapphire_result.Option.none; const always = () => true; var FlagUnorderedStrategy = class extends __sapphire_lexure.PrefixedStrategy { constructor({ flags, options, prefixes = [ "--", "-", "—" ], separators = ["=", ":"] } = {}) { super(prefixes, separators); this.flags = flags || []; this.options = options || []; if (this.flags === true) this.allowedFlag = always; else if (this.flags.length === 0) this.matchFlag = never; if (this.options === true) this.allowedOption = always; else if (this.options.length === 0) this.matchOption = never; } matchFlag(s) { const result = super.matchFlag(s); if (result.isSomeAnd((value) => this.allowedFlag(value))) return result; return __sapphire_result.Option.none; } matchOption(s) { const result = super.matchOption(s); if (result.isSomeAnd((option) => this.allowedOption(option[0]))) return result; return __sapphire_result.Option.none; } allowedFlag(s) { return this.flags.includes(s); } allowedOption(s) { return this.options.includes(s); } }; //#endregion exports.FlagUnorderedStrategy = FlagUnorderedStrategy; //# sourceMappingURL=FlagUnorderedStrategy.cjs.map