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.
Parameter | Type | Description |
---|---|---|
props | ...string | Properties to use to filter modules |
Returns: Array.<Any>
getAllByPrototypeKeys
Finds all modules with a set of properties of its prototype.
Parameter | Type | Description |
---|---|---|
prototypes | ...string | Properties to use to filter modules |
Returns: Array.<Any>
getAllByRegex
Finds all modules using its code.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
regex | RegEx | ❌ | none | A regular expression to use to filter modules |
options | object | ✅ | none | Options to configure the search |
options.defaultExport | Boolean | ✅ | true | Whether to return default export when matching the default export |
options.searchExports | Boolean | ✅ | false | Whether to execute the filter on webpack exports |
Returns: Array.<Any>
getAllByStrings
Finds all modules with a set of strings.
Parameter | Type | Description |
---|---|---|
strings | ...String | Strings to use to filter modules |
Returns: Array.<Any>
getBulk
Finds multiple modules using multiple filters.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
queries | ...object | ❌ | none | Object representing the query to perform |
queries.filter | function | ❌ | none | A function to use to filter modules |
queries.first | boolean | ✅ | true | Whether to return only the first matching module |
queries.defaultExport | boolean | ✅ | true | Whether to return default export when matching the default export |
queries.searchExports | boolean | ✅ | false | Whether to execute the filter on webpack exports |
Returns: any
getByKeys
Finds a single module using its own properties.
Parameter | Type | Description |
---|---|---|
props | ...string | Properties to use to filter modules |
Returns: Any
getByPrototypeKeys
Finds a single module using properties on its prototype.
Parameter | Type | Description |
---|---|---|
prototypes | ...string | Properties to use to filter modules |
Returns: Any
getByRegex
Finds a module using its code.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
regex | RegEx | ❌ | none | A regular expression to use to filter modules |
options | object | ✅ | none | Options to configure the search |
options.defaultExport | Boolean | ✅ | true | Whether to return default export when matching the default export |
options.searchExports | Boolean | ✅ | false | Whether to execute the filter on webpack exports |
Returns: Any
getByStrings
Finds a single module using a set of strings.
Parameter | Type | Description |
---|---|---|
props | ...String | Strings to use to filter modules |
Returns: Any
getModule
Finds a module using a filter function.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
filter | function | ❌ | none | A function to use to filter modules. It is given exports, module, and moduleID. Return true to signify match. |
options | object | ✅ | none | Options to configure the search |
options.first | boolean | ✅ | true | Whether to return only the first matching module |
options.defaultExport | boolean | ✅ | true | Whether to return default export when matching the default export |
options.searchExports | boolean | ✅ | false | Whether to execute the filter on webpack exports |
Returns: any
getModules
Finds all modules matching a filter function.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
filter | function | ❌ | none | A function to use to filter modules |
options | object | ✅ | none | Options to configure the search |
options.defaultExport | Boolean | ✅ | true | Whether to return default export when matching the default export |
options.searchExports | Boolean | ✅ | false | Whether to execute the filter on webpack exports |
Returns: Array.<any>
getStore
Finds an internal Store module using the name.
Parameter | Type | Description |
---|---|---|
name | String | Name 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.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
filter | function | ❌ | none | A function to use to filter the module. It is given exports, module, and moduleID. |
options | object | ✅ | none | Set of options to customize the search |
options.target | any | ✅ | none | Optional module target to look inside. |
options.defaultExport | Boolean | ✅ | true | Whether to return default export when matching the default export |
options.searchExports | Boolean | ✅ | false | Whether to execute the filter on webpack export getters. |
Returns: Array.<any, string>
waitForModule
Finds a module that is lazily loaded.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
filter | function | ❌ | none | A function to use to filter modules. It is given exports. Return true to signify match. |
options | object | ✅ | none | Options for configuring the listener |
options.signal | AbortSignal | ✅ | none | AbortSignal of an AbortController to cancel the promise |
options.defaultExport | boolean | ✅ | true | Whether to return default export when matching the default export |
options.searchExports | boolean | ✅ | false | Whether to execute the filter on webpack exports |
Returns: Promise.<any>