fix(lib/discord/flux): patch dispatch method instead of using interceptors

Previously patched events weren't being returned at all.
This commit is contained in:
PalmDevs 2025-08-11 16:47:59 +07:00
parent dcfe40c1d7
commit 28f8c02869
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

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