Update EditRoles.plugin.js

This commit is contained in:
Mirco Wittrien 2022-08-03 00:21:40 +02:00
parent fc5aef83f6
commit cb6a384b37
1 changed files with 18 additions and 17 deletions

View File

@ -2,7 +2,7 @@
* @name EditRoles
* @author DevilBro
* @authorId 278543574059057154
* @version 1.0.8
* @version 1.0.9
* @description Allows you to locally edit Roles
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -17,12 +17,12 @@ module.exports = (_ => {
"info": {
"name": "EditRoles",
"author": "DevilBro",
"version": "1.0.8",
"version": "1.0.9",
"description": "Allows you to locally edit Roles"
},
"changeLog": {
"fixed": {
"Icons": "Work again"
"Remove Icon": "Now works again"
}
}
};
@ -109,7 +109,10 @@ module.exports = (_ => {
}
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.RoleIconUtils, "getRoleIconData", {after: e => {
if (e.returnValue && e.methodArguments[0].id && changedRoles[e.methodArguments[0].id] && changedRoles[e.methodArguments[0].id].icon) return {customIconSrc: changedRoles[e.methodArguments[0].id].icon};
if (e.returnValue && e.methodArguments[0].id && changedRoles[e.methodArguments[0].id]) {
if (changedRoles[e.methodArguments[0].id].icon) return {customIconSrc: changedRoles[e.methodArguments[0].id].icon};
else if (changedRoles[e.methodArguments[0].id].removeIcon) return {customIconSrc: null};
}
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.RoleIconUtils, "canGuildUseRoleIcons", {after: e => {
if (e.returnValue === false && Object.keys(e.methodArguments[0].roles).some(roleId => changedRoles[roleId] && changedRoles[roleId].icon)) return true;
@ -162,20 +165,18 @@ module.exports = (_ => {
}
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}));
});
if (e.subType == "useUserRolesItems") {
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, e => BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("DeveloperContextMenu"), Object.assign({}, e2, {id: child.props.id})));
return label;
};
return label;
};
}
}
}
}