Add argument invalidtext

This commit is contained in:
Dragon Fire
2024-03-22 19:51:58 -04:00
parent fc37fdf491
commit c0112f9ad6
6 changed files with 24 additions and 366 deletions
+20
View File
@@ -1,4 +1,5 @@
const UnionType = require('./UnionType');
const { list } = require('../util/Util');
module.exports = class Argument {
constructor(client, options) {
@@ -37,4 +38,23 @@ module.exports = class Argument {
if (this.emptyChecker) return this.emptyChecker(val, msg, arg);
return this.type.isEmpty(val, msg, arg);
}
get invalidText() {
if (this.oneOf) {
return `It must be one of the following: ${list(arg.oneOf, 'or')}`;
} else if (this.max !== null && this.min !== null && (this.typeID === 'integer' || this.typeID === 'float')) {
return `It must be a number from ${this.min} to ${this.max}.`;
} else if (this.max !== null && this.min === null && (this.typeID === 'integer' || this.typeID === 'float')) {
return `It must be a number less than or equal to ${this.max}.`;
} else if (this.min !== null && this.max === null && (this.typeID === 'integer' || this.typeID === 'float')) {
return `It must be a number greater than or equal to ${this.min}.`
} else if (this.min !== null && this.max !== null && this.typeID === 'string') {
return `It must be at least ${this.min} characters long and at most ${this.max} characters long.`;
} else if (this.min !== null && this.max === null && this.typeID === 'string') {
return `It must be at least ${this.min} characters long.`;
} else if (this.max !== null && this.min === null && this.typeID === 'string') {
return `It must be at most ${this.max} characters long.`;
}
return `It must be a ${this.typeID}.`;
}
};