diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 645d502..871f5a8 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -1,10 +1,12 @@ -import type { Interaction } from 'discord.js'; -import { fromEvent, Observable, of, concatMap, map, tap } from 'rxjs'; +import { ApplicationCommandType, Interaction } from 'discord.js'; +import { fromEvent, Observable, of, concatMap, map, filter } from 'rxjs'; import { CommandType } from '../sern'; import Context from '../structures/context'; import type Wrapper from '../structures/wrapper'; import * as Files from '../utilities/readFile'; +import { match, partition } from './observableHandling'; +import { isEventPlugin } from './readyEvent'; @@ -12,20 +14,27 @@ import * as Files from '../utilities/readFile'; export const onInteractionCreate = ( wrapper : Wrapper ) => { const { client } = wrapper; - const interactionEvent = (> fromEvent(client, 'interactionCreate')) + const interactionEvent$ = (> fromEvent(client, 'interactionCreate')) + + const processPlugins = ( plug : Observable ) => { + return plug + }; - interactionEvent.pipe( - concatMap ( async interaction => { + const processCommand$ = interactionEvent$.pipe( + concatMap( interaction => { if(interaction.isCommand()) { - return of( - Files.ApplicationCommandStore[interaction.commandType] - .get(interaction.commandName)).pipe( - - ) + return of( Files + .ApplicationCommandStore[interaction.commandType] + .get(interaction.commandName) + ).pipe( + ) + } + }) + ); + + - }) - ).subscribe() /** concatMap (async interaction => { if (interaction.isChatInputCommand()) { return of(Files.Commands.get(interaction.commandName)) diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index ff1c99c..b9b4c64 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -21,7 +21,7 @@ export const onMessageCreate = (wrapper : Wrapper) => { map(message => { const [prefix, ...rest] = fmt(message, defaultPrefix); return { - ctx : Context.wrap(message), + ctx : Context.wrap(message), //TODO : check for BothCommand args : ['text', rest], mod : Files.ApplicationCommandStore[1].get(prefix) ?? Files.BothCommand.get(prefix) @@ -31,7 +31,7 @@ export const onMessageCreate = (wrapper : Wrapper) => { const ensureModuleType$ = processMessage$.pipe( concatMap(payload => of(payload.mod) .pipe( - filterCorrectModule(CommandType.Text), + filterCorrectModule(CommandType.Text), // fix for BothCommand map( textCommand => ({ ...payload, mod : textCommand })) ))); diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 7511588..adcd605 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -2,15 +2,13 @@ import {concatMap, from, fromEvent, map, take,concat, skip, Observable, of, import { basename } from 'path'; import * as Files from '../utilities/readFile'; import type Wrapper from '../structures/wrapper'; -import type { ApplicationModules, HandlerCallback, MessageCompModules, ModDefs, ModuleCbs, ModuleHandlers, ModuleStates, ModuleType, StateMachine, TextCommandModules, ModuleHandler } from '../structures/modules/commands/moduleHandler'; +import type { HandlerCallback, ModuleHandlers, ModuleStates, ModuleType} from '../structures/modules/commands/moduleHandler'; import { CommandType } from '../sern'; import { CommandPlugin, EventPlugin, PluginType, SernPlugin } from '../plugins/plugin'; import { match, partition } from './observableHandling'; import { Err, Ok, Result } from 'ts-results'; import type { PluggedModule } from '../structures/modules/module'; import type { Awaitable } from 'discord.js'; -import { SernError } from '../structures/errors'; -import type { ContextMenuMsg, ContextMenuUser, Module, SlashCommand } from '../structures/modules/commands/module'; export const onReady = ( wrapper : Wrapper ) => {