diff --git a/src/handler/sern/sern.ts b/src/handler/sern/sern.ts index 83080fc..62124b8 100644 --- a/src/handler/sern/sern.ts +++ b/src/handler/sern/sern.ts @@ -41,7 +41,7 @@ export namespace Sern { return "This command is not availible in this guild!" } if (module.type === CommandType.SLASH) return `This may be a slash command and not a legacy command` - let args = this.msgHandler.fmtMsg.slice(1).join(" "); + let args = this.msgHandler.fmtMsg.join(" "); let parsedArgs = module.parse === undefined ? Ok("") : module.parse(message, args); if(parsedArgs.err) return parsedArgs.val; let fn = await module.delegate(message, parsedArgs) diff --git a/src/handler/utils/preprocessors/args.ts b/src/handler/utils/preprocessors/args.ts index f3424ac..c0881ca 100644 --- a/src/handler/utils/preprocessors/args.ts +++ b/src/handler/utils/preprocessors/args.ts @@ -21,15 +21,14 @@ export namespace Utils { * * @param {string} arg - command arguments * @param {possibleOutput} onFailure - If cannot parse `arg` into boolean. - * @param { {yesRegex: RegExp, noRegex: RegExp} } regexes - default regexes: yes : `/(yes|y|👍)/gi`, no : /(no|n|👎)/gi + * @param { {yesRegex: RegExp, noRegex: RegExp} } regexes - default regexes: yes : `/^(?:y(?:es)?|👍)$/i`, no : /^(?:n(?:o)?|👎)$/i * @returns { ArgType } attemps to parse `args` as a boolean */ export function parseBool( arg: string, - onFailure: possibleOutput = `Cannot parse ${arg} as a boolean`, - regexes : {yesRegex: RegExp, noRegex: RegExp} = {yesRegex : /(yes|y|👍)/gi, noRegex : /(no|n|👎)/gi} + onFailure: possibleOutput = `Cannot parse "${arg}" as a boolean`, + regexes : {yesRegex: RegExp, noRegex: RegExp} = { yesRegex : /^(?:y(?:es)?|👍)$/i , noRegex : /^(?:n(?:o)?|👎)$/i } ): ArgType { - if(arg.match(regexes.yesRegex)) return Ok(true); if(arg.match(regexes.noRegex)) return Ok(false); return Err(onFailure); @@ -51,7 +50,7 @@ export namespace Utils { * @returns {ArgType} */ export function toPositiveInt(arg: string, onFailure: possibleOutput) : ArgType { - return Utils.parseInt(arg, onFailure).andThen( num => Ok(num > 0 ? num : Math.abs(num))) + return Utils.parseInt(arg, onFailure).andThen( num => Ok(num > 0 ? num :-num)) } /**