Add examples

This commit is contained in:
Dragon Fire
2024-05-16 17:16:00 -04:00
parent 9d00180cb3
commit 986d5d90fb
28 changed files with 138 additions and 32 deletions
+6
View File
@@ -15,6 +15,7 @@ module.exports = class Argument {
this.default = typeof options.default === 'undefined' ? null : options.default;
this.infinite = Boolean(options.infinite);
this.avatarSize = typeof options.avatarSize === 'undefined' ? 2048 : options.avatarSize;
this.examples = typeof options.examples === 'undefined' ? null : options.examples;
this.validator = typeof options.validate === 'undefined' ? null : options.validate;
this.parser = typeof options.parse === 'undefined' ? null : options.parse;
this.emptyChecker = typeof options.isEmpty === 'undefined' ? null : options.isEmpty;
@@ -40,6 +41,11 @@ module.exports = class Argument {
return this.type.isEmpty(val, msg, arg);
}
example(msg, arg) {
if (this.examples) return this.examples[Math.floor(Math.random() * this.examples.length)];
return this.type.example(msg, arg);
}
get invalidText() {
if (this.oneOf) {
return `It must be one of the following: ${list(this.oneOf, 'or')}`;