@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
42 lines (40 loc) • 1.53 kB
JavaScript
import { __name } from '../../../chunk-PAWJFY3S.mjs';
import { PrefixedStrategy } from '@sapphire/lexure';
import { Option } from '@sapphire/result';
var never = /* @__PURE__ */ __name(() => Option.none, "never");
var always = /* @__PURE__ */ __name(() => true, "always");
var _FlagUnorderedStrategy = class _FlagUnorderedStrategy extends 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 = super.matchFlag(s);
if (result.isSomeAnd((value) => this.allowedFlag(value))) return result;
return Option.none;
}
matchOption(s) {
const result = super.matchOption(s);
if (result.isSomeAnd((option) => this.allowedOption(option[0]))) return result;
return Option.none;
}
allowedFlag(s) {
return this.flags.includes(s);
}
allowedOption(s) {
return this.options.includes(s);
}
};
__name(_FlagUnorderedStrategy, "FlagUnorderedStrategy");
var FlagUnorderedStrategy = _FlagUnorderedStrategy;
export { FlagUnorderedStrategy };
//# sourceMappingURL=FlagUnorderedStrategy.mjs.map
//# sourceMappingURL=FlagUnorderedStrategy.mjs.map