From cb6a384b3767babd799042a29737098c17c3411f Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Wed, 3 Aug 2022 00:21:40 +0200 Subject: [PATCH] Update EditRoles.plugin.js --- Plugins/EditRoles/EditRoles.plugin.js | 35 ++++++++++++++------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Plugins/EditRoles/EditRoles.plugin.js b/Plugins/EditRoles/EditRoles.plugin.js index 9a60b9e975..640c1b7bea 100644 --- a/Plugins/EditRoles/EditRoles.plugin.js +++ b/Plugins/EditRoles/EditRoles.plugin.js @@ -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; - }; + } } } }