diff --git a/src/handler/structures/structxports.ts b/src/handler/structures/structxports.ts index 1c9ea05..ec02939 100644 --- a/src/handler/structures/structxports.ts +++ b/src/handler/structures/structxports.ts @@ -2,4 +2,8 @@ import Context from './context'; import * as Modules from './commands/module'; import type Wrapper from './wrapper'; -export { Context, Modules, Wrapper }; +export { + Context, + Modules, + Wrapper +}; diff --git a/src/handler/utilities/preprocessors/args.ts b/src/handler/utilities/preprocessors/args.ts deleted file mode 100644 index d293609..0000000 --- a/src/handler/utilities/preprocessors/args.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Err, Ok, Result } from 'ts-results'; -import type { possibleOutput } from '../../../types/handler'; - -/** - * Wrapper type taking `Ok(T)` or `Err(possibleOutput)` e.g `Result = Result; - -/** - * - * @param {string} arg - command arguments - * @param {possibleOutput} onFailure - if `Number.parseInt` returns NaN - * @returns {ArgType} Attempts to use `Number.parseInt()` on `arg` - */ - -export function parseInt(arg: string, onFailure: possibleOutput): ArgType { - const val = Number.parseInt(arg); - - return val === NaN ? Err(onFailure) : Ok(val); -} - -/** - * - * @param {string} arg - command arguments - * @param {possibleOutput} onFailure - If cannot parse `arg` into boolean. - * @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: /^(?: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); -} - -/** - * - * @param {string} arg - command arguments - * @param {string} sep - default separator = ' ' - * @returns {Ok} - */ - -export function toArr(arg: string, sep = ' '): ArgType { - return Ok(arg.split(sep)); -} - -/** - * - * @param {string} arg - command arguments - * @param {possibleOutput} onFailure - delegates `Utils.parseInt` - * @returns {ArgType} - */ - -export function toPositiveInt(arg: string, onFailure: possibleOutput): ArgType { - return parseInt(arg, onFailure).andThen((num) => Ok(num > 0 ? num : -num)); -} - -/** - * - * @param {string} arg - command arguments - * @param {possibleOutput} onFailure - delegates `parseInt` - * @returns {ArgType} - */ -export function toNegativeInt(arg: string, onFailure: possibleOutput): ArgType { - return parseInt(arg, onFailure).andThen((num) => Ok(num > 0 ? -num : num)); -} diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index bd874ff..23a48b8 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -1,5 +1,3 @@ -import type { ApplicationCommandOptionData } from 'discord.js'; - import { readdirSync, statSync } from 'fs'; import { join } from 'path'; import type { Module } from '../structures/commands/module'; diff --git a/src/handler/utilities/utilsExports.ts b/src/handler/utilities/utilsExports.ts deleted file mode 100644 index 6c02f52..0000000 --- a/src/handler/utilities/utilsExports.ts +++ /dev/null @@ -1,4 +0,0 @@ -import * as Preprocessors from './preprocessors/args'; - -module.exports = { Preprocessors }; -export { Preprocessors }; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index ed35363..791cb53 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,3 @@ -import * as Sern from './handler/sern'; -import * as Utils from './handler/utilities/utilsExports'; -import * as Types from './types/handler'; -import * as Structures from './handler/structures/structxports'; - -module.exports = { Sern, Utils, Types, Structures }; -export { Sern, Utils, Types, Structures }; +export * as Sern from './handler/sern'; +export * from './types/handler'; +export * from './handler/structures/structxports';