From 28f8c0286973f4400232c7b21f7de40240156aa1 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Mon, 11 Aug 2025 16:47:59 +0700 Subject: [PATCH] fix(lib/discord/flux): patch `dispatch` method instead of using interceptors Previously patched events weren't being returned at all. --- lib/discord/src/flux.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/discord/src/flux.ts b/lib/discord/src/flux.ts index be3c0ce..1ab9711 100644 --- a/lib/discord/src/flux.ts +++ b/lib/discord/src/flux.ts @@ -8,7 +8,8 @@ export type FluxEventDispatchPatch = ( payload: DiscordModules.Flux.DispatcherPayload, ) => DiscordModules.Flux.DispatcherPayload | undefined | void -;(Dispatcher._interceptors ??= []).unshift(payload => { +const originalDispatch = Dispatcher.dispatch +Dispatcher.dispatch = payload => { let res: typeof payload | undefined | void = payload for (const patch of fPatchesAll) @@ -27,8 +28,10 @@ export type FluxEventDispatchPatch = ( } catch {} } - return !res -}) + if (res) return Reflect.apply(originalDispatch, Dispatcher, [res]) + // If res is undefined, the event is blocked + return Promise.resolve() +} /** * Registers a patch for all Flux events.