Fix an issue with public servers and documentation

This commit is contained in:
Zack Rauen 2022-10-10 14:33:36 -04:00
parent 9c0a8747f3
commit c3d4313b8e
10 changed files with 229 additions and 126 deletions

View File

@ -35,7 +35,8 @@ const ContextMenuActions = (() => {
for (const key of Object.keys(ActionsModule)) {
if (ActionsModule[key].toString().includes("CONTEXT_MENU_CLOSE")) {
out.closeContextMenu = ActionsModule[key];
} else if (ActionsModule[key].toString().includes("renderLazy")) {
}
else if (ActionsModule[key].toString().includes("renderLazy")) {
out.openContextMenu = ActionsModule[key];
}
}
@ -66,7 +67,8 @@ class MenuPatcher {
if (res?.props.navId) {
MenuPatcher.runPatches(res.props.navId, res, props);
} else if (typeof res?.type === "function") {
}
else if (typeof res?.type === "function") {
MenuPatcher.patchRecursive(res, "type");
}
@ -87,8 +89,9 @@ class MenuPatcher {
if (!res) return res;
if (res.props?.navId) {
MenuPatcher.runPatches(res.props.navId, res, arguments[0])
} else {
MenuPatcher.runPatches(res.props.navId, res, arguments[0]);
}
else {
const layer = res.props.children ? res.props.children : res;
if (typeof layer?.type == "function") {
@ -115,7 +118,8 @@ class MenuPatcher {
for (const patch of this.patches[id]) {
try {
patch(res, props);
} catch (error) {
}
catch (error) {
Logger.error("ContextMenu~runPatches", `Could not run ${id} patch for`, patch, error);
}
}
@ -131,13 +135,33 @@ class MenuPatcher {
}
}
/**
* `ContextMenu` is a module to help patch and create context menus. Instance is accessible through the {@link BdApi}.
* @type ContextMenu
* @summary {@link ContextMenu} is a utility class for interacting with React internals.
* @name ContextMenu
*/
class ContextMenu {
/**
* Allows you to patch a given context menu. Acts as a wrapper around the `Patcher`.
*
* @param {string} navId Discord's internal navId used to identify context menus
* @param {function} callback callback function that accepts the react render tree
* @returns {function} a function that automatically unpatches
*/
patch(navId, callback) {
MenuPatcher.patch(navId, callback);
return () => MenuPatcher.unpatch(navId, callback);
}
/**
* Allows you to remove the patch added to a given context menu.
*
* @param {string} navId the original navId from patching
* @param {function} callback the original callback from patching
*/
unpatch(navId, callback) {
MenuPatcher.unpatch(navId, callback);
}
@ -258,6 +282,7 @@ class ContextMenu {
}
/**
* Function that allows you to open an entire context menu. Recommended to build the menu with this module.
*
* @param {MouseEvent} event - The context menu event. This can be emulated, requires target, and all X, Y locations.
* @param {function} menuComponent - Component to render. This can be any react component or output of {@link ContextMenu.buildMenu}

View File

@ -21,7 +21,6 @@ class Data {
* @param {string} pluginName Name of the plugin saving data
* @param {string} key Which piece of data to store
* @param {any} data The data to be saved
* @returns
*/
save(pluginName, key, data) {
if (this.#callerName) {

View File

@ -8,10 +8,16 @@ import DOMManager from "../dommanager";
*/
class DOM {
/** Document/window width */
/**
* Current width of the user's screen.
* @type {number}
*/
get screenWidth() {return Math.max(document.documentElement.clientWidth, window.innerWidth || 0);}
/** Document/window height */
/**
* Current height of the user's screen.
* @type {number}
*/
get screenHeight() {return Math.max(document.documentElement.clientHeight, window.innerHeight || 0);}
#callerName = "";
@ -67,17 +73,19 @@ class DOM {
}
/**
* Utility to help smoothly animate using JavaScript
*
* @param {function} update render function indicating the style should be updates
* @param {number} duration duration in ms to animate for
* @param {object} [options] option to customize the animation
* @returns
*/
animate(update, duration, options = {}) {
return DOMManager.animate({update, duration, timing: options.timing});
}
/**
* Utility function to make creating DOM elements easier. Acts similarly
* to `React.createElement`
*
* @param {string} tag HTML tag name to create
* @param {object} [options] options object to customize the element

View File

@ -15,28 +15,32 @@ import ipc from "../ipc";
/**
* The React module being used inside Discord.
* @type React
* @memberof BdApi
*/
export const React = DiscordModules.React;
const React = DiscordModules.React;
/**
* The ReactDOM module being used inside Discord.
* @type ReactDOM
* @memberof BdApi
*/
export const ReactDOM = DiscordModules.ReactDOM;
const ReactDOM = DiscordModules.ReactDOM;
/**
* A reference object to get BD's settings.
* @type object
* @deprecated
* @memberof BdApi
*/
export const settings = Settings.collections;
const settings = Settings.collections;
/**
* A reference object for BD's emotes.
* @type object
* @deprecated
* @memberof BdApi
*/
export const emotes = new Proxy(Emotes.Emotes, {
const emotes = new Proxy(Emotes.Emotes, {
get(obj, category) {
if (category === "blocklist") return Emotes.blocklist;
const group = Emotes.Emotes[category];
@ -52,28 +56,33 @@ export const emotes = new Proxy(Emotes.Emotes, {
/**
* A reference string for BD's version.
* @type string
* @memberof BdApi
*/
export const version = Config.version;
const version = Config.version;
/**
* Adds a `<style>` to the document with the given ID.
*
* @deprecated
* @param {string} id ID to use for style element
* @param {string} css CSS to apply to the document
* @memberof BdApi
*/
export const injectCSS = function (id, css) {
function injectCSS(id, css) {
DOMManager.injectStyle(id, css);
};
}
/**
* Removes a `<style>` from the document corresponding to the given ID.
*
* @deprecated
* @param {string} id ID uses for the style element
* @memberof BdApi
*/
export const clearCSS = function (id) {
function clearCSS(id) {
DOMManager.removeStyle(id);
};
}
/**
* Automatically creates and links a remote JS script.
@ -82,34 +91,39 @@ export const clearCSS = function (id) {
* @param {string} id ID of the script element
* @param {string} url URL of the remote script
* @returns {Promise} Resolves upon onload event
* @memberof BdApi
*/
export const linkJS = function (id, url) {
function linkJS(id, url) {
return DOMManager.injectScript(id, url);
};
}
/**
* Removes a remotely linked JS script.
*
* @deprecated
* @param {string} id ID of the script element
* @memberof BdApi
*/
export const unlinkJS = function (id) {
function unlinkJS(id) {
DOMManager.removeScript(id);
};
}
/**
* Shows a generic but very customizable modal.
*
* @deprecated
* @param {string} title title of the modal
* @param {(string|ReactElement|Array<string|ReactElement>)} content a string of text to display in the modal
* @memberof BdApi
*/
export const alert = function (title, content) {
function alert(title, content) {
Modals.alert(title, content);
};
}
/**
* Shows a generic but very customizable confirmation modal with optional confirm and cancel callbacks.
*
* @deprecated
* @param {string} title title of the modal
* @param {(string|ReactElement|Array<string|ReactElement>)} children a single or mixed array of react elements and strings. Everything is wrapped in Discord's `TextElement` component so strings will show and render properly.
* @param {object} [options] options to modify the modal
@ -118,147 +132,158 @@ export const alert = function (title, content) {
* @param {string} [options.cancelText=Cancel] text for the cancel button
* @param {callable} [options.onConfirm=NOOP] callback to occur when clicking the submit button
* @param {callable} [options.onCancel=NOOP] callback to occur when clicking the cancel button
* @memberof BdApi
*/
export const showConfirmationModal = function (title, content, options = {}) {
function showConfirmationModal(title, content, options = {}) {
return Modals.showConfirmationModal(title, content, options);
};
}
/**
* This shows a toast similar to android towards the bottom of the screen.
* Shows a toast similar to android towards the bottom of the screen.
*
* @deprecated
* @param {string} content The string to show in the toast.
* @param {object} options Options object. Optional parameter.
* @param {string} [options.type=""] Changes the type of the toast stylistically and semantically. Choices: "", "info", "success", "danger"/"error", "warning"/"warn". Default: ""
* @param {boolean} [options.icon=true] Determines whether the icon should show corresponding to the type. A toast without type will always have no icon. Default: true
* @param {number} [options.timeout=3000] Adjusts the time (in ms) the toast should be shown for before disappearing automatically. Default: 3000
* @param {boolean} [options.icon=true] Determines whether the icon should show corresponding to the type. A toast without type will always have no icon. Default: `true`
* @param {number} [options.timeout=3000] Adjusts the time (in ms) the toast should be shown for before disappearing automatically. Default: `3000`
* @param {boolean} [options.forceShow=false] Whether to force showing the toast and ignore the bd setting
* @memberof BdApi
*/
export const showToast = function(content, options = {}) {
function showToast(content, options = {}) {
Toasts.show(content, options);
};
}
/**
* Show a notice above discord's chat layer.
* Shows a notice above Discord's chat layer.
*
* @deprecated
* @param {string|Node} content Content of the notice
* @param {object} options Options for the notice.
* @param {string} [options.type="info" | "error" | "warning" | "success"] Type for the notice. Will affect the color.
* @param {Array<{label: string, onClick: function}>} [options.buttons] Buttons that should be added next to the notice text.
* @param {number} [options.timeout=10000] Timeout until the notice is closed. Won't fire if it's set to 0;
* @returns {function}
* @returns {function} A callback for closing the notice. Passing `true` as first parameter closes immediately without transitioning out.
* @memberof BdApi
*/
export const showNotice = function (content, options = {}) {
function showNotice(content, options = {}) {
return Notices.show(content, options);
};
}
/**
* Finds a webpack module using a filter
*
* @deprecated
* @param {function} filter A filter given the exports, module, and moduleId. Returns true if the module matches.
* @param {function} filter A filter given the exports, module, and moduleId. Returns `true` if the module matches.
* @returns {any} Either the matching module or `undefined`
* @memberof BdApi
*/
export const findModule = function(filter) {
function findModule(filter) {
return WebpackModules.getModule(filter);
};
}
/**
* Finds multple webpack modules using a filter
* Finds multiple webpack modules using a filter
*
* @deprecated
* @param {function} filter A filter given the exports, module, and moduleId. Returns true if the module matches.
* @param {function} filter A filter given the exports, module, and moduleId. Returns `true` if the module matches.
* @returns {Array} Either an array of matching modules or an empty array
* @memberof BdApi
*/
export const findAllModules = function(filter) {
function findAllModules(filter) {
return WebpackModules.getModule(filter, {first: false});
};
}
/**
* Finds a webpack module by own properties
* Finds a webpack module by own properties.
*
* @deprecated
* @param {...string} props Any desired properties
* @returns {any} Either the matching module or `undefined`
* @memberof BdApi
*/
export const findModuleByProps = function(...props) {
function findModuleByProps(...props) {
return WebpackModules.getByProps(...props);
};
}
/**
* Finds a webpack module by own prototypes
* Finds a webpack module by own prototypes.
*
* @deprecated
* @param {...string} protos Any desired prototype properties
* @returns {any} Either the matching module or `undefined`
* @memberof BdApi
*/
export const findModuleByPrototypes = function(...protos) {
function findModuleByPrototypes(...protos) {
return WebpackModules.getByPrototypes(...protos);
};
}
/**
* Finds a webpack module by displayName property
* Finds a webpack module by `displayName` property
*
* @deprecated
* @param {string} name Desired displayName property
* @param {string} name Desired `displayName` property
* @returns {any} Either the matching module or `undefined`
* @memberof BdApi
*/
export const findModuleByDisplayName = function(name) {
function findModuleByDisplayName(name) {
return WebpackModules.getByDisplayName(name);
};
}
/**
* Get the internal react data of a specified node
* Get the internal react data of a specified node.
*
* @deprecated
* @param {HTMLElement} node Node to get the react data from
* @returns {object|undefined} Either the found data or `undefined`
* @memberof BdApi
*/
export const getInternalInstance = function(node) {
function getInternalInstance(node) {
if (node.__reactInternalInstance$) return node.__reactInternalInstance$;
return node[Object.keys(node).find(k => k.startsWith("__reactInternalInstance") || k.startsWith("__reactFiber"))] || null;
};
}
/**
* Loads previously stored data.
*
* @deprecated
* @param {string} pluginName Name of the plugin loading data
* @param {string} key Which piece of data to load
* @returns {any} The stored data
* @memberof BdApi
*/
export const loadData = function(pluginName, key) {
function loadData(pluginName, key) {
return DataStore.getPluginData(pluginName, key);
};
/** @alias loadData */
export const getData = loadData;
}
/**
* Saves JSON-serializable data.
*
* @deprecated
* @param {string} pluginName Name of the plugin saving data
* @param {string} key Which piece of data to store
* @param {any} data The data to be saved
* @returns
* @memberof BdApi
*/
export const saveData = function(pluginName, key, data) {
function saveData(pluginName, key, data) {
return DataStore.setPluginData(pluginName, key, data);
};
/** @alias saveData */
export const setData = saveData;
}
/**
* Deletes a piece of stored data, this is different than saving as null or undefined.
*
* @deprecated
* @param {string} pluginName Name of the plugin deleting data
* @param {string} key Which piece of data to delete
* @memberof BdApi
*/
export const deleteData = function(pluginName, key) {
function deleteData(pluginName, key) {
DataStore.deletePluginData(pluginName, key);
};
}
/**
* This function monkey-patches a method on an object. The patching callback may be run before, after or instead of target method.
* Monkey-patches a method on an object. The patching callback may be run before, after or instead of target method.
*
* - Be careful when monkey-patching. Think not only about original functionality of target method and your changes, but also about developers of other plugins, who may also patch this method before or after you. Try to change target method behaviour as little as possible, and avoid changing method signatures.
* - Display name of patched method is changed, so you can see if a function has been patched (and how many times) while debugging or in the stack trace. Also, patched methods have property `__monkeyPatched` set to `true`, in case you want to check something programmatically.
@ -273,8 +298,9 @@ export const deleteData = function(pluginName, key) {
* @param {boolean} [options.once=false] Set to `true` if you want to automatically unpatch method after first call.
* @param {boolean} [options.silent=false] Set to `true` if you want to suppress log messages about patching and unpatching.
* @returns {function} A function that cancels the monkey patch
* @memberof BdApi
*/
export const monkeyPatch = function(what, methodName, options) {
function monkeyPatch(what, methodName, options) {
const {before, after, instead, once = false, callerId = "BdApi"} = options;
const patchType = before ? "before" : after ? "after" : instead ? "instead" : "";
if (!patchType) return Logger.err("BdApi", "Must provide one of: after, before, instead");
@ -297,17 +323,19 @@ export const monkeyPatch = function(what, methodName, options) {
}
});
return data.cancelPatch;
};
}
/**
* Adds a listener for when the node is removed from the document body.
*
* @deprecated
* @param {HTMLElement} node Node to be observed
* @param {function} callback Function to run when fired
* @memberof BdApi
*/
export const onRemoved = function(node, callback) {
function onRemoved(node, callback) {
return DOMManager.onRemoved(node, callback);
};
}
/**
* Wraps a given function in a `try..catch` block.
@ -316,13 +344,14 @@ export const onRemoved = function(node, callback) {
* @param {function} method Function to wrap
* @param {string} message Additional messasge to print when an error occurs
* @returns {function} The new wrapped function
* @memberof BdApi
*/
export const suppressErrors = function(method, message) {
function suppressErrors(method, message) {
return (...params) => {
try {return method(...params);}
catch (e) {Logger.stacktrace("SuppressedError", "Error occurred in " + message, e);}
};
};
}
/**
* Tests a given object to determine if it is valid JSON.
@ -330,40 +359,43 @@ export const suppressErrors = function(method, message) {
* @deprecated
* @param {object} data Data to be tested
* @returns {boolean} Result of the test
* @memberof BdApi
*/
export const testJSON = function(data) {
function testJSON(data) {
try {
return JSON.parse(data);
}
catch (err) {
return false;
}
};
}
/**
* Gets a specific setting's status from BD
* Gets a specific setting's status from BD.
*
* @deprecated
* @param {string} [collection="settings"] Collection ID
* @param {string} category Category ID in the collection
* @param {string} id Setting ID in the category
* @returns {boolean} If the setting is enabled
* @memberof BdApi
*/
export const isSettingEnabled = function(collection, category, id) {
function isSettingEnabled(collection, category, id) {
return Settings.get(collection, category, id);
};
}
/**
* Enable a BetterDiscord setting by ids.
* Enables a BetterDiscord setting by ids.
*
* @deprecated
* @param {string} [collection="settings"] Collection ID
* @param {string} category Category ID in the collection
* @param {string} id Setting ID in the category
* @memberof BdApi
*/
export const enableSetting = function(collection, category, id) {
function enableSetting(collection, category, id) {
return Settings.set(collection, category, id, true);
};
}
/**
* Disables a BetterDiscord setting by ids.
@ -372,22 +404,24 @@ export const enableSetting = function(collection, category, id) {
* @param {string} [collection="settings"] Collection ID
* @param {string} category Category ID in the collection
* @param {string} id Setting ID in the category
* @memberof BdApi
*/
export const disableSetting = function(collection, category, id) {
function disableSetting(collection, category, id) {
return Settings.set(collection, category, id, false);
};
}
/**
* Toggle a BetterDiscord setting by ids.
* Toggles a BetterDiscord setting by ids.
*
* @deprecated
* @param {string} [collection="settings"] Collection ID
* @param {string} category Category ID in the collection
* @param {string} id Setting ID in the category
* @memberof BdApi
*/
export const toggleSetting = function(collection, category, id) {
function toggleSetting(collection, category, id) {
return Settings.set(collection, category, id, !Settings.get(collection, category, id));
};
}
/**
* Gets some data in BetterDiscord's misc data.
@ -395,26 +429,29 @@ export const toggleSetting = function(collection, category, id) {
* @deprecated
* @param {string} key Key of the data to load.
* @returns {any} The stored data
* @memberof BdApi
*/
export const getBDData = function(key) {
function getBDData(key) {
return DataStore.getBDData(key);
};
}
/**
* Gets some data in BetterDiscord's misc data.
* Sets some data in BetterDiscord's misc data.
*
* @deprecated
* @param {string} key Key of the data to load.
* @param {string} key Key of the data to store.
* @returns {any} The stored data
* @memberof BdApi
*/
export const setBDData = function(key, data) {
function setBDData(key, data) {
return DataStore.setBDData(key, data);
};
}
/**
* Gives access to the [Electron Dialog](https://www.electronjs.org/docs/latest/api/dialog/) api.
* Gives access to the [Electron Dialog](https://www.electronjs.org/docs/latest/api/dialog/) api.
* Returns a `Promise` that resolves to an `object` that has a `boolean` cancelled and a `filePath` string for saving and a `filePaths` string array for opening.
*
* @deprecated
* @param {object} options Options object to configure the dialog.
* @param {"open"|"save"} [options.mode="open"] Determines whether the dialog should open or save files.
* @param {string} [options.defaultPath=~] Path the dialog should show on launch.
@ -429,10 +466,49 @@ export const setBDData = function(key, data) {
* @param {boolean} [options.multiSelections=false] Whether the user should be able to select multiple targets.
* @param {boolean} [options.modal=false] Whether the dialog should act as a modal to the main window.
* @returns {Promise<object>} Result of the dialog
* @memberof BdApi
*/
export const openDialog = async function (options) {
async function openDialog(options) {
const data = await ipc.openDialog(options);
if (data.error) throw new Error(data.error);
return data;
}
export {
React,
ReactDOM,
settings,
emotes,
version,
injectCSS,
clearCSS,
linkJS,
unlinkJS,
alert,
showConfirmationModal,
showToast,
showNotice,
findModule,
findAllModules,
findModuleByProps,
findModuleByPrototypes,
findModuleByDisplayName,
getInternalInstance,
loadData,
loadData as getData,
saveData,
saveData as setData,
deleteData,
monkeyPatch,
onRemoved,
suppressErrors,
testJSON,
isSettingEnabled,
enableSetting,
disableSetting,
toggleSetting,
getBDData,
setBDData,
openDialog
};

View File

@ -17,7 +17,7 @@ class Patcher {
}
/**
* This method patches onto another function, allowing your code to run beforehand.
* 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.
* @param {string} caller Name of the caller of the patch function.
* @param {object} moduleToPatch Object with the function to be patched. Can also be an object's prototype.
@ -36,7 +36,7 @@ class Patcher {
}
/**
* This method patches onto another function, allowing your code to run instead.
* This method patches onto another function, allowing your code to run instead.
* Using this, you are also able to modify the return value, using the return of your code instead.
* @param {string} caller Name of the caller of the patch function.
* @param {object} moduleToPatch Object with the function to be patched. Can also be an object's prototype.
@ -55,7 +55,7 @@ class Patcher {
}
/**
* This method patches onto another function, allowing your code to run instead.
* This method patches onto another function, allowing your code to run instead.
* Using this, you are also able to modify the return value, using the return of your code instead.
* @param {string} caller Name of the caller of the patch function.
* @param {object} moduleToPatch Object with the function to be patched. Can also be an object's prototype.

View File

@ -6,7 +6,6 @@ import DiscordModules from "../discordmodules";
* This is extremely useful for interacting with the internals of the UI.
* @type ReactUtils
* @summary {@link ReactUtils} is a utility class for interacting with React internals.
* @memberof BdApi
* @name ReactUtils
*/
const ReactUtils = {
@ -14,7 +13,7 @@ const ReactUtils = {
get rootInstance() {return document.getElementById("app-mount")?._reactRootContainer?._internalRoot?.current;},
/**
* Get the internal react data of a specified node
* Gets the internal react data of a specified node
*
* @param {HTMLElement} node Node to get the react data from
* @returns {object|undefined} Either the found data or `undefined`
@ -25,9 +24,9 @@ const ReactUtils = {
},
/**
* Grabs a value from the react internal instance. Allows you to grab
* long depth values safely without accessing no longer valid properties.
* @param {(HTMLElement|jQuery)} node - node to obtain react instance of
* Attempts to find the "owner" node to the current node. This is generally
* a node with a stateNode--a class component.
* @param {HTMLElement} node - node to obtain react instance of
* @param {object} options - options for the search
* @param {array} [options.include] - list of items to include from the search
* @param {array} [options.exclude=["Popout", "Tooltip", "Scroller", "BackgroundFlash"]] - list of items to exclude from the search

View File

@ -9,7 +9,6 @@ import ipc from "../ipc";
* This is extremely useful for interacting with the internals of Discord.
* @type UI
* @summary {@link UI} is a utility class for getting internal webpack modules.
* @memberof BdApi
* @name UI
*/
const UI = {
@ -33,7 +32,7 @@ const UI = {
* @param {"top"|"right"|"bottom"|"left"} [options.side="top"] - can be any of top, right, bottom, left
* @param {boolean} [options.preventFlip=false] - prevents moving the tooltip to the opposite side if it is too big or goes offscreen
* @param {boolean} [options.disabled=false] - whether the tooltip should be disabled from showing on hover
* @returns new Tooltip
* @returns {Tooltip} the tooltip that was generated
*/
createTooltip(node, content, options = {}) {
return Tooltip.create(node, content, options);
@ -61,8 +60,8 @@ const UI = {
* @param {string} content The string to show in the toast.
* @param {object} options Options object. Optional parameter.
* @param {string} [options.type=""] Changes the type of the toast stylistically and semantically. Choices: "", "info", "success", "danger"/"error", "warning"/"warn". Default: ""
* @param {boolean} [options.icon=true] Determines whether the icon should show corresponding to the type. A toast without type will always have no icon. Default: true
* @param {number} [options.timeout=3000] Adjusts the time (in ms) the toast should be shown for before disappearing automatically. Default: 3000
* @param {boolean} [options.icon=true] Determines whether the icon should show corresponding to the type. A toast without type will always have no icon. Default: `true`
* @param {number} [options.timeout=3000] Adjusts the time (in ms) the toast should be shown for before disappearing automatically. Default: `3000`
* @param {boolean} [options.forceShow=false] Whether to force showing the toast and ignore the bd setting
*/
showToast(content, options = {}) {
@ -70,7 +69,7 @@ const UI = {
},
/**
* Show a notice above discord's chat layer.
* Shows a notice above Discord's chat layer.
*
* @param {string|Node} content Content of the notice
* @param {object} options Options for the notice.
@ -84,7 +83,7 @@ const UI = {
},
/**
* Gives access to the [Electron Dialog](https://www.electronjs.org/docs/latest/api/dialog/) api.
* Gives access to the [Electron Dialog](https://www.electronjs.org/docs/latest/api/dialog/) api.
* Returns a `Promise` that resolves to an `object` that has a `boolean` cancelled and a `filePath` string for saving and a `filePaths` string array for opening.
*
* @param {object} options Options object to configure the dialog.

View File

@ -1,11 +1,9 @@
import Utilities from "../utilities";
/**
* `Utils` is a utility class for interacting with React internals. Instance is accessible through the {@link BdApi}.
* This is extremely useful for interacting with the internals of the UI.
* `Utils` is a utility containing commonly reused functions. Instance is accessible through the {@link BdApi}.
* @type Utils
* @summary {@link Utils} is a utility class for interacting with React internals.
* @memberof BdApi
* @name Utils
*/
const Utils = {

View File

@ -6,7 +6,6 @@ import WebpackModules, {Filters} from "../webpackmodules";
* This is extremely useful for interacting with the internals of Discord.
* @type Webpack
* @summary {@link Webpack} is a utility class for getting internal webpack modules.
* @memberof BdApi
* @name Webpack
*/
const Webpack = {
@ -47,9 +46,9 @@ const Webpack = {
byStrings(...strings) {return Filters.byStrings(...strings);},
/**
* Generates a function that filters by a set of properties.
* Generates a function that filters by the `displayName` property.
* @param {string} name Name the module should have
* @returns {function} A filter that checks for a set of properties
* @returns {function} A filter that checks for a `displayName` match
*/
byDisplayName(name) {return Filters.byDisplayName(name);},
@ -64,11 +63,11 @@ const Webpack = {
/**
* Finds a module using a filter function.
* @memberof Webpack
* @param {function} filter A function to use to filter modules. It is given exports, module, and moduleID. Return true to signify match.
* @param {object} [options] Whether to return only the first matching module
* @param {function} filter A function to use to filter modules. It is given exports, module, and moduleID. Return `true` to signify match.
* @param {object} [options] Options to configure the search
* @param {Boolean} [options.first=true] Whether to return only the first matching module
* @param {Boolean} [options.defaultExport=true] Whether to return default export when matching the default export
* @param {Boolean} [options.searchExports=false] Whether to execute the filter on webpack export getters.
* @param {Boolean} [options.searchExports=false] Whether to execute the filter on webpack exports
* @return {any}
*/
getModule(filter, options = {}) {
@ -81,23 +80,23 @@ const Webpack = {
/**
* Finds multiple modules using multiple filters.
* @memberof Webpack
* @param {...object} queries Whether to return only the first matching module
* @param {...object} queries Object representing the query to perform
* @param {Function} queries.filter A function to use to filter modules
* @param {Boolean} [queries.first=true] Whether to return only the first matching module
* @param {Boolean} [queries.defaultExport=true] Whether to return default export when matching the default export
* @param {Boolean} [queries.searchExports=false] Whether to execute the filter on webpack export getters.
* @param {Boolean} [queries.searchExports=false] Whether to execute the filter on webpack exports
* @return {any}
*/
getBulk(...queries) {return WebpackModules.getBulk(...queries);},
/**
* Finds a module that lazily loaded.
* Finds a module that is lazily loaded.
* @memberof Webpack
* @param {function} filter A function to use to filter modules. It is given exports. Return true to signify match.
* @param {object} [options] Whether to return only the first matching module
* @param {function} filter A function to use to filter modules. It is given exports. Return `true` to signify match.
* @param {object} [options] Options for configuring the listener
* @param {AbortSignal} [options.signal] AbortSignal of an AbortController to cancel the promise
* @param {Boolean} [options.defaultExport=true] Whether to return default export when matching the default export
* @param {Boolean} [options.searchExports=false] Whether to execute the filter on webpack export getters.
* @param {Boolean} [options.searchExports=false] Whether to execute the filter on webpack exports
* @returns {Promise<any>}
*/
waitForModule(filter, options = {}) {

View File

@ -2,7 +2,7 @@ import Logger from "common/logger";
import {WebpackModules, IPC} from "modules";
const SortedGuildStore = WebpackModules.getByProps("getSortedGuilds");
const AvatarDefaults = WebpackModules.getByProps("getUserAvatarURL", "DEFAULT_AVATARS");
const AvatarDefaults = WebpackModules.getByProps("DEFAULT_AVATARS");
const InviteActions = WebpackModules.getByProps("acceptInvite");
// const BrowserWindow = require("electron").remote.BrowserWindow;