diff --git a/src/handler/utils/preprocessors/args.ts b/src/handler/Utilities/Preprocessors/args.ts similarity index 96% rename from src/handler/utils/preprocessors/args.ts rename to src/handler/Utilities/Preprocessors/args.ts index febd314..de9d6c1 100644 --- a/src/handler/utils/preprocessors/args.ts +++ b/src/handler/Utilities/Preprocessors/args.ts @@ -1,5 +1,5 @@ import { Err, Ok, Result } from 'ts-results'; -import type { possibleOutput } from '../../../types/handler'; +import type { possibleOutput } from '../../../Types/Handler'; /** * Wrapper type taking `Ok(T)` or `Err(possibleOutput)` e.g `Result { if (arg.match(regexes.yesRegex)) return Ok(true); if (arg.match(regexes.noRegex)) return Ok(false); + return Err(onFailure); } @@ -73,5 +73,5 @@ export function toPositiveInt(arg: string, onFailure: possibleOutput): ArgType} */ export function toNegativeInt(arg: string, onFailure: possibleOutput): ArgType { - return parseInt(arg, onFailure).andThen(num => Ok(num > 0 ? -num : num)) + return parseInt(arg, onFailure).andThen(num => Ok(num > 0 ? -num : num)); } diff --git a/src/handler/utils/messageHelpers.ts b/src/handler/Utilities/messageHelpers.ts similarity index 100% rename from src/handler/utils/messageHelpers.ts rename to src/handler/Utilities/messageHelpers.ts diff --git a/src/handler/utils/readFile.ts b/src/handler/Utilities/readFile.ts similarity index 85% rename from src/handler/utils/readFile.ts rename to src/handler/Utilities/readFile.ts index fb8e611..cb1fe86 100644 --- a/src/handler/utils/readFile.ts +++ b/src/handler/Utilities/readFile.ts @@ -23,15 +23,15 @@ export const Alias = new Map(); // Courtesy of Townsy#0001 on Discord async function readPath(dir: string, arrayOfFiles: string[] = []): Promise { try { - const files = readdirSync(dir); - for (const file of files) { - if (statSync(dir + '/' + file).isDirectory()) - await readPath(dir + '/' + file, arrayOfFiles) - else - arrayOfFiles.push(join(dir, '/', file)); + const files = readdirSync(dir); + for (const file of files) { + if (statSync(dir + '/' + file).isDirectory()) + await readPath(dir + '/' + file, arrayOfFiles) + else + arrayOfFiles.push(join(dir, '/', file)); } } catch (err) { - throw err; + throw err; } return arrayOfFiles; diff --git a/src/handler/sern.ts b/src/handler/sern.ts index eda48a4..3bc7f01 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -1,12 +1,12 @@ -import * as Files from './utils/readFile' -import type * as Utils from './utils/preprocessors/args'; +import * as Files from './Utilities/readFile'; +import type * as Utils from './Utilities/Preprocessors/args'; import type { - Arg, - Context, - Visibility, - possibleOutput -} from '../types/handler'; + Arg, + Context, + Visibility, + possibleOutput +} from '../Types/Handler'; import type { ApplicationCommandOptionData, @@ -17,7 +17,7 @@ import type { } from 'discord.js'; import { Ok, Result, None, Some } from 'ts-results'; -import { isBot, hasPrefix, fmt } from './utils/messageHelpers'; +import { isBot, hasPrefix, fmt } from './Utilities/messageHelpers'; /** @@ -29,14 +29,13 @@ export class Handler { /** * @constructor - * @param {Wrapper} wrapper Some data that is required to run sern handler + * @param {Wrapper} wrapper The data that is required to run sern handler */ constructor( wrapper: Wrapper, ) { this.wrapper = wrapper; - this.client /** diff --git a/src/index.ts b/src/index.ts index 78e789f..d7fa6c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ -import * as Sern from './handler/sern'; -import * as Utils from './handler/utils/preprocessors/args'; -import * as Types from './types/handler'; +import * as Sern from './Handler/sern'; +import * as Utils from './Handler/Utilities/Preprocessors/args'; +import * as Types from './Types/Handler'; module.exports = { Sern, Utils, Types }; export { Sern, Utils, Types }; diff --git a/src/types/handler.ts b/src/types/handler.ts index 9bfa72f..bfd267d 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -8,7 +8,7 @@ import type { MessageOptions } from 'discord.js'; -import type * as Sern from '../handler/sern'; +import type * as Sern from '../Handler/sern'; export type Visibility = 'private' | 'public'; @@ -19,15 +19,17 @@ export type delegate = Sern.Module['delegate']; // Thanks @cursorsdottsx export type ParseType = { - [K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never; + [K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never; } [keyof T]; // A Sern.Module['delegate'] will carry a Context Parameter + export type Context = { message: Option, interaction: Option } -export type Arg = ParseType<{text : string, slash : SlashOptions}> + +export type Arg = ParseType<{ text: string, slash: SlashOptions }>; // TypeAlias for interaction.options export type SlashOptions = Omit;