Skip to main content


ContextMenu is a module to help patch and create context menus. Instance is accessible through the BdApi.




Builds a single menu item. The only prop shown here is the type, the rest should 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.

propsobjectnoneProps used to build the item
props.typestring"text"Type of the item, options: text, submenu, toggle, radio, custom, separator

Returns: object - The created component


Creates the menu component including the wrapping ContextMenu. Calls {@link ContextMenu.buildMenuChildren} under the covers. Used to call in combination with {@link}.

setupArray.<object>Array of item props used to build items. See {@link ContextMenu.buildMenuChildren}.

Returns: function - The unique context menu component


Creates the all the items and groups of a context menu recursively. There is no hard limit to the number of groups within groups or number of items in a menu.

setupArray.<object>Array of item props used to build items. See {@link ContextMenu.buildItem}.

Returns: Array.<object> - Array of the created component


Closes the current opened context menu immediately.

Returns: void


Function that allows you to open an entire context menu. Recommended to build the menu with this module.

eventMouseEventnoneThe context menu event. This can be emulated, requires target, and all X, Y locations.
menuComponentfunctionnoneComponent to render. This can be any React component or output of {@link ContextMenu.buildMenu}.
configobjectnoneConfiguration/props for the context menu
config.positionstring"right"Default position for the menu, options: "left", "right"
config.alignstring"top"Default alignment for the menu, options: "bottom", "top"
config.onClosefunctionnoneFunction to run when the menu is closed

Returns: void


Allows you to patch a given context menu. Acts as a wrapper around the Patcher.

navIdstringDiscord's internal navId used to identify context menus
callbackfunctionCallback function that accepts the React render tree

Returns: function - A function that automatically unpatches


Allows you to remove the patch added to a given context menu.

navIdstringThe original navId from patching
callbackfunctionThe original callback from patching

Returns: void