How vendicated/vencord works
Purpose and deployment targets
Vencord is a TypeScript Discord client modification that injects runtime patches, built-in plugins, settings UI, themes, and privacy changes into Discord. It supports Electron desktop Discord and browser-based extension/userscript targets. Main injected runtime entry points are src/Vencord.ts, src/VencordNative.ts, and browser/Vencord.ts; Electron main-process integration begins at src/main/index.ts.
Build and injection pipeline
Node-based build scripts assemble target-specific bundles and injection assets. scripts/build/build.mjs is the general build orchestrator; scripts/build/buildWeb.mjs produces browser variants; scripts/build/inject/react.mjs supports injecting into Discord’s React application. Browser packaging is defined by browser/manifest.json, with background/content boundaries in browser/background.js and browser/content.js.
Discord runtime discovery and patching
The renderer-side core locates Discord’s Webpack modules and mutates loaded code/components so Vencord can attach behavior despite Discord’s internal APIs. This boundary is centered on src/webpack/webpack.ts, src/webpack/patchWebpack.ts, and src/webpack/common/index.ts. Patch utilities in src/utils/patches.ts underpin plugin and core modifications; Discord’s own Webpack bundle and UI/store APIs remain external, unstable dependencies.
Core lifecycle, plugins, and extension APIs
src/Vencord.ts initializes the injected client runtime and coordinates Vencord functionality. src/api/PluginManager.ts owns enabling, disabling, and lifecycle management of the large built-in plugin catalog under src/plugins/; plugin contributions are exposed through APIs such as src/api/Commands/index.ts, src/api/ContextMenu.ts, and src/api/MessageEvents.ts. Internal plugin API adapters in src/plugins/_api/ bridge these public APIs to Discord patch points.
Settings, persistence, sync, and presentation
Settings are a shared data contract, persisted through src/shared/SettingsStore.ts and accessed by src/api/Settings.ts / src/api/DataStore/index.ts. Optional cloud and offline synchronization flows live in src/api/SettingsSync/cloudSync.ts and src/api/SettingsSync/offline.ts. React settings screens and plugin configuration controls are rendered from src/components/settings/tabs/, especially src/components/settings/tabs/plugins/index.tsx; these consume settings and PluginManager state.
Desktop native boundary
Electron-specific capabilities are separated into a main process, preload bridge, and renderer-facing native abstraction. src/main/ipcMain.ts and src/main/ipcPlugins.ts expose IPC operations; src/preload.ts provides the constrained preload layer; src/utils/native.ts is the renderer-side access boundary. Main-process services cover updater, themes, CSP handling, and persistence across Discord updates in src/main/updater/index.ts, src/main/themes/index.ts, and src/main/persistAfterDiscordUpdates.ts.
Browser boundary and shared type packages
Browser builds cannot use Electron IPC; they use extension messaging and a native stub instead (browser/background.js, browser/GMPolyfill.js, browser/VencordNativeStub.ts). The pnpm workspace also publishes declaration-only contracts for Discord internals and Vencord consumers: packages/discord-types/src/index.d.ts and packages/vencord-types/index.d.ts. External services are primarily Discord itself, optional sync endpoints configured by the user, and update retrieval through the desktop updater’s HTTP/Git implementations.
Components 24
Build & Packaging
- Build orchestrator · Assembles target-specific injection bundles.
scripts/build/build.mjs - Browser build
scripts/build/buildWeb.mjs - React injector
scripts/build/inject/react.mjs
Injected Renderer
- Vencord runtime · Initializes the renderer-side client modification lifecycle.
src/Vencord.ts - Webpack discovery · Locates Discord modules and common UI/store APIs.
src/webpack/webpack.ts - Webpack patching · Mutates loaded Discord code and components.
src/webpack/patchWebpack.ts - Plugin manager · Enables, disables, and manages built-in plugins.
src/api/PluginManager.ts - Built-in plugins
- Plugin APIs · Commands, context menus, and message-event contributions.
src/api/Commands/index.ts - Settings store · Shared settings data contract and persistence.
src/shared/SettingsStore.ts - Settings sync · Optional cloud and offline settings synchronization.
src/api/SettingsSync/cloudSync.ts - Plugin settings UI
src/components/settings/tabs/plugins/index.tsx
Electron Native
- Electron main process · Starts Electron-side integration and services.
src/main/index.ts - IPC services · Main-process IPC operations and plugin IPC.
src/main/ipcMain.ts - Preload bridge · Constrained bridge between renderer and main process.
src/preload.ts - Renderer native API
src/utils/native.ts
Browser Extension
- Extension manifest
browser/manifest.json - Extension background · Owns browser extension messaging and privileged work.
browser/background.js - Content bridge
browser/content.js - Browser Vencord runtime
browser/Vencord.ts - Browser native stub
browser/VencordNativeStub.ts
Shared Contracts
- Type contracts · Discord internal and Vencord consumer declarations.
packages/discord-types/src/index.d.ts
Other components
- Discord client runtime · Unstable Webpack bundle, UI APIs, and stores.
- User sync endpoints
Connections 26
- Build orchestrator → React injector: runs
- Build orchestrator → Vencord runtime: bundles
- Browser build → Extension manifest: packages
- Extension manifest → Extension background: declares
- Extension manifest → Content bridge: declares
- Content bridge → Browser Vencord runtime: injects
- Browser Vencord runtime → Browser native stub: uses
- Extension background → Content bridge: messages
- Vencord runtime → Webpack discovery: discovers modules
- Webpack discovery → Webpack patching: supplies modules
- Webpack patching → Discord client runtime: patches
- Vencord runtime → Plugin manager: starts
- Plugin manager → Built-in plugins: manages
- Built-in plugins → Plugin APIs: contribute through
- Built-in plugins → Webpack patching: apply patches
- Vencord runtime → Settings store: reads settings
- Plugin manager → Settings store: persists state
- Plugin settings UI → Plugin manager: controls
- Plugin settings UI → Settings store: edits
- Settings sync → Settings store: synchronizes
- Settings sync → User sync endpoints: connects
- Electron main process → IPC services: hosts
- IPC services → Preload bridge: exposes
- Preload bridge → Renderer native API: bridges
- Vencord runtime → Renderer native API: uses
- Type contracts → Vencord runtime: types