Private
#slashPrivate
#uninjectorsA few utils to add stuff in frequent modules.
A utility function to add an item to any context menu.
By default, items are placed in a group for custom items, though that can be customized with sectionId
and indexInSection
The id of the menu to add to
The function that creates the item to add
— The number of the section to add to. Defaults to replugged's section
— The index in the section to add to. Defaults to the end position
A callback to de-register the function
Add an item to any context menu
A callback to de-register the function
import { Injector, components, types } from "replugged";
const { ContextMenu: { MenuItem } } = components;
const { ContextMenuTypes } = types;
const injector = new Injector();
export function start() {
injector.utils.addMenuItem(ContextMenuTypes.UserContext, // Right-clicking a user
(data, menu) => {
return <MenuItem
id="my-item"
label="An Item!"
action={() => console.log(data)}
/>
}
)
}
export function stop() {
injector.uninjectAll();
}
A utility function to add a button to any message popover.
The function that creates the button to add
Uninject Function.
Adds a button to any MessagePopover
A callback to remove the button from set.
import { Injector, webpack } from "replugged";
const injector = new Injector();
export function start() {
injector.utils.addPopoverButton((msg: Message, channel: Channel) => {
return {
label: "Click the button!",
icon: myVeryCoolIcon(), // Cool icon
onClick: () => {
// do stuff here when someone left clicks the button
},
onContextMenu: () => {
// do other stuff here when someone right clicks the button
},
};
});
}
export function stop() {
injector.uninjectAll();
}
A utility function to add a custom slash command.
The slash command to add to register
A callback to de-register the command
Code to register an slash command
An Callback to unregister the slash command
import { Injector, components, types } from "replugged";
const injector = new Injector();
export function start() {
injector.utils.registerSlashCommand({
name: "use",
description: "a command meant to be used",
usage: "/use",
executor: (interaction) => {},
})
}
export function stop() {
injector.uninjectAll();
}
Run code after a native module
Module to inject to
Function name on that module to inject
Code to run
Uninject function
Run code after a native module
Uninject function
Run code before a native module
Module to inject to
Function name on that module to inject
Code to run
Uninject function
Run code before a native module
Uninject function
Run code instead of a native module
Module to inject to
Function name on that module to inject
Code to run
Uninject function
Run code instead of a native module
Uninject function
Generated using TypeDoc
Inject code into Discord's webpack modules.
Example