diff --git a/lib/discord/src/common/index.ts b/lib/discord/src/common/index.ts index af5a0fe..c3dea99 100644 --- a/lib/discord/src/common/index.ts +++ b/lib/discord/src/common/index.ts @@ -1,5 +1,14 @@ -import { byName, byProps } from '@revenge-mod/modules/finders/filters' +import { + byDependencies, + byName, + byProps, + every, + looseDeps, + preferExports, + relativeDep, +} from '@revenge-mod/modules/finders/filters' import { lookupModule } from '@revenge-mod/modules/finders/lookup' +import { proxify } from '@revenge-mod/utils/proxy' import type { Metro } from '@revenge-mod/modules/types' import type { DiscordModules } from '../types' @@ -16,3 +25,35 @@ export const [Tokens, TokensModuleId] = lookupModule(byProps('RawColor')) as [ any, Metro.ModuleID, ] + +const OnlyImportTrackerDep = [2] + +export let Constants: DiscordModules.Constants = proxify( + () => { + const [module] = lookupModule( + preferExports( + byProps('ME'), + every( + // ID: 1236 + // Deps: 26, 1237, 1238, 1239, 1240, ... + // Every module has only one dependency, which is the import tracker + byDependencies( + looseDeps([ + undefined, + relativeDep(1), + relativeDep(2), + relativeDep(3), + relativeDep(4), + ]), + ), + byDependencies( + looseDeps(new Array(5).fill(OnlyImportTrackerDep)), + ), + ), + ), + ) + + if (module) return (Constants = module) + }, + { hint: 'object' }, +)! diff --git a/lib/discord/src/types/index.ts b/lib/discord/src/types/index.ts index 6a57cbf..29849b5 100644 --- a/lib/discord/src/types/index.ts +++ b/lib/discord/src/types/index.ts @@ -113,6 +113,16 @@ export namespace DiscordModules { [index: string]: unknown } + export interface Constants { + [K: string]: + | string + | number + | boolean + | null + | ((...args: any[]) => any) + | Constants + } + /** * Discord's `Logger` class. *