A 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
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.
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.
import { Injector, 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 before 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
Module to inject to
Function name on that module to inject
Code to run
Uninject function
Remove all injections made by this injector
Inject code into Discord's webpack modules.
Example