This commit is contained in:
Dragon Fire
2021-06-05 18:13:07 -04:00
parent 2a764e3edc
commit 7d3b0672be
+18
View File
@@ -11,10 +11,28 @@ module.exports = class Argument {
this.oneOf = options.oneOf;
this.default = options.default;
this.avatarSize = options.avatarSize || 2048;
this.validator = options.validate;
this.parser = options.parse;
this.emptyChecker = options.isEmpty;
}
get type() {
if (this.typeID.includes('|')) return new UnionType(this.client, this.typeID);
return this.client.registry.types.get(this.typeID);
}
validate(val, msg, arg) {
if (this.validator) return this.validator(val, msg, arg);
return this.type.validate(val, msg, arg);
}
parse(val, msg, arg) {
if (this.parser) return this.parser(val, msg, arg);
return this.type.parse(val, msg, arg);
}
isEmpty(val, msg, arg) {
if (this.emptyChecker) return this.emptyChecker(val, msg, arg);
return this.type.isEmpty(val, msg, arg);
}
};