From 9e4adf8bcfc1b05a24707122310f8364caee5c20 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 8 Mar 2022 00:30:18 -0600 Subject: [PATCH] refactor(structures) create structures dir --- src/handler/sern.ts | 25 +++++-------------------- src/handler/{ => structures}/context.ts | 0 src/handler/{ => structures}/module.ts | 6 +++--- src/handler/structures/wrapper.ts | 21 +++++++++++++++++++++ src/handler/utilities/readFile.ts | 2 +- src/types/handler.ts | 2 +- 6 files changed, 31 insertions(+), 25 deletions(-) rename src/handler/{ => structures}/context.ts (100%) rename src/handler/{ => structures}/module.ts (81%) create mode 100644 src/handler/structures/wrapper.ts diff --git a/src/handler/sern.ts b/src/handler/sern.ts index c516287..08167ef 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -1,5 +1,4 @@ import * as Files from './utilities/readFile'; - import type { possibleOutput, } from '../types/handler'; @@ -15,12 +14,13 @@ import { Ok, None, Some } from 'ts-results'; import { isNotFromBot, hasPrefix, fmt } from './utilities/messageHelpers'; import Logger, { sEvent } from './logger'; import { AllTrue } from './utilities/higherOrders'; -import type Module from './module'; -import Context from './context'; +import type Module from './structures/module'; +import Context from './structures/context'; +import type Wrapper from './structures/wrapper'; + /** * @class */ - export class Handler { private wrapper: Wrapper; private defaultLogger: Logger = new Logger(); @@ -272,22 +272,7 @@ export class Handler { } } -/** - * An object to be passed into Sern.Handler constructor. - * @typedef {object} Wrapper - * @property {readonly Client} client - * @property {readonly string} prefix - * @property {readonly string} commands - * @prop {(handler : Handler) => void)} init - * @property {readonly {test: boolean, id: string}[]} privateServers - */ -export interface Wrapper { - readonly client: Client; - readonly prefix: string; - readonly commands: string; - init?: (handler: Handler) => void; - readonly privateServers: { test: boolean; id: string }[]; -} + diff --git a/src/handler/context.ts b/src/handler/structures/context.ts similarity index 100% rename from src/handler/context.ts rename to src/handler/structures/context.ts diff --git a/src/handler/module.ts b/src/handler/structures/module.ts similarity index 81% rename from src/handler/module.ts rename to src/handler/structures/module.ts index 9671c0c..47f45e0 100644 --- a/src/handler/module.ts +++ b/src/handler/structures/module.ts @@ -1,9 +1,9 @@ -import type { Visibility, possibleOutput, Arg } from '../types/handler'; -import type { CommandType } from './sern'; +import type { Visibility, possibleOutput, Arg } from '../../types/handler'; +import type { CommandType } from '../sern'; import type Context from './context' ; import type { Awaitable } from 'discord.js'; import type { Ok } from 'ts-results'; -import type * as Utils from './utilities/preprocessors/args'; +import type * as Utils from '../utilities/preprocessors/args'; /** * An object that gets imported and acts as a command. diff --git a/src/handler/structures/wrapper.ts b/src/handler/structures/wrapper.ts new file mode 100644 index 0000000..43fbaad --- /dev/null +++ b/src/handler/structures/wrapper.ts @@ -0,0 +1,21 @@ +import type { Client } from 'discord.js'; +import type * as Sern from '../sern'; + +/** + * An object to be passed into Sern.Handler constructor. + * @typedef {object} Wrapper + * @property {readonly Client} client + * @property {readonly string} prefix + * @property {readonly string} commands + * @prop {(handler : Handler) => void)} ini + * @property {readonly {test: boolean, id: string}[]} privateServers + */ +interface Wrapper { + readonly client: Client; + readonly prefix: string; + readonly commands: string; + init?: (handler: Sern.Handler) => void; + readonly privateServers: { test: boolean; id: string }[]; +} + +export default Wrapper; diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index 6287a6d..4392131 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -1,6 +1,6 @@ import type { ApplicationCommandOptionData } from 'discord.js'; import type * as Sern from '../sern'; -import type Module from '../module'; +import type Module from '../structures/module'; import { readdirSync, statSync } from 'fs'; import { basename, join } from 'path'; diff --git a/src/types/handler.ts b/src/types/handler.ts index 82f38d0..b4b998c 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -5,7 +5,7 @@ import type { MessageOptions, } from 'discord.js'; -import type Module from '../handler/module'; +import type Module from '../handler/structures/module'; export type Visibility = 'private' | 'public';