From 38963ffa19eace111ee2864c838ada00fc40f26b Mon Sep 17 00:00:00 2001 From: jacoobes Date: Mon, 14 Feb 2022 09:21:32 -0600 Subject: [PATCH] rf --- src/handler/utilities/readFile.ts | 54 +++++++++++++------------------ 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index 9fc78ba..f8d694b 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -1,23 +1,15 @@ -import type { - ApplicationCommandOptionData -} from 'discord.js'; +import type { ApplicationCommandOptionData } from 'discord.js'; -import { - readdirSync, - statSync -} from 'fs'; +import { readdirSync, statSync } from 'fs'; -import { - basename, - join -} from 'path'; +import { basename, join } from 'path'; import type * as Sern from '../sern'; export type CommandVal = { - mod: Sern.Module, - options: ApplicationCommandOptionData[], -} + mod: Sern.Module; + options: ApplicationCommandOptionData[]; +}; export const Commands = new Map(); export const Alias = new Map(); @@ -27,11 +19,9 @@ async function readPath(dir: string, arrayOfFiles: string[] = []): Promise n.substring(0, n.length - 3); /** - * @param {Sern.Handler} handler an instance of Sern.Handler + * @param {Sern.Handler} handler an instance of Sern.Handler * @returns {Promise<{ name: string; mod: Sern.Module; absPath: string; }[]>} data from command files -*/ + */ -export async function buildData(handler: Sern.Handler) - : Promise<{ - name: string; - mod: Sern.Module; - absPath: string; - }[]> { - const commandDir = handler.commandDir; - return Promise.all((await getCommands(commandDir)) - .map(async absPath => { +export async function buildData(handler: Sern.Handler): Promise< + { + name: string; + mod: Sern.Module; + absPath: string; + }[] +> { + const commandDir = handler.commandDir; + return Promise.all( + (await getCommands(commandDir)).map(async (absPath) => { return { name: basename(absPath), mod: (await import(absPath)).default as Sern.Module, absPath }; - })); + }), + ); } export async function getCommands(dir: string): Promise {