chore: prettier reformat

This commit is contained in:
jacoobes
2022-05-13 14:45:06 -05:00
parent 88dcdee818
commit 3dedba3493
9 changed files with 663 additions and 613 deletions

View File

@@ -1,40 +1,38 @@
import { ApplicationCommandType, ComponentType, InteractionType, MessageComponentInteraction, MessageComponentType } from 'discord.js';
import { ApplicationCommandType, ComponentType } from 'discord.js';
import { readdirSync, statSync } from 'fs';
import { join } from 'path';
import { from, Observable } from 'rxjs';
import { CommandType } from '../sern';
import type { PluggedModule } from '../structures/modules/module';
export const BothCommand = new Map<string, PluggedModule>();
export const ApplicationCommandStore = {
[ApplicationCommandType.User] : new Map<string, PluggedModule>(),
[ApplicationCommandType.Message] : new Map<string, PluggedModule>(),
[ApplicationCommandType.ChatInput] : new Map<string, PluggedModule>(),
} as {[K in ApplicationCommandType] : Map<string, PluggedModule> };
[ApplicationCommandType.User]: new Map<string, PluggedModule>(),
[ApplicationCommandType.Message]: new Map<string, PluggedModule>(),
[ApplicationCommandType.ChatInput]: new Map<string, PluggedModule>(),
} as { [K in ApplicationCommandType]: Map<string, PluggedModule> };
export const MessageCompCommandStore = {
[ComponentType.Button] : new Map<string, PluggedModule>(),
[ComponentType.SelectMenu] : new Map<string, PluggedModule>()
[ComponentType.Button]: new Map<string, PluggedModule>(),
[ComponentType.SelectMenu]: new Map<string, PluggedModule>(),
};
export const TextCommandStore = {
text : new Map<string, PluggedModule>(),
aliases : new Map<string, PluggedModule>()
text: new Map<string, PluggedModule>(),
aliases: new Map<string, PluggedModule>(),
};
// Courtesy @Townsy45
function readPath(dir: string, arrayOfFiles: string[] = []): string[] {
try {
const files = readdirSync(dir);
for (const file of files) {
if (statSync(dir + '/' + file).isDirectory()) readPath(dir + '/' + file, arrayOfFiles);
else arrayOfFiles.push(join(dir, '/', file));
try {
const files = readdirSync(dir);
for (const file of files) {
if (statSync(dir + '/' + file).isDirectory()) readPath(dir + '/' + file, arrayOfFiles);
else arrayOfFiles.push(join(dir, '/', file));
}
} catch (err) {
throw err;
}
} catch (err) {
throw err;
}
return arrayOfFiles;
return arrayOfFiles;
}
export const fmtFileName = (n: string) => n.substring(0, n.length - 3);
@@ -45,18 +43,19 @@ export const fmtFileName = (n: string) => n.substring(0, n.length - 3);
* @param commandDir
*/
export function buildData(commandDir: string ): Observable<
{
export function buildData(commandDir: string): Observable<{
plugged: PluggedModule;
absPath: string;
}> {
return from(getCommands(commandDir).map(absPath => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const plugged = (<PluggedModule> require(absPath).module);
return { plugged, absPath };
}));
}> {
return from(
getCommands(commandDir).map(absPath => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const plugged = <PluggedModule>require(absPath).module;
return { plugged, absPath };
}),
);
}
export function getCommands(dir: string): string[] {
return readPath(join(process.cwd(), dir));
return readPath(join(process.cwd(), dir));
}