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 * @name EditRoles
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 1.0.8 * @version 1.0.9
* @description Allows you to locally edit Roles * @description Allows you to locally edit Roles
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,12 +17,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "EditRoles", "name": "EditRoles",
"author": "DevilBro", "author": "DevilBro",
"version": "1.0.8", "version": "1.0.9",
"description": "Allows you to locally edit Roles" "description": "Allows you to locally edit Roles"
}, },
"changeLog": { "changeLog": {
"fixed": { "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 => { 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 => { 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; 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) { onUserContextMenu (e) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "roles"}); if (e.subType == "useUserRolesItems") {
if (index > -1 && children[index].props && BDFDB.ArrayUtils.is(children[index].props.children)) for (let child of children[index].props.children) { let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "roles"});
if (child && child.props && typeof child.props.label == "function") { if (index > -1 && children[index].props && BDFDB.ArrayUtils.is(children[index].props.children)) for (let child of children[index].props.children) {
let renderLabel = child.props.label; if (child && child.props && typeof child.props.label == "function") {
child.props.label = (...args) => { let renderLabel = child.props.label;
let label = renderLabel(...args); child.props.label = (...args) => {
let onContextMenu = typeof label.props.onContextMenu == "function" ? label.props.onContextMenu : (_ => {}); let label = renderLabel(...args);
label.props.onContextMenu = event => { let onContextMenu = typeof label.props.onContextMenu == "function" ? label.props.onContextMenu : (_ => {});
BDFDB.LibraryModules.ContextMenuUtils.openContextMenu(event, function (e) { 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 BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("DeveloperContextMenu"), Object.assign({}, e, {id: child.props.id})); return label;
});
}; };
return label; }
};
} }
} }
} }