chore: eslint formattting

This commit is contained in:
Jacob Nguyen
2022-05-09 15:01:10 -05:00
parent 8782cad9cd
commit 46b3b9574a
9 changed files with 41 additions and 41 deletions

View File

@@ -13,7 +13,7 @@ import { correctModuleType } from './observableHandling';
export const onInteractionCreate = ( wrapper : Wrapper ) => {
const { client } = wrapper;
const interactionEvent$ = (<Observable<Interaction>> fromEvent(client, 'interactionCreate'))
const interactionEvent$ = (<Observable<Interaction>> 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);

View File

@@ -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');
}
})
});
};

View File

@@ -91,9 +91,9 @@ export function partition<T,U extends T>(
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 ];
}

View File

@@ -33,9 +33,9 @@ export const onReady = ( wrapper : Wrapper ) => {
next : () => Ok.EMPTY,
stop : () => Err.EMPTY
})
}
};
});
return of({ plugged : <PluggedModule>{ mod , plugins : eventPlugins }, cmdPluginsRes })
return of({ plugged : <PluggedModule>{ 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 });
},
}
};
}

View File

@@ -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
}
};
}

View File

@@ -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();
}

View File

@@ -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);
})
)!;

View File

@@ -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;

View File

@@ -11,16 +11,16 @@ 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> }
} as {[K in ApplicationCommandType] : Map<string, PluggedModule> };
export const MessageCompCommandStore = {
[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>()
}
};
// 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 = (<PluggedModule> require(absPath).module);
return { plugged, absPath }
}))
return { plugged, absPath };
}));
}
export function getCommands(dir: string): string[] {