core/inject
Classes
InjectError
Defined in: venpm/src/core/inject.ts:56
Extends
Error
Constructors
Constructor
new InjectError(code, message): InjectError;Defined in: venpm/src/core/inject.ts:57
Parameters
| Parameter | Type |
|---|---|
code | InjectErrorCode |
message | string |
Returns
Overrides
Error.constructorProperties
cause?
optional cause?: unknown;Defined in: venpm-docs/node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.causecode
code: InjectErrorCode;Defined in: venpm/src/core/inject.ts:57
message
message: string;Defined in: venpm-docs/node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.messagename
name: string;Defined in: venpm-docs/node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.namestack?
optional stack?: string;Defined in: venpm-docs/node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stackstackTraceLimit
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
Error.stackTraceLimitMethods
captureStackTrace()
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.
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:
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
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTraceprepareStackTrace()
static prepareStackTrace(err, stackTraces): any;Defined in: venpm/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTraceInterfaces
InjectResult
Defined in: venpm/src/core/inject.ts:49
Properties
appPath
appPath: string;Defined in: venpm/src/core/inject.ts:51
backupPath
backupPath: string;Defined in: venpm/src/core/inject.ts:53
branch
branch: DiscordBranch;Defined in: venpm/src/core/inject.ts:50
shimAsar
shimAsar: string;Defined in: venpm/src/core/inject.ts:52
InjectStatus
Defined in: venpm/src/core/inject.ts:39
Properties
asarPresent
asarPresent: boolean;Defined in: venpm/src/core/inject.ts:42
True when Resources/app.asar exists (either original or our shim).
backupPresent
backupPresent: boolean;Defined in: venpm/src/core/inject.ts:44
True when Resources/_app.asar (Discord's renamed original) exists.
injected
injected: boolean;Defined in: venpm/src/core/inject.ts:40
legacyShimDirPresent
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
appPath: string;Defined in: venpm/src/core/inject.ts:35
branch
branch: DiscordBranch;Defined in: venpm/src/core/inject.ts:34
platform
platform: Platform;Defined in: venpm/src/core/inject.ts:36
Type Aliases
DiscordBranch
type DiscordBranch = "stable" | "canary" | "ptb";Defined in: venpm/src/core/inject.ts:9
InjectErrorCode
type InjectErrorCode =
| "PLATFORM_UNSUPPORTED"
| "DISCORD_NOT_FOUND"
| "ALREADY_INJECTED"
| "NOT_INJECTED"
| "INJECT_FAILED";Defined in: venpm/src/core/inject.ts:63
Variables
DISCORD_BRANCHES
const DISCORD_BRANCHES: DiscordBranch[];Defined in: venpm/src/core/inject.ts:11
Functions
detectDiscordApps()
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
| Parameter | Type | Default value |
|---|---|---|
fs | FileSystem | undefined |
platform | Platform | process.platform |
Returns
Promise<InjectTarget[]>
getInjectStatus()
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
| Parameter | Type |
|---|---|
fs | FileSystem |
target | InjectTarget |
Returns
Promise<InjectStatus>
injectVencord()
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:
- Rename Discord's app.asar → _app.asar
- 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
| Parameter | Type |
|---|---|
fs | FileSystem |
target | InjectTarget |
Returns
Promise<InjectResult>
uninjectVencord()
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
| Parameter | Type |
|---|---|
fs | FileSystem |
target | InjectTarget |
Returns
Promise<InjectResult>