Update EditRoles.plugin.js

This commit is contained in:
Mirco Wittrien 2021-04-09 18:51:46 +02:00
parent b031394cf4
commit 090b2ad441
1 changed files with 21 additions and 2 deletions

View File

@ -2,7 +2,7 @@
* @name EditRoles
* @author DevilBro
* @authorId 278543574059057154
* @version 1.0.1
* @version 1.0.3
* @description Allows you to locally edit Roles
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -17,7 +17,7 @@ module.exports = (_ => {
"info": {
"name": "EditRoles",
"author": "DevilBro",
"version": "1.0.1",
"version": "1.0.3",
"description": "Allows you to locally edit Roles"
}
};
@ -135,6 +135,25 @@ module.exports = (_ => {
BDFDB.MessageUtils.rerenderAll();
}
onUserContextMenu (e) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "roles"});
if (index > -1 && children[index].props && BDFDB.ArrayUtils.is(children[index].props.children)) for (let child of children[index].props.children) {
if (child && child.props && typeof child.props.label == "function") {
let renderLabel = child.props.label;
child.props.label = (...args) => {
let label = renderLabel(...args);
let onContextMenu = typeof label.props.onContextMenu == "function" ? label.props.onContextMenu : (_ => {});
label.props.onContextMenu = event => {
BDFDB.LibraryModules.ContextMenuUtils.openContextMenu(event, function (e) {
return BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("DeveloperContextMenu"), Object.assign({}, e, {id: child.props.id}));
});
};
return label;
};
}
}
}
onGuildContextMenu (e) {
if (e.instance.props.guild) e.instance.props.guild = this.changeRolesInGuild(e.instance.props.guild);
}