Improve period & hyphen consistency

This commit is contained in:
Zerthox 2023-04-02 12:23:57 +02:00
parent 0087f4c8d7
commit 68ba0580aa
9 changed files with 204 additions and 202 deletions

View File

@ -15,45 +15,45 @@
/**
* Determines if a particular addon is enabled.
* @param {string} idOrFile Addon ID or filename.
* @param {string} idOrFile Addon ID or filename
* @returns {boolean}
*/
isEnabled(idOrFile) {return this.#manager.isEnabled(idOrFile);}
/**
* Enables the given addon.
* @param {string} idOrFile Addon ID or filename.
* @param {string} idOrFile Addon ID or filename
*/
enable(idOrAddon) {return this.#manager.enableAddon(idOrAddon);}
/**
* Disables the given addon.
* @param {string} idOrFile Addon ID or filename.
* @param {string} idOrFile Addon ID or filename
*/
disable(idOrAddon) {return this.#manager.disableAddon(idOrAddon);}
/**
* Toggles if a particular addon is enabled.
* @param {string} idOrFile Addon ID or filename.
* @param {string} idOrFile Addon ID or filename
*/
toggle(idOrAddon) {return this.#manager.toggleAddon(idOrAddon);}
/**
* Reloads if a particular addon is enabled.
* @param {string} idOrFile Addon ID or filename.
* @param {string} idOrFile Addon ID or filename
*/
reload(idOrFileOrAddon) {return this.#manager.reloadAddon(idOrFileOrAddon);}
/**
* Gets a particular addon.
* @param {string} idOrFile Addon ID or filename.
* @param {string} idOrFile Addon ID or filename
* @returns {object} Addon instance
*/
get(idOrFile) {return this.#manager.getAddon(idOrFile);}
/**
* Gets all addons of this type.
* @returns {Array<object>} Array of all addon instances.
* @returns {Array<object>} Array of all addon instances
*/
getAll() {return this.#manager.addonList.map(a => this.#manager.getAddon(a.id));}
}

View File

@ -178,9 +178,9 @@ 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.
* @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);
@ -191,8 +191,8 @@ class ContextMenu {
/**
* 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.
* @param {string} navId The original `navId` from patching
* @param {function} callback The original callback from patching
*/
unpatch(navId, callback) {
MenuPatcher.unpatch(navId, callback);
@ -203,9 +203,9 @@ class ContextMenu {
* match the actual component being built. View those to see what options exist
* for each, they often have less in common than you might think.
*
* @param {object} props - Props used to build the item.
* @param {string} [props.type="text"] - Type of the item, options: text, submenu, toggle, radio, custom, separator.
* @returns {object} The created component.
* @param {object} props Props used to build the item
* @param {string} [props.type="text"] Type of the item, options: text, submenu, toggle, radio, custom, separator
* @returns {object} The created component
*
* @example
* // Creates a single menu item that prints "MENU ITEM" on click
@ -263,8 +263,8 @@ class ContextMenu {
* There is no hard limit to the number of groups within groups or number
* of items in a menu.
*
* @param {Array<object>} setup - Array of item props used to build items. See {@link ContextMenu.buildItem}.
* @returns {Array<object>} Array of the created component.
* @param {Array<object>} setup Array of item props used to build items. See {@link ContextMenu.buildItem}.
* @returns {Array<object>} Array of the created component
*
* @example
* // Creates a single item group item with a toggle item
@ -319,8 +319,8 @@ class ContextMenu {
* Calls {@link ContextMenu.buildMenuChildren} under the covers.
* Used to call in combination with {@link ContextMenu.open}.
*
* @param {Array<object>} setup - Array of item props used to build items. See {@link ContextMenu.buildMenuChildren}.
* @returns {function} The unique context menu component.
* @param {Array<object>} setup Array of item props used to build items. See {@link ContextMenu.buildMenuChildren}.
* @returns {function} The unique context menu component
*/
buildMenu(setup) {
return (props) => {return React.createElement(MenuComponents.Menu, props, this.buildMenuChildren(setup));};
@ -329,12 +329,12 @@ 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}.
* @param {object} config - Configuration/props for the context menu.
* @param {string} [config.position="right"] - Default position for the menu, options: "left", "right".
* @param {string} [config.align="top"] - Default alignment for the menu, options: "bottom", "top".
* @param {function} [config.onClose] - Function to run when the menu is closed.
* @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}.
* @param {object} config Configuration/props for the context menu
* @param {string} [config.position="right"] Default position for the menu, options: "left", "right"
* @param {string} [config.align="top"] Default alignment for the menu, options: "bottom", "top"
* @param {function} [config.onClose] Function to run when the menu is closed
*/
open(event, menuComponent, config) {
return ContextMenuActions.openContextMenu(event, function(e) {

View File

@ -18,9 +18,9 @@ class Data {
/**
* Saves JSON-serializable 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.
* @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
*/
save(pluginName, key, data) {
if (this.#callerName) {
@ -34,9 +34,9 @@ class Data {
/**
* Loads previously stored data.
*
* @param {string} pluginName Name of the plugin loading data.
* @param {string} key Which piece of data to load.
* @returns {any} The stored data.
* @param {string} pluginName Name of the plugin loading data
* @param {string} key Which piece of data to load
* @returns {any} The stored data
*/
load(pluginName, key) {
if (this.#callerName) {
@ -49,7 +49,7 @@ class Data {
/**
* Deletes a piece of stored data. This is different than saving `null` or `undefined`.
*
* @param {string} pluginName Name of the plugin deleting data.
* @param {string} pluginName Name of the plugin deleting data
* @param {string} key Which piece of data to delete.
*/
delete(pluginName, key) {

View File

@ -30,8 +30,8 @@ class DOM {
/**
* Adds a `<style>` to the document with the given ID.
*
* @param {string} id ID to use for style element.
* @param {string} css CSS to apply to the document.
* @param {string} id ID to use for style element
* @param {string} css CSS to apply to the document
*/
addStyle(id, css) {
if (this.#callerName && arguments.length === 2) {
@ -49,7 +49,7 @@ class DOM {
/**
* Removes a `<style>` from the document corresponding to the given ID.
*
* @param {string} id ID used for the style element.
* @param {string} id ID used for the style element
*/
removeStyle(id) {
if (this.#callerName && arguments.length === 1) {
@ -65,8 +65,8 @@ class DOM {
/**
* Adds a listener for when the node is removed from the document body.
*
* @param {HTMLElement} node Node to be observed.
* @param {function} callback Function to run when removed.
* @param {HTMLElement} node Node to be observed
* @param {function} callback Function to run when removed
*/
onRemoved(node, callback) {
return DOMManager.onRemoved(node, callback);
@ -75,9 +75,9 @@ class DOM {
/**
* Utility to help smoothly animate using JavaScript.
*
* @param {function} update Render function indicating the style should be updated.
* @param {number} duration Duration in ms to animate for.
* @param {object} [options] Options to customize the animation.
* @param {function} update Render function indicating the style should be updated
* @param {number} duration Duration in ms to animate for
* @param {object} [options] Options to customize the animation
* @param {function} [options.timing] Optional function calculating progress based on current time fraction. Linear by default.
*/
animate(update, duration, options = {}) {
@ -88,13 +88,13 @@ class DOM {
* 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.
* @param {string} [options.className] Class name to add to the element.
* @param {string} [options.id] ID to set for the element.
* @param {HTMLElement} [options.target] Target element to automatically append to.
* @param {HTMLElement} [child] Child node to add.
* @returns {HTMLElement} The created HTML element.
* @param {string} tag HTML tag name to create
* @param {object} [options] Options object to customize the element
* @param {string} [options.className] Class name to add to the element
* @param {string} [options.id] ID to set for the element
* @param {HTMLElement} [options.target] Target element to automatically append to
* @param {HTMLElement} [child] Child node to add
* @returns {HTMLElement} The created HTML element
*/
createElement(tag, options = {}, child = null) {
return DOMManager.createElement(tag, options, child);
@ -108,9 +108,9 @@ class DOM {
* If the second parameter is false, then the return value will be the list of parsed
* nodes and there were multiple top level nodes, otherwise the single node is returned.
*
* @param {string} html - HTML to be parsed.
* @param {boolean} [fragment=false] - Whether or not the return should be the raw `DocumentFragment`.
* @returns {(DocumentFragment|NodeList|HTMLElement)} - The result of HTML parsing.
* @param {string} html HTML to be parsed
* @param {boolean} [fragment=false] Whether or not the return should be the raw `DocumentFragment`
* @returns {(DocumentFragment|NodeList|HTMLElement)} The result of HTML parsing
*/
parseHTML(html, fragment = false) {
return DOMManager.parseHTML(html, fragment);

View File

@ -53,8 +53,8 @@ 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.
* @param {string} id ID to use for style element
* @param {string} css CSS to apply to the document
* @memberof BdApi
*/
function injectCSS(id, css) {
@ -65,7 +65,7 @@ function injectCSS(id, css) {
* Removes a `<style>` from the document corresponding to the given ID.
*
* @deprecated
* @param {string} id ID uses for the style element.
* @param {string} id ID uses for the style element
* @memberof BdApi
*/
function clearCSS(id) {
@ -76,9 +76,9 @@ function clearCSS(id) {
* Automatically creates and links a remote JS script.
*
* @deprecated
* @param {string} id ID of the script element.
* @param {string} url URL of the remote script.
* @returns {Promise} Resolves upon onload event.
* @param {string} id ID of the script element
* @param {string} url URL of the remote script
* @returns {Promise} Resolves upon onload event
* @memberof BdApi
*/
function linkJS(id, url) {
@ -89,7 +89,7 @@ function linkJS(id, url) {
* Removes a remotely linked JS script.
*
* @deprecated
* @param {string} id ID of the script element.
* @param {string} id ID of the script element
* @memberof BdApi
*/
function unlinkJS(id) {
@ -100,8 +100,8 @@ function unlinkJS(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.
* @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
*/
function alert(title, content) {
@ -114,13 +114,13 @@ function alert(title, content) {
* @deprecated
* @param {string} title Title of the modal
* @param {(string|ReactElement|Array<string|ReactElement>)} children 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.
* @param {boolean} [options.danger=false] Whether the main button should be red or not.
* @param {string} [options.confirmText=Okay] Text for the confirmation/submit button.
* @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.
* @returns {string} The key used for this modal.
* @param {object} [options] Options to modify the modal
* @param {boolean} [options.danger=false] Whether the main button should be red or not
* @param {string} [options.confirmText=Okay] Text for the confirmation/submit button
* @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
* @returns {string} The key used for this modal
* @memberof BdApi
*/
function showConfirmationModal(title, content, options = {}) {
@ -131,12 +131,12 @@ function showConfirmationModal(title, content, options = {}) {
* 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} 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.forceShow=false] Whether to force showing the toast and ignore the BD setting.
* @param {boolean} [options.forceShow=false] Whether to force showing the toast and ignore the BD setting
* @memberof BdApi
*/
function showToast(content, options = {}) {
@ -148,9 +148,9 @@ function showToast(content, options = {}) {
*
* @deprecated
* @param {string|Node} content Content of the notice
* @param {object} options Options for 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 {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. Will not fire when set to `0`.
* @returns {function} A callback for closing the notice. Passing `true` as first parameter closes immediately without transitioning out.
* @memberof BdApi
@ -164,7 +164,7 @@ function showToast(content, options = {}) {
*
* @deprecated
* @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`.
* @returns {any} Either the matching module or `undefined`
* @memberof BdApi
*/
function findModule(filter) {
@ -176,7 +176,7 @@ function findModule(filter) {
*
* @deprecated
* @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.
* @returns {Array} Either an array of matching modules or an empty array
* @memberof BdApi
*/
function findAllModules(filter) {
@ -187,8 +187,8 @@ function findAllModules(filter) {
* Finds a webpack module by own properties.
*
* @deprecated
* @param {...string} props Any desired properties.
* @returns {any} Either the matching module or `undefined`.
* @param {...string} props Any desired properties
* @returns {any} Either the matching module or `undefined`
* @memberof BdApi
*/
function findModuleByProps(...props) {
@ -200,8 +200,8 @@ function findModuleByProps(...props) {
* Finds a webpack module by own prototypes.
*
* @deprecated
* @param {...string} protos Any desired prototype properties.
* @returns {any} Either the matching module or `undefined`.
* @param {...string} protos Any desired prototype properties
* @returns {any} Either the matching module or `undefined`
* @memberof BdApi
*/
function findModuleByPrototypes(...protos) {
@ -212,8 +212,8 @@ function findModuleByPrototypes(...protos) {
* Finds a webpack module by `displayName` property.
*
* @deprecated
* @param {string} name Desired `displayName` property.
* @returns {any} Either the matching module or `undefined`.
* @param {string} name Desired `displayName` property
* @returns {any} Either the matching module or `undefined`
* @memberof BdApi
*/
function findModuleByDisplayName(name) {
@ -225,7 +225,7 @@ function findModuleByDisplayName(name) {
*
* @deprecated
* @param {HTMLElement} node Node to get the internal React data from.
* @returns {object|undefined} Either the found data or `undefined`.
* @returns {object|undefined} Either the found data or `undefined`
* @memberof BdApi
*/
function getInternalInstance(node) {
@ -237,9 +237,9 @@ function getInternalInstance(node) {
* 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.
* @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
*/
function loadData(pluginName, key) {
@ -250,9 +250,9 @@ function loadData(pluginName, key) {
* 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.
* @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
* @memberof BdApi
*/
function saveData(pluginName, key, data) {
@ -263,8 +263,8 @@ function saveData(pluginName, key, data) {
* Deletes a piece of stored data. This is different than saving `null` or `undefined`.
*
* @deprecated
* @param {string} pluginName Name of the plugin deleting data.
* @param {string} key Which piece of data to delete.
* @param {string} pluginName Name of the plugin deleting data
* @param {string} key Which piece of data to delete
* @memberof BdApi
*/
function deleteData(pluginName, key) {
@ -279,14 +279,14 @@ function deleteData(pluginName, key) {
*
* @deprecated
* @param {object} what Object to be patched. You can can also pass class prototypes to patch all class instances.
* @param {string} methodName Name of the function to be patched.
* @param {object} options Options object to configure the patch.
* @param {string} methodName Name of the function to be patched
* @param {object} options Options object to configure the patch
* @param {function} [options.after] Callback that will be called after original target method call. You can modify return value here, so it will be passed to external code which calls target method. Can be combined with `before`.
* @param {function} [options.before] Callback that will be called before original target method call. You can modify arguments here, so it will be passed to original method. Can be combined with `after`.
* @param {function} [options.instead] Callback that will be called instead of original target method call. You can get access to original method using `originalMethod` parameter if you want to call it, but you do not have to. Can't be combined with `before` or `after`.
* @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.
* @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
*/
function monkeyPatch(what, methodName, options) {
@ -318,8 +318,8 @@ function monkeyPatch(what, methodName, options) {
* 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 removed.
* @param {HTMLElement} node Node to be observed
* @param {function} callback Function to run when removed
* @memberof BdApi
*/
function onRemoved(node, callback) {
@ -330,9 +330,9 @@ function onRemoved(node, callback) {
* Wraps a given function in a `try..catch` block.
*
* @deprecated
* @param {function} method Function to wrap.
* @param {string} message Additional message to print when an error occurs.
* @returns {function} The new wrapped function.
* @param {function} method Function to wrap
* @param {string} message Additional message to print when an error occurs
* @returns {function} The new wrapped function
* @memberof BdApi
*/
function suppressErrors(method, message) {
@ -346,8 +346,8 @@ function suppressErrors(method, message) {
* Tests a given object to determine if it is valid JSON.
*
* @deprecated
* @param {object} data Data to be tested.
* @returns {boolean} Result of the test.
* @param {object} data Data to be tested
* @returns {boolean} Result of the test
* @memberof BdApi
*/
function testJSON(data) {
@ -363,10 +363,10 @@ function testJSON(data) {
* 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.
* @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
*/
function isSettingEnabled(collection, category, id) {
@ -377,9 +377,9 @@ function isSettingEnabled(collection, category, id) {
* 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.
* @param {string} [collection="settings"] Collection ID
* @param {string} category Category ID in the collection
* @param {string} id Setting ID in the category
* @memberof BdApi
*/
function enableSetting(collection, category, id) {
@ -390,9 +390,9 @@ function enableSetting(collection, category, id) {
* Disables 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.
* @param {string} [collection="settings"] Collection ID
* @param {string} category Category ID in the collection
* @param {string} id Setting ID in the category
* @memberof BdApi
*/
function disableSetting(collection, category, id) {
@ -403,9 +403,9 @@ function disableSetting(collection, category, id) {
* 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.
* @param {string} [collection="settings"] Collection ID
* @param {string} category Category ID in the collection
* @param {string} id Setting ID in the category
* @memberof BdApi
*/
function toggleSetting(collection, category, id) {
@ -416,8 +416,8 @@ function toggleSetting(collection, category, id) {
* Gets some data in BetterDiscord's misc data.
*
* @deprecated
* @param {string} key Key of the data to load.
* @returns {any} The stored data.
* @param {string} key Key of the data to load
* @returns {any} The stored data
* @memberof BdApi
*/
function getBDData(key) {
@ -428,8 +428,8 @@ function getBDData(key) {
* Sets some data in BetterDiscord's misc data.
*
* @deprecated
* @param {string} key Key of the data to store.
* @returns {any} The stored data.
* @param {string} key Key of the data to store
* @returns {any} The stored data
* @memberof BdApi
*/
function setBDData(key, data) {
@ -441,20 +441,20 @@ function setBDData(key, data) {
* 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.
* @param {Array<object<string, string[]>>} [options.filters=[]] An array of [file filters](https://www.electronjs.org/docs/latest/api/structures/file-filter).
* @param {string} [options.title] Title for the titlebar.
* @param {string} [options.message] Message for the dialog.
* @param {boolean} [options.showOverwriteConfirmation=false] Whether the user should be prompted when overwriting a file.
* @param {boolean} [options.showHiddenFiles=false] Whether hidden files should be shown in the dialog.
* @param {boolean} [options.promptToCreate=false] Whether the user should be prompted to create non-existant folders.
* @param {boolean} [options.openDirectory=false] Whether the user should be able to select a directory as a target.
* @param {boolean} [options.openFile=true] Whether the user should be able to select a file as a target.
* @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.
* @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
* @param {Array<object<string, string[]>>} [options.filters=[]] An array of [file filters](https://www.electronjs.org/docs/latest/api/structures/file-filter)
* @param {string} [options.title] Title for the titlebar
* @param {string} [options.message] Message for the dialog
* @param {boolean} [options.showOverwriteConfirmation=false] Whether the user should be prompted when overwriting a file
* @param {boolean} [options.showHiddenFiles=false] Whether hidden files should be shown in the dialog
* @param {boolean} [options.promptToCreate=false] Whether the user should be prompted to create non-existant folders
* @param {boolean} [options.openDirectory=false] Whether the user should be able to select a directory as a target
* @param {boolean} [options.openFile=true] Whether the user should be able to select a file as a target
* @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
*/
async function openDialog(options) {

View File

@ -20,11 +20,11 @@ class Patcher {
* 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 {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.
* @param {string} functionName Name of the function to be patched.
* @param {string} functionName Name of the function to be patched
* @param {function} callback Function to run before the original method. The function is given the `this` context and the `arguments` of the original function.
* @returns {function} Function that cancels the original patch.
* @returns {function} Function that cancels the original patch
*/
before(caller, moduleToPatch, functionName, callback) {
if (this.#callerName) {
@ -40,11 +40,11 @@ class Patcher {
* 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.
*
* @param {string} caller Name of the caller of the patch function.
* @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.
* @param {string} functionName Name of the function to be patched.
* @param {string} functionName Name of the function to be patched
* @param {function} callback Function to run before the original method. The function is given the `this` context, `arguments` of the original function, and also the original function.
* @returns {function} Function that cancels the original patch.
* @returns {function} Function that cancels the original patch
*/
instead(caller, moduleToPatch, functionName, callback) {
if (this.#callerName) {
@ -60,11 +60,11 @@ class Patcher {
* 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.
*
* @param {string} caller Name of the caller of the patch function.
* @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.
* @param {string} functionName Name of the function to be patched.
* @param {string} functionName Name of the function to be patched
* @param {function} callback 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.
* @returns {function} Function that cancels the original patch.
* @returns {function} Function that cancels the original patch
*/
after(caller, moduleToPatch, functionName, callback) {
if (this.#callerName) {
@ -79,8 +79,8 @@ class Patcher {
/**
* Returns all patches by a particular caller. The patches all have an `unpatch()` method.
*
* @param {string} caller ID of the original patches.
* @returns {Array<function>} Array of all the patch objects.
* @param {string} caller ID of the original patches
* @returns {Array<function>} Array of all the patch objects
*/
getPatchesByCaller(caller) {
if (this.#callerName) caller = this.#callerName;
@ -91,7 +91,7 @@ class Patcher {
/**
* Automatically cancels all patches created with a specific ID.
*
* @param {string} caller ID of the original patches.
* @param {string} caller ID of the original patches
*/
unpatchAll(caller) {
if (this.#callerName) caller = this.#callerName;

View File

@ -14,8 +14,8 @@ const ReactUtils = {
/**
* Gets the internal React data of a specified node.
*
* @param {HTMLElement} node Node to get the internal React data from.
* @returns {object|undefined} Either the found data or `undefined` .
* @param {HTMLElement} node Node to get the internal React data from
* @returns {object|undefined} Either the found data or `undefined`
*/
getInternalInstance(node) {
if (node.__reactFiber$) return node.__reactFiber$;
@ -26,12 +26,12 @@ const ReactUtils = {
* 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 in the search.
* @param {array} [options.exclude=["Popout", "Tooltip", "Scroller", "BackgroundFlash"]] - List of items to exclude from the search.
* @param {callable} [options.filter=_=>_] - Filter to check the current instance with (should return a boolean).
* @return {(*|null)} The owner instance or `undefined` if not found.
* @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 in the search
* @param {array} [options.exclude=["Popout", "Tooltip", "Scroller", "BackgroundFlash"]] List of items to exclude from the search.
* @param {callable} [options.filter=_=>_] Filter to check the current instance with (should return a boolean)
* @return {object|undefined} The owner instance or `undefined` if not found
*/
getOwnerInstance(node, {include, exclude = ["Popout", "Tooltip", "Scroller", "BackgroundFlash"], filter = _ => _} = {}) {
if (node === undefined) return undefined;
@ -59,8 +59,9 @@ const ReactUtils = {
/**
* Creates an unrendered React component that wraps HTML elements.
* @param {HTMLElement} element - Element or array of elements to wrap.
* @returns {object} - Unrendered React component.
*
* @param {HTMLElement} element Element or array of elements to wrap
* @returns {object} Unrendered React component
*/
wrapElement(element) {
return class ReactWrapper extends DiscordModules.React.Component {

View File

@ -15,7 +15,7 @@ const UI = {
* Shows a generic but very customizable modal.
*
* @param {string} title Title of the modal
* @param {(string|ReactElement|Array<string|ReactElement>)} content A string of text to display in the modal.
* @param {(string|ReactElement|Array<string|ReactElement>)} content A string of text to display in the modal
*/
alert(title, content) {
Modals.alert(title, content);
@ -24,13 +24,13 @@ const UI = {
/**
* Creates a tooltip to automatically show on hover.
*
* @param {HTMLElement} node - DOM node to monitor and show the tooltip on.
* @param {string|HTMLElement} content - String to show in the tooltip.
* @param {object} options - Additional options for the tooltip.
* @param {"primary"|"info"|"success"|"warn"|"danger"} [options.style="primary"] - Correlates to the Discord styling/colors.
* @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.
* @param {HTMLElement} node DOM node to monitor and show the tooltip on
* @param {string|HTMLElement} content String to show in the tooltip
* @param {object} options Additional options for the tooltip
* @param {"primary"|"info"|"success"|"warn"|"danger"} [options.style="primary"] Correlates to the Discord styling/colors
* @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 {Tooltip} The tooltip that was generated.
*/
createTooltip(node, content, options = {}) {
@ -42,12 +42,12 @@ const UI = {
*
* @param {string} title Title of the modal.
* @param {(string|ReactElement|Array<string|ReactElement>)} children 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.
* @param {boolean} [options.danger=false] Whether the main button should be red or not.
* @param {string} [options.confirmText=Okay] Text for the confirmation/submit button.
* @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.
* @param {object} [options] Options to modify the modal
* @param {boolean} [options.danger=false] Whether the main button should be red or not
* @param {string} [options.confirmText=Okay] Text for the confirmation/submit button
* @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
* @returns {string} The key used for this modal.
*/
showConfirmationModal(title, content, options = {}) {
@ -57,12 +57,12 @@ const UI = {
/**
* This shows a toast similar to android towards the bottom of the screen.
*
* @param {string} content The string to show in the toast.
* @param {object} options Options object. Optional parameter.
* @param {string} content The string to show in the toast
* @param {object} options Options for the toast
* @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.forceShow=false] Whether to force showing the toast and ignore the BD setting.
* @param {boolean} [options.forceShow=false] Whether to force showing the toast and ignore the BD setting
*/
showToast(content, options = {}) {
Toasts.show(content, options);
@ -71,10 +71,10 @@ const UI = {
/**
* Shows a notice above Discord's chat layer.
*
* @param {string|Node} content Content of the notice.
* @param {object} options Options for the notice.
* @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 {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. Will not fire when set to `0`.
* @returns {function} A callback for closing the notice. Passing `true` as first parameter closes immediately without transitioning out.
*/
@ -86,20 +86,20 @@ const UI = {
* 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.
* @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.
* @param {Array<object<string, string[]>>} [options.filters=[]] An array of [file filters](https://www.electronjs.org/docs/latest/api/structures/file-filter).
* @param {string} [options.title] Title for the titlebar.
* @param {string} [options.message] Message for the dialog.
* @param {boolean} [options.showOverwriteConfirmation=false] Whether the user should be prompted when overwriting a file.
* @param {boolean} [options.showHiddenFiles=false] Whether hidden files should be shown in the dialog.
* @param {boolean} [options.promptToCreate=false] Whether the user should be prompted to create non-existant folders.
* @param {boolean} [options.openDirectory=false] Whether the user should be able to select a directory as a target.
* @param {boolean} [options.openFile=true] Whether the user should be able to select a file as a target.
* @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.
* @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
* @param {Array<object<string, string[]>>} [options.filters=[]] An array of [file filters](https://www.electronjs.org/docs/latest/api/structures/file-filter)
* @param {string} [options.title] Title for the titlebar
* @param {string} [options.message] Message for the dialog
* @param {boolean} [options.showOverwriteConfirmation=false] Whether the user should be prompted when overwriting a file
* @param {boolean} [options.showHiddenFiles=false] Whether hidden files should be shown in the dialog
* @param {boolean} [options.promptToCreate=false] Whether the user should be prompted to create non-existent folders
* @param {boolean} [options.openDirectory=false] Whether the user should be able to select a directory as a target
* @param {boolean} [options.openFile=true] Whether the user should be able to select a file as a target
* @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
*/
async openDialog(options) {
const data = await ipc.openDialog(options);

View File

@ -10,11 +10,11 @@ const Utils = {
/**
* Finds a value, subobject, or array from a tree that matches a specific filter. This is a DFS.
*
* @param {object} tree Tree that should be walked.
* @param {callable} searchFilter Filter to check against each object and subobject.
* @param {object} options Additional options to customize the search.
* @param {Array<string>|null} [options.walkable=null] Array of strings to use as keys that are allowed to be walked on. Null value indicates all keys are walkable.
* @param {Array<string>} [options.ignore=[]] Array of strings to use as keys to exclude from the search, most helpful when `walkable = null`.
* @param {object} tree Tree that should be walked
* @param {callable} searchFilter Filter to check against each object and subobject
* @param {object} options Additional options to customize the search
* @param {Array<string>|null} [options.walkable=null] Array of strings to use as keys that are allowed to be walked on. `null` indicates all keys are walkable.
* @param {Array<string>} [options.ignore=[]] Array of strings to use as keys to exclude from the search. Most helpful when `walkable = null`.
*/
findInTree(tree, searchFilter, options = {}) {
return Utilities.findInTree(tree, searchFilter, options);
@ -26,9 +26,9 @@ const Utils = {
* it will be overwritten with the next one with the same key. If it is an object,
* and the keys match, the object is extended. This happens recursively.
*
* @param {object} extendee - Object to be extended.
* @param {...object} extenders - Objects to extend with.
* @returns {object} - A reference to `extendee`.
* @param {object} extendee Object to be extended
* @param {...object} extenders Objects to extend with
* @returns {object} A reference to `extendee`
*/
extend(extendee, ...extenders) {
return Utilities.extend(extendee, ...extenders);
@ -41,9 +41,9 @@ const Utils = {
*
* Adapted from the version by David Walsh (https://davidwalsh.name/javascript-debounce-function)
*
* @param {function} executor The function to be debounced.
* @param {number} delay Number of ms to delay calls.
* @return {function} A debounced version of the function.
* @param {function} executor The function to be debounced
* @param {number} delay Number of ms to delay calls
* @return {function} A debounced version of the function
*/
debounce(executor, delay) {
return Utilities.debounce(executor, delay);
@ -51,8 +51,9 @@ const Utils = {
/**
* Takes a string of HTML and escapes it using the browser's own escaping mechanism.
* @param {String} html - HTML to be escaped.
* @return {string} Escaped HTML string.
*
* @param {String} html HTML to be escaped
* @return {string} Escaped HTML string
*/
escapeHTML(html) {
return Utilities.escapeHTML(html);
@ -64,8 +65,8 @@ const Utils = {
* When given an object they keys are added as the classnames if the value is truthy.
* Copyright (c) 2018 Jed Watson https://github.com/JedWatson/classnames MIT License
*
* @param {...Any} argument - Anything that should be used to add classnames.
* @returns {string} Joined classname.
* @param {...Any} argument Anything that should be used to add classnames
* @returns {string} Joined classname
*/
className() {
return Utilities.className(...arguments);