@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
45 lines (42 loc) • 1.67 kB
JavaScript
;
var lexure = require('@sapphire/lexure');
var result = require('@sapphire/result');
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var never = /* @__PURE__ */ __name(() => result.Option.none, "never");
var always = /* @__PURE__ */ __name(() => true, "always");
var _FlagUnorderedStrategy = class _FlagUnorderedStrategy extends lexure.PrefixedStrategy {
constructor({ flags, options, prefixes = ["--", "-", "\u2014"], 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$1 = super.matchFlag(s);
if (result$1.isSomeAnd((value) => this.allowedFlag(value))) return result$1;
return result.Option.none;
}
matchOption(s) {
const result$1 = super.matchOption(s);
if (result$1.isSomeAnd((option) => this.allowedOption(option[0]))) return result$1;
return result.Option.none;
}
allowedFlag(s) {
return this.flags.includes(s);
}
allowedOption(s) {
return this.options.includes(s);
}
};
__name(_FlagUnorderedStrategy, "FlagUnorderedStrategy");
var FlagUnorderedStrategy = _FlagUnorderedStrategy;
exports.FlagUnorderedStrategy = FlagUnorderedStrategy;
//# sourceMappingURL=FlagUnorderedStrategy.cjs.map
//# sourceMappingURL=FlagUnorderedStrategy.cjs.map