Skip to main content

Webpack

Webpack is a utility class for getting internal webpack modules. Instance is accessible through the BdApi. This is extremely useful for interacting with the internals of Discord.

Properties

Filters

Series of Filters to be used for finding webpack modules.

Type: Filters


modules

A Proxy that returns the module source by ID.

Type: modules


Methods

getAllByKeys

Finds all modules with a set of properties.

ParameterTypeDescription
props...stringProperties to use to filter modules

Returns: Array.<Any>


getAllByPrototypeKeys

Finds all modules with a set of properties of its prototype.

ParameterTypeDescription
prototypes...stringProperties to use to filter modules

Returns: Array.<Any>


getAllByRegex

Finds all modules using its code.

ParameterTypeOptionalDefaultDescription
regexRegExnoneA regular expression to use to filter modules
optionsobjectnoneOptions to configure the search
options.defaultExportBooleantrueWhether to return default export when matching the default export
options.searchExportsBooleanfalseWhether to execute the filter on webpack exports

Returns: Array.<Any>


getAllByStrings

Finds all modules with a set of strings.

ParameterTypeDescription
strings...StringStrings to use to filter modules

Returns: Array.<Any>


getBulk

Finds multiple modules using multiple filters.

ParameterTypeOptionalDefaultDescription
queries...objectnoneObject representing the query to perform
queries.filterfunctionnoneA function to use to filter modules
queries.firstbooleantrueWhether to return only the first matching module
queries.defaultExportbooleantrueWhether to return default export when matching the default export
queries.searchExportsbooleanfalseWhether to execute the filter on webpack exports

Returns: any


getByKeys

Finds a single module using its own properties.

ParameterTypeDescription
props...stringProperties to use to filter modules

Returns: Any


getByPrototypeKeys

Finds a single module using properties on its prototype.

ParameterTypeDescription
prototypes...stringProperties to use to filter modules

Returns: Any


getByRegex

Finds a module using its code.

ParameterTypeOptionalDefaultDescription
regexRegExnoneA regular expression to use to filter modules
optionsobjectnoneOptions to configure the search
options.defaultExportBooleantrueWhether to return default export when matching the default export
options.searchExportsBooleanfalseWhether to execute the filter on webpack exports

Returns: Any


getByStrings

Finds a single module using a set of strings.

ParameterTypeDescription
props...StringStrings to use to filter modules

Returns: Any


getModule

Finds a module using a filter function.

ParameterTypeOptionalDefaultDescription
filterfunctionnoneA function to use to filter modules. It is given exports, module, and moduleID. Return true to signify match.
optionsobjectnoneOptions to configure the search
options.firstbooleantrueWhether to return only the first matching module
options.defaultExportbooleantrueWhether to return default export when matching the default export
options.searchExportsbooleanfalseWhether to execute the filter on webpack exports

Returns: any


getModules

Finds all modules matching a filter function.

ParameterTypeOptionalDefaultDescription
filterfunctionnoneA function to use to filter modules
optionsobjectnoneOptions to configure the search
options.defaultExportBooleantrueWhether to return default export when matching the default export
options.searchExportsBooleanfalseWhether to execute the filter on webpack exports

Returns: Array.<any>


getStore

Finds an internal Store module using the name.

ParameterTypeDescription
nameStringName of the store to find (usually includes "Store")

Returns: Any


getWithKey

Searches for a module by value, returns module & matched key. Useful in combination with the Patcher.

ParameterTypeOptionalDefaultDescription
filterfunctionnoneA function to use to filter the module. It is given exports, module, and moduleID.
optionsobjectnoneSet of options to customize the search
options.targetanynoneOptional module target to look inside.
options.defaultExportBooleantrueWhether to return default export when matching the default export
options.searchExportsBooleanfalseWhether to execute the filter on webpack export getters.

Returns: Array.<any, string>


waitForModule

Finds a module that is lazily loaded.

ParameterTypeOptionalDefaultDescription
filterfunctionnoneA function to use to filter modules. It is given exports. Return true to signify match.
optionsobjectnoneOptions for configuring the listener
options.signalAbortSignalnoneAbortSignal of an AbortController to cancel the promise
options.defaultExportbooleantrueWhether to return default export when matching the default export
options.searchExportsbooleanfalseWhether to execute the filter on webpack exports

Returns: Promise.<any>