From 4beee4abf09e5ad3fe8e206bf8544ea9a7a1cec6 Mon Sep 17 00:00:00 2001 From: Neo <80315475+Benzo-Fury@users.noreply.github.com> Date: Fri, 6 Oct 2023 12:31:30 +1000 Subject: [PATCH] refractor: move the change to the parent (executeModule) --- src/handlers/event-utils.ts | 5 +++-- src/handlers/interaction-event.ts | 4 ++-- src/handlers/message-event.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/handlers/event-utils.ts b/src/handlers/event-utils.ts index e61cc2ed..e4c3c891 100644 --- a/src/handlers/event-utils.ts +++ b/src/handlers/event-utils.ts @@ -11,6 +11,7 @@ import { MonoTypeOperatorFunction, catchError, finalize, + mergeMap } from 'rxjs'; import { Files, @@ -149,8 +150,8 @@ export function executeModule( ) { return of(module).pipe( //converting the task into a promise so rxjs can resolve the Awaitable properly - concatMap(() => Result.wrapAsync(async () => task())), - concatMap(result => { + mergeMap(() => Result.wrapAsync(async () => task())), + mergeMap(result => { if (result.isOk()) { emitter.emit('module.activate', SernEmitter.success(module)); return EMPTY; diff --git a/src/handlers/interaction-event.ts b/src/handlers/interaction-event.ts index 2e150dab..0c385af6 100644 --- a/src/handlers/interaction-event.ts +++ b/src/handlers/interaction-event.ts @@ -1,5 +1,5 @@ import { Interaction } from 'discord.js'; -import { mergeMap, merge } from 'rxjs'; +import { concatMap, merge } from 'rxjs'; import { SernEmitter } from '../core'; import { isAutocomplete, @@ -28,6 +28,6 @@ export function interactionHandler([emitter, , , modules, client]: DependencyLis filterTap(e => emitter.emit('warning', SernEmitter.warning(e))), makeModuleExecutor(module => emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure))), - mergeMap(payload => executeModule(emitter, payload)), + concatMap(payload => executeModule(emitter, payload)), ); } diff --git a/src/handlers/message-event.ts b/src/handlers/message-event.ts index aa7a05b2..01d7fe05 100644 --- a/src/handlers/message-event.ts +++ b/src/handlers/message-event.ts @@ -1,4 +1,4 @@ -import { mergeMap, EMPTY } from 'rxjs'; +import { concatMap, EMPTY } from 'rxjs'; import type { Message } from 'discord.js'; import { SernEmitter } from '../core'; import { sharedEventStream, SernError, filterTap } from '../core/_internal'; @@ -42,6 +42,6 @@ export function messageHandler( makeModuleExecutor(module => { emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure)); }), - mergeMap(payload => executeModule(emitter, payload)), + concatMap(payload => executeModule(emitter, payload)), ); }