From 2f21be2c5249513f773fc12a77802a4e46709994 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Thu, 3 Jul 2025 20:55:26 +0700 Subject: [PATCH] fix: don't wrap functions twice in entrypoint --- src/index.ts | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/index.ts b/src/index.ts index 11ba166..d97e0e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ import { getErrorStack } from '@revenge-mod/utils/errors' const IndexModuleId = 0 onModuleFirstRequired(IndexModuleId, function onIndexRequired() { - runCatching(() => { + try { if (__BUILD_FLAG_LOG_PROMISE_REJECTIONS__) require('./patches/log-promise-rejections') @@ -34,7 +34,7 @@ onModuleFirstRequired(IndexModuleId, function onIndexRequired() { require('@revenge-mod/plugins/preinit') onModuleInitialized(IndexModuleId, function onIndexInitialized() { - runCatching(() => { + try { // Initialize init libraries require('@revenge-mod/storage/init') require('@revenge-mod/externals/init') @@ -44,28 +44,28 @@ onModuleFirstRequired(IndexModuleId, function onIndexRequired() { // Run all init plugins require('~/plugins/init') require('@revenge-mod/plugins/init') - }) + } catch (e) { + onError(e) + } }) - }) + } catch (e) { + onError(e) + } }) -function runCatching(fn: () => void) { - try { - fn() - } catch (e) { - // TODO(init): Move to use native provided alert function, which will accept a string stack trace - // Above will reduce the need for runCatching() to exist, as the code won't be able to be deduped any further - const { ClientInfoModule, DeviceModule } = - require('@revenge-mod/discord/native') as typeof import('@revenge-mod/discord/native') +function onError(e: unknown) { + // TODO(init): Move to use native provided alert function, which will accept a string stack trace + // Above will reduce the need for runCatching() to exist, as the code won't be able to be deduped any further + const { ClientInfoModule, DeviceModule } = + require('@revenge-mod/discord/native') as typeof import('@revenge-mod/discord/native') - const Client = ClientInfoModule.getConstants() - const Device = DeviceModule.getConstants() + const Client = ClientInfoModule.getConstants() + const Device = DeviceModule.getConstants() - alert( - `Failed to load Revenge (${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__}))\n` + - `Discord: ${Client.Version} (${Client.Build})\n` + - `Device: ${Device.deviceManufacturer} ${Device.deviceModel}\n\n` + - getErrorStack(e), - ) - } + alert( + `Failed to load Revenge (${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__}))\n` + + `Discord: ${Client.Version} (${Client.Build})\n` + + `Device: ${Device.deviceManufacturer} ${Device.deviceModel}\n\n` + + getErrorStack(e), + ) }