Skip to content

core/inject

Classes

InjectError

Defined in: venpm/src/core/inject.ts:56

Extends

  • Error

Constructors

Constructor
ts
new InjectError(code, message): InjectError;

Defined in: venpm/src/core/inject.ts:57

Parameters
ParameterType
codeInjectErrorCode
messagestring
Returns

InjectError

Overrides
ts
Error.constructor

Properties

cause?
ts
optional cause?: unknown;

Defined in: venpm-docs/node_modules/typescript/lib/lib.es2022.error.d.ts:24

Inherited from
ts
Error.cause
code
ts
code: InjectErrorCode;

Defined in: venpm/src/core/inject.ts:57

message
ts
message: string;

Defined in: venpm-docs/node_modules/typescript/lib/lib.es5.d.ts:1075

Inherited from
ts
Error.message
name
ts
name: string;

Defined in: venpm-docs/node_modules/typescript/lib/lib.es5.d.ts:1074

Inherited from
ts
Error.name
stack?
ts
optional stack?: string;

Defined in: venpm-docs/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from
ts
Error.stack
stackTraceLimit
ts
static stackTraceLimit: number;

Defined in: venpm/node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from
ts
Error.stackTraceLimit

Methods

captureStackTrace()
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: venpm/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from
ts
Error.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: venpm/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from
ts
Error.prepareStackTrace

Interfaces

InjectResult

Defined in: venpm/src/core/inject.ts:49

Properties

appPath
ts
appPath: string;

Defined in: venpm/src/core/inject.ts:51

backupPath
ts
backupPath: string;

Defined in: venpm/src/core/inject.ts:53

branch
ts
branch: DiscordBranch;

Defined in: venpm/src/core/inject.ts:50

shimAsar
ts
shimAsar: string;

Defined in: venpm/src/core/inject.ts:52


InjectStatus

Defined in: venpm/src/core/inject.ts:39

Properties

asarPresent
ts
asarPresent: boolean;

Defined in: venpm/src/core/inject.ts:42

True when Resources/app.asar exists (either original or our shim).

backupPresent
ts
backupPresent: boolean;

Defined in: venpm/src/core/inject.ts:44

True when Resources/_app.asar (Discord's renamed original) exists.

injected
ts
injected: boolean;

Defined in: venpm/src/core/inject.ts:40

legacyShimDirPresent
ts
legacyShimDirPresent: boolean;

Defined in: venpm/src/core/inject.ts:46

True when a legacy Resources/app/ directory shim exists.


InjectTarget

Defined in: venpm/src/core/inject.ts:33

Properties

appPath
ts
appPath: string;

Defined in: venpm/src/core/inject.ts:35

branch
ts
branch: DiscordBranch;

Defined in: venpm/src/core/inject.ts:34

platform
ts
platform: Platform;

Defined in: venpm/src/core/inject.ts:36

Type Aliases

DiscordBranch

ts
type DiscordBranch = "stable" | "canary" | "ptb";

Defined in: venpm/src/core/inject.ts:9


InjectErrorCode

ts
type InjectErrorCode = 
  | "PLATFORM_UNSUPPORTED"
  | "DISCORD_NOT_FOUND"
  | "ALREADY_INJECTED"
  | "NOT_INJECTED"
  | "INJECT_FAILED";

Defined in: venpm/src/core/inject.ts:63

Variables

DISCORD_BRANCHES

ts
const DISCORD_BRANCHES: DiscordBranch[];

Defined in: venpm/src/core/inject.ts:11

Functions

detectDiscordApps()

ts
function detectDiscordApps(fs, platform?): Promise<InjectTarget[]>;

Defined in: venpm/src/core/inject.ts:116

Discover installed Discord branches on the current platform.

On unsupported platforms, returns an empty array. Callers should treat that as "not supported" rather than "none installed".

Parameters

ParameterTypeDefault value
fsFileSystemundefined
platformPlatformprocess.platform

Returns

Promise<InjectTarget[]>


getInjectStatus()

ts
function getInjectStatus(fs, target): Promise<InjectStatus>;

Defined in: venpm/src/core/inject.ts:197

Inspect an on-disk Discord install and report injection status. Does not modify anything. Returns a detailed breakdown so callers can decide whether to re-inject, warn, or abort.

Parameters

ParameterType
fsFileSystem
targetInjectTarget

Returns

Promise<InjectStatus>


injectVencord()

ts
function injectVencord(fs, target): Promise<InjectResult>;

Defined in: venpm/src/core/inject.ts:282

Patch a Discord install so Electron loads Vencord's patcher before the original asar. Uses the asar-shim layout:

  1. Rename Discord's app.asar → _app.asar
  2. Pack a shim asar (package.json + index.js) and place it at app.asar

Also cleans up legacy plain-directory shims from older venpm versions.

On failure during shim packing, the rename is rolled back so the next Discord launch reverts cleanly to stock behaviour.

Parameters

ParameterType
fsFileSystem
targetInjectTarget

Returns

Promise<InjectResult>


uninjectVencord()

ts
function uninjectVencord(fs, target): Promise<InjectResult>;

Defined in: venpm/src/core/inject.ts:359

Reverse an inject: remove the shim asar, rename backup back to app.asar. Also cleans up any legacy plain-directory shim.

Parameters

ParameterType
fsFileSystem
targetInjectTarget

Returns

Promise<InjectResult>

Disclaimer — Not affiliated with Discord Inc. or Vencord. Client mods are against Discord's ToS. Use at your own risk.