diff --git a/src/classes/CommandOption.ts b/src/classes/CommandOption.ts index d15f76c..c8a3468 100644 --- a/src/classes/CommandOption.ts +++ b/src/classes/CommandOption.ts @@ -115,6 +115,32 @@ class CommandOption implements ICommandOption { return { value: this.rawValue.join(' '), removed: this.rawValue }; } + protected INTEGER() { + if (!this.rawValue) return { error: true }; + const integer = parseInt(this.rawValue[0]); + if(isNaN(integer)) return { error: true }; + if (this.minimum !== undefined && integer < this.minimum) return { error: true }; + if (this.maximum !== undefined && integer > this.maximum) return { error: true }; + return { value: integer, removed: [this.rawValue[0]] }; + } + + protected FLOAT() { + if (!this.rawValue) return { error: true }; + const float = parseFloat(this.rawValue[0]); + if(isNaN(float)) return { error: true }; + if (this.minimum !== undefined && float < this.minimum) return { error: true }; + if (this.maximum !== undefined && float > this.maximum) return { error: true }; + return { value: (float), removed: [this.rawValue[0]] }; + } + + protected BOOLEAN() { + if (!this.rawValue) return { error: true }; + const boolean = this.resolver?.resolveBoolean(this.rawValue[0]) || null; + if (boolean === null && this.valueOptional) return { value: this.defaultValue, removed: [] }; + else if(boolean === null) return { error: true }; + return { value: boolean, removed: [this.rawValue[0]] }; + } + } export { CommandOption };