From 46b3b9574a22cb2d99e6f9889fd78b9365e98413 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Mon, 9 May 2022 15:01:10 -0500 Subject: [PATCH] chore: eslint formattting --- src/handler/events/interactionCreate.ts | 14 +++++++------- src/handler/events/messageEvent.ts | 10 +++++----- src/handler/events/observableHandling.ts | 4 ++-- src/handler/events/readyEvent.ts | 14 +++++++------- src/handler/plugins/plugin.ts | 14 +++++++------- src/handler/sern.ts | 4 ++-- src/handler/structures/context.ts | 4 ++-- src/handler/structures/modules/module.ts | 8 ++++---- src/handler/utilities/readFile.ts | 10 +++++----- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 5321d69..3a50670 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -13,7 +13,7 @@ import { correctModuleType } from './observableHandling'; export const onInteractionCreate = ( wrapper : Wrapper ) => { const { client } = wrapper; - const interactionEvent$ = (> fromEvent(client, 'interactionCreate')) + const interactionEvent$ = (> fromEvent(client, 'interactionCreate')); interactionEvent$.pipe( concatMap( interaction => { @@ -25,20 +25,20 @@ export const onInteractionCreate = ( wrapper : Wrapper ) => { map ( plug => { console.log('a'); if(plug === undefined) { - return throwError(() => SernError.UndefinedModule) + return throwError(() => SernError.UndefinedModule); } const eventPlugins = plug.plugins.filter(isEventPlugin); match(interaction) .when(i => i.isChatInputCommand(), (i : ChatInputCommandInteraction) => { - console.log("chatI", eventPlugins) + console.log('chatI', eventPlugins); }) .when(() => P._, i => { - console.log("other I", eventPlugins) - }) + console.log('other I', eventPlugins); + }); }) - ) + ); } - return of() + return of(null); }) ).subscribe(console.log); diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index 977f654..9916b89 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -26,7 +26,7 @@ export const onMessageCreate = (wrapper : Wrapper) => { mod : Files.ApplicationCommandStore[1].get(prefix) ?? Files.BothCommand.get(prefix) ?? Files.TextCommandStore.aliases.get(prefix) - } + }; })); const ensureModuleType$ = processMessage$.pipe( concatMap(payload => of(payload.mod) @@ -47,18 +47,18 @@ export const onMessageCreate = (wrapper : Wrapper) => { stop : () => Err.EMPTY }); })); - return from(res).pipe(map(res => ({ plugged, ctx, args, res }))) + return from(res).pipe(map(res => ({ plugged, ctx, args, res }))); })); processEventPlugins$.subscribe( ( { plugged, ctx, args, res } ) => { if(res.every( pl => pl.ok)) { Promise.resolve(plugged.mod.execute(ctx, args)).then(() => console.log(plugged) - ) + ); } else { - console.log(plugged, "failed"); + console.log(plugged, 'failed'); } - }) + }); }; diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index 1347be5..2a1c812 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -91,9 +91,9 @@ export function partition( const uArr : U[] = []; const vArr : T[] = []; for (const el of array ) { - (condition(el) ? uArr : vArr).push(el) + (condition(el) ? uArr : vArr).push(el); } - return [ uArr, vArr ] + return [ uArr, vArr ]; } diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 6a5054d..ba4ab0e 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -33,9 +33,9 @@ export const onReady = ( wrapper : Wrapper ) => { next : () => Ok.EMPTY, stop : () => Err.EMPTY }) - } + }; }); - return of({ plugged : { mod , plugins : eventPlugins }, cmdPluginsRes }) + return of({ plugged : { mod , plugins : eventPlugins }, cmdPluginsRes }); }), ); @@ -63,12 +63,12 @@ export const onReady = ( wrapper : Wrapper ) => { registerModule(mod.name!, mod, plugins); } else { - console.log(`Failed to load command ${mod.name!}`) - console.log(mod) + console.log(`Failed to load command ${mod.name!}`); + console.log(mod); } - }) + }); -} +}; function handler( name : string ) : ModuleHandlers { return { @@ -95,7 +95,7 @@ function handler( name : string ) : ModuleHandlers { [CommandType.MenuSelect] : ( mod, plugins ) => { Files.MessageCompCommandStore[2].set(name, { mod, plugins }); }, - } + }; } diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 0184544..7b97c92 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -11,12 +11,12 @@ // Plugins are reminisce of middleware in express. // -import type { Awaitable, Client } from "discord.js"; -import type { Err, Ok, Result } from "ts-results"; -import type { Module, Override, Wrapper } from "../.."; -import type { CommandType } from "../sern"; -import type { ModuleDefs } from "../structures/modules/commands/moduleHandler"; -import type { BaseModule, PluggedModule } from "../structures/modules/module"; +import type { Awaitable, Client } from 'discord.js'; +import type { Err, Ok, Result } from 'ts-results'; +import type { Module, Override, Wrapper } from '../..'; +import type { CommandType } from '../sern'; +import type { ModuleDefs } from '../structures/modules/commands/moduleHandler'; +import type { BaseModule, PluggedModule } from '../structures/modules/module'; export enum PluginType { Command = 0b01, @@ -71,7 +71,7 @@ export function sernModule return { mod, plugins - } + }; } diff --git a/src/handler/sern.ts b/src/handler/sern.ts index cfa1657..622c72f 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -52,8 +52,8 @@ export function cmdTypeToDjs(ty: CommandType) { .with(CommandType.MenuUser, () => ApplicationCommandType.User) .with(CommandType.MenuMsg, ()=> ApplicationCommandType.Message) .with(CommandType.Both, () => ApplicationCommandType.ChatInput ) - .with(P._, () => { throw new Error(SernError.NonValidModuleType) }) - .exhaustive() + .with(P._, () => { throw new Error(SernError.NonValidModuleType); }) + .exhaustive(); } diff --git a/src/handler/structures/context.ts b/src/handler/structures/context.ts index 62b2b37..5080b46 100644 --- a/src/handler/structures/context.ts +++ b/src/handler/structures/context.ts @@ -136,10 +136,10 @@ export default class Context { return firstSome( this.oInterac.map(async i => { await i.reply( content as InteractionReplyOptions); - return new Context(Some(await i.fetchReply() as Message), Some(i)) + return new Context(Some(await i.fetchReply() as Message), Some(i)); }), this.oMsg.map(async m => { - const reply = await m.reply( content as ReplyMessageOptions ) + const reply = await m.reply( content as ReplyMessageOptions ); return new Context(Some(reply), this.oInterac); }) )!; diff --git a/src/handler/structures/modules/module.ts b/src/handler/structures/modules/module.ts index 74c91ca..5a93758 100644 --- a/src/handler/structures/modules/module.ts +++ b/src/handler/structures/modules/module.ts @@ -1,7 +1,7 @@ -import type { Awaitable, ChatInputCommandInteraction } from "discord.js"; -import type { Args, Module } from "../../.."; -import type { CommandPlugin, EventPlugin, SernPlugin } from "../../plugins/plugin"; -import type Context from "../context"; +import type { Awaitable, ChatInputCommandInteraction } from 'discord.js'; +import type { Args, Module } from '../../..'; +import type { CommandPlugin, EventPlugin, SernPlugin } from '../../plugins/plugin'; +import type Context from '../context'; export interface BaseModule { name? : string; diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index 1ba884e..59f632f 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -11,16 +11,16 @@ export const ApplicationCommandStore = { [ApplicationCommandType.User] : new Map(), [ApplicationCommandType.Message] : new Map(), [ApplicationCommandType.ChatInput] : new Map(), -} as {[K in ApplicationCommandType] : Map } +} as {[K in ApplicationCommandType] : Map }; export const MessageCompCommandStore = { [ComponentType.Button] : new Map(), [ComponentType.SelectMenu] : new Map() -} +}; export const TextCommandStore = { text : new Map(), aliases : new Map() -} +}; // Courtesy @Townsy45 function readPath(dir: string, arrayOfFiles: string[] = []): string[] { @@ -52,8 +52,8 @@ export function buildData(commandDir: string ): Observable< }> { return from(getCommands(commandDir).map(absPath => { const plugged = ( require(absPath).module); - return { plugged, absPath } - })) + return { plugged, absPath }; + })); } export function getCommands(dir: string): string[] {