From fd9dc35ff097cc08ea552fd2f0d5a7517d7163a5 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 21 Aug 2022 22:46:58 -0500 Subject: [PATCH] feat: removing unused types --- src/handler/structures/moduleManager.ts | 128 ------------------------ src/types/handler.ts | 6 -- 2 files changed, 134 deletions(-) delete mode 100644 src/handler/structures/moduleManager.ts diff --git a/src/handler/structures/moduleManager.ts b/src/handler/structures/moduleManager.ts deleted file mode 100644 index 2b20eda..0000000 --- a/src/handler/structures/moduleManager.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { ApplicationCommandType, ComponentType } from 'discord.js'; -import type { - BothCommand, - CommandModule, - ContextMenuMsg, - ContextMenuUser, - ModalSubmitCommand, - SlashCommand, -} from './module.js'; -import type { EventEmitter } from 'node:events'; -import type { DefinitelyDefined } from '../../types/handler'; - -class ModuleManager { - private BothCommands = new Map(); - private ApplicationCommands = { - [ApplicationCommandType.User]: new Map(), - [ApplicationCommandType.Message]: new Map(), - [ApplicationCommandType.ChatInput]: new Map(), - } as { [K in ApplicationCommandType]: Map }; - - private MessageCompCommands = { - [ComponentType.Button]: new Map(), - [ComponentType.SelectMenu]: new Map(), - [ComponentType.TextInput]: new Map(), - }; - private TextCommands = { - text: new Map(), - aliases: new Map(), - }; - private ModalSubmitCommands = new Map(); - /** - * keeps all external emitters stored here - */ - private ExternalEventEmitters = new Map(); - - private static getFromMap(map: Map, name: string): Readonly | undefined { - return Object.freeze(map.get(name)); - } - private static setIntoMap(map: Map, key: string, value: T) { - map.set(key, value); - } - - public setIntoApplicationStore( - type: ApplicationCommandType, - value: DefinitelyDefined, - ) { - ModuleManager.setIntoMap(this.ApplicationCommands[type], value.name, value); - } - - public setIntoComponentStore( - type: Exclude, - value: DefinitelyDefined, - ) { - ModuleManager.setIntoMap(this.MessageCompCommands[type], value.name, value); - } - - public getFromApplicationType(type: ApplicationCommandType, name: string) { - return ModuleManager.getFromMap(this.ApplicationCommands[type], name); - } - - public getFromComponentsStore( - type: Exclude, - name: string, - ) { - return ModuleManager.getFromMap(this.MessageCompCommands[type], name); - } - - setIntoBoth(mod: DefinitelyDefined) { - ModuleManager.setIntoMap(this.BothCommands,mod.name, mod); - } - - setIntoSlash(mod: DefinitelyDefined) { - this.setIntoApplicationStore(ApplicationCommandType.ChatInput, mod); - } - /** - * Checks both aliases and text command map - */ - setIntoText(mod: DefinitelyDefined) { - ModuleManager.setIntoMap(this.TextCommands.text,mod.name, mod); - } - setIntoMessageContextMenu(mod: DefinitelyDefined) { - return this.setIntoApplicationStore(ApplicationCommandType.Message, mod); - } - - setIntoUserContextMenu(mod: DefinitelyDefined) { - return this.setIntoApplicationStore(ApplicationCommandType.User, mod); - } - - setIntoEventEmitters(mod: EventEmitter) { - return ModuleManager.setIntoMap(this.ExternalEventEmitters,mod.constructor.name, mod); - } - - setIntoModalStore(mod: DefinitelyDefined) { - return ModuleManager.setIntoMap(this.ModalSubmitCommands, mod.name, mod); - } - - getFromBoth(name: string) { - return ModuleManager.getFromMap(this.BothCommands, name); - } - - getFromSlash(name: string) { - return this.getFromApplicationType(ApplicationCommandType.ChatInput, name); - } - /** - * Checks both aliases and text command map - */ - getFromText(name: string) { - return ( - ModuleManager.getFromMap(this.TextCommands.text, name) ?? - ModuleManager.getFromMap(this.TextCommands.aliases, name) - ); - } - getFromMessageContextMenu(name: string) { - return this.getFromApplicationType(ApplicationCommandType.Message, name); - } - - getFromUserContextMenu(name: string) { - return this.getFromApplicationType(ApplicationCommandType.User, name); - } - - getExternalEventEmitter(name: string) { - return ModuleManager.getFromMap(this.ExternalEventEmitters, name); - } - - getModalHandler(name: string) { - return ModuleManager.getFromMap(this.ModalSubmitCommands, name); - } -} diff --git a/src/types/handler.ts b/src/types/handler.ts index 3c4cb13..a89539a 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -26,11 +26,6 @@ export type EventInput = | { mod: EventModule; absPath: string }[] | (() => { mod: EventModule; absPath: string }[]); -export type Reconstruct = T extends Omit ? O & Reconstruct : T; - -export type IsOptional = { - [K in keyof T]-?: T[K] extends Required[K] ? false : true; -}; /** * Turns a function with a union of array of args into a single union @@ -44,7 +39,6 @@ export type SpreadParams unknown> = ( * After modules are transformed, name and description are given default values if none * are provided to Module. This type represents that transformation */ -export type DefinedModule = DefinitelyDefined; export type DefinedCommandModule = DefinitelyDefined; export type DefinedEventModule = DefinitelyDefined; export type Payload =