diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 977bd23..e1489cc 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -23,15 +23,15 @@ import type { UnionToTuple } from '../utilities/resolveParameters'; function isChatInputCommand(i : CommandInteraction) : i is ChatInputCommandInteraction { return i.isChatInputCommand(); } -function applicationCommandHandler(plugged: PluggedModule | undefined, interaction: CommandInteraction) { +function applicationCommandHandler(plugged: PluggedModule| undefined, interaction: CommandInteraction) { if (plugged === undefined) { return throwError(() => SernError.UndefinedModule); } const eventPlugins = plugged.plugins.filter(isEventPlugin); return match(interaction) .when(isChatInputCommand, i => { - const ctx = Context.wrap(i); - const res = eventPlugins.map(e => { + const ctx = Context.wrap(i); + const res = eventPlugins.map(e => { return e.execute( [ctx, ['slash', i.options]] , controller); @@ -73,7 +73,7 @@ function messageComponentInteractionHandler( }) as Awaited>[]; return of({ type : plugged.mod.type, res, plugged, ctx }); }) - .otherwise(_ => throwError( () => SernError.NotSupportedInteraction) ); + .otherwise(() => throwError( () => SernError.NotSupportedInteraction) ); } export const onInteractionCreate = (wrapper: Wrapper) => { diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index 875e082..f0bc9e5 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -81,11 +81,3 @@ export function ignoreNonBot(prefix: string) { }); } -export function partition(condition: (el: T) => el is U, array: T[]): [U[], T[]] { - const uArr: U[] = []; - const vArr: T[] = []; - for (const el of array) { - (condition(el) ? uArr : vArr).push(el); - } - return [uArr, vArr]; -} diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 140f352..d6e7083 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -10,7 +10,7 @@ import type { } from '../structures/modules/commands/moduleHandler'; import { CommandType } from '../sern'; import { CommandPlugin, EventPlugin, PluginType, SernPlugin } from '../plugins/plugin'; -import { partition } from './observableHandling'; +import { partition } from '../utilities/partition'; import { Err, Ok, Result } from 'ts-results'; import type { PluggedModule } from '../structures/modules/module'; import type { Awaitable } from 'discord.js'; @@ -106,7 +106,7 @@ function isCmdPlugin(p: SernPlugin): p is CommandPlugin { return (p.type & PluginType.Command) !== 0; } -export function isEventPlugin(p: SernPlugin): p is EventPlugin { +export function isEventPlugin(p: SernPlugin): p is EventPlugin { return (p.type & PluginType.Event) !== 0; } diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index d5e2749..fecfeb3 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -57,7 +57,7 @@ export type EventPlugin = { export type SernPlugin = CommandPlugin | EventPlugin; -export function plugins | CommandPlugin>(...plug: V[]) { +export function plugins(...plug: SernPlugin[]) { return plug; } diff --git a/src/handler/structures/modules/commands/module.ts b/src/handler/structures/modules/commands/module.ts index 3864b0d..9ee8528 100644 --- a/src/handler/structures/modules/commands/module.ts +++ b/src/handler/structures/modules/commands/module.ts @@ -2,7 +2,6 @@ import type { ApplicationCommandOptionData, Awaitable, ButtonInteraction, - ContextMenuCommandInteraction, MessageContextMenuCommandInteraction, SelectMenuInteraction, } from 'discord.js'; diff --git a/src/handler/utilities/partition.ts b/src/handler/utilities/partition.ts new file mode 100644 index 0000000..f83c1c0 --- /dev/null +++ b/src/handler/utilities/partition.ts @@ -0,0 +1,8 @@ +export function partition(condition: (el: T) => el is U, array: T[]): [U[], T[]] { + const uArr: U[] = []; + const vArr: T[] = []; + for (const el of array) { + (condition(el) ? uArr : vArr).push(el); + } + return [uArr, vArr]; +} diff --git a/src/index.ts b/src/index.ts index 791cb53..1948fb5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ export * as Sern from './handler/sern'; export * from './types/handler'; export * from './handler/structures/structxports'; +export * from './handler/plugins/plugin'; \ No newline at end of file