Class: Patcher<Bounded>
Defined in: src/betterdiscord/api/patcher.ts:34
Patcher is a utility class for modifying existing functions. Instance is accessible through the BdApi. This is extremely useful for modifying the internals of Discord by adjusting return value or React renders, or arguments of internal functions.
Type Parameters
| Type Parameter |
|---|
Bounded extends boolean |
Methods
after()
after<M, K>(...args: [...(Bounded extends false ? [caller: string] : [])[], M, K, M[K] extends (...a: any[]) => any ? AfterCallback<any[any]> : never]): () => void | null;Defined in: src/betterdiscord/api/patcher.ts:117
This method patches onto another function, allowing your code to run afterwards. Using this, you are able to modify the return value after the original method is run.
Type Parameters
| Type Parameter |
|---|
M extends object |
K extends string |
Parameters
| Parameter | Type |
|---|---|
...args | [...(Bounded extends false ? [caller: string] : [])[], M, K, M[K] extends (...a: any[]) => any ? AfterCallback<any[any]> : never] |
Returns
() => void | null
Function that cancels the original patch
before()
before<M, K>(...args: [...(Bounded extends false ? [caller: string] : [])[], M, K, M[K] extends (...a: any[]) => any ? BeforeCallback<any[any]> : never]): () => void | null;Defined in: src/betterdiscord/api/patcher.ts:51
This method patches onto another function, allowing your code to run beforehand. Using this, you are also able to modify the incoming arguments before the original method is run.
Type Parameters
| Type Parameter |
|---|
M extends object |
K extends string |
Parameters
| Parameter | Type |
|---|---|
...args | [...(Bounded extends false ? [caller: string] : [])[], M, K, M[K] extends (...a: any[]) => any ? BeforeCallback<any[any]> : never] |
Returns
() => void | null
Function that cancels the original patch
getPatchesByCaller()
getPatchesByCaller(caller: string): void | GenericChildPatch[];Defined in: src/betterdiscord/api/patcher.ts:146
Returns all patches by a particular caller. The patches all have an unpatch() method.
Parameters
| Parameter | Type | Description |
|---|---|---|
caller | string | ID of the original patches |
Returns
void | GenericChildPatch[]
Array of all the patch objects
instead()
instead<M, K>(...args: [...(Bounded extends false ? [caller: string] : [])[], M, K, M[K] extends (...a: any[]) => any ? InsteadCallback<any[any]> : never]): () => void | null;Defined in: src/betterdiscord/api/patcher.ts:84
This method patches onto another function, allowing your code to run instead. Using this, you are able to replace the original completely. You can still call the original manually if needed.
Type Parameters
| Type Parameter |
|---|
M extends object |
K extends string |
Parameters
| Parameter | Type |
|---|---|
...args | [...(Bounded extends false ? [caller: string] : [])[], M, K, M[K] extends (...a: any[]) => any ? InsteadCallback<any[any]> : never] |
Returns
() => void | null
Function that cancels the original patch
unpatchAll()
unpatchAll(caller: string): void;Defined in: src/betterdiscord/api/patcher.ts:157
Automatically cancels all patches created with a specific ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
caller | string | ID of the original patches |
Returns
void