Skip to main content
Discord code is bundled through Webpack. Illegalcord exposes lazy finders and a patch system so plugins can use Discord internals without importing them directly.

Lazy finders

Use lazy finders at module scope:
Common stores and utilities are often already exported from @webpack/common:
Before adding a finder, check src/webpack/common. Many stores and utilities are already mapped there.

CSS classes

Use findCssClassesLazy for Discord’s mangled class names:
Do not hardcode generated class prefixes or suffixes in plugin CSS.

Declarative patches

Webpack source patches live on the plugin object:
Use $self only for methods that live on the plugin object.

Patch rules

  • Prefer string find anchors.
  • Use stable strings such as intl keys, action types, paths, or distinctive code.
  • Keep regex gaps bounded, usually .{0,150}?.
  • Capture only what you reuse.
  • Use group: true when multiple replacements must succeed together.
  • Use predicate, fromBuild, or toBuild for version or target gates.
  • Keep replacement strings small and move logic into plugin methods.
Do not write broad patches with unbounded .*? or .+?. They are fragile and can rewrite the wrong module after Discord updates.