Documentation Index
Fetch the complete documentation index at: https://mintlify.com/betterdiscord/betterdiscord/llms.txt
Use this file to discover all available pages before exploring further.
Patcher is a utility class for modifying existing functions. This is extremely useful for modifying the internals of Discord by adjusting return values, React renders, or arguments of internal functions.
Methods
before
Patches onto another function, allowing your code to run beforehand. You can modify the incoming arguments before the original method runs.Name of the caller of the patch function. Only required when using the global API.
Object with the function to be patched. Can also be an object’s prototype.
Name of the function to be patched.
Function to run before the original method. The function is given the
this context and the arguments of the original function.Parameters:thisObject- Thethiscontext of the original functionargs- Array of arguments passed to the original function (modifiable)
function - Function that cancels the original patch when called
instead
Patches onto another function, allowing your code to run instead of the original. You can replace the original completely while still being able to call it manually if needed.Name of the caller of the patch function. Only required when using the global API.
Object with the function to be patched. Can also be an object’s prototype.
Name of the function to be patched.
Function to run instead of the original method. The function is given the
this context, arguments of the original function, and the original function itself.Parameters:thisObject- Thethiscontext of the original functionargs- Array of arguments passed to the original functionoriginal- The original function that was patched
function - Function that cancels the original patch when called
after
Patches onto another function, allowing your code to run afterwards. You can modify the return value after the original method runs.Name of the caller of the patch function. Only required when using the global API.
Object with the function to be patched. Can also be an object’s prototype.
Name of the function to be patched.
Function to run after the original method. The function is given the
this context, the arguments of the original function, and the return value of the original function.Parameters:thisObject- Thethiscontext of the original functionargs- Array of arguments passed to the original functionreturnValue- The return value from the original function (modifiable)
function - Function that cancels the original patch when called
getPatchesByCaller
Returns all patches by a particular caller. The patches all have anunpatch() method.
ID of the original patches. When using scoped API, this parameter is automatically filled.
Array<function> - Array of all the patch objects
unpatchAll
Automatically cancels all patches created with a specific ID.ID of the original patches. When using scoped API, this parameter is automatically filled.