EditRoles
This commit is contained in:
parent
906f3ed6de
commit
0e776e0588
|
@ -358,9 +358,11 @@
|
|||
"AuditLogEntry": {"protos": ["renderRoleUpdate", "renderChangeDetails", "getActionTypeColor", "renderPermissionUpdate"]},
|
||||
"AuthWrapper": {"protos": ["renderDefault", "renderMobile", "mobileReplaceWith"]},
|
||||
"AutocompleteChannelResult": {"strings": [".channel", ".category", ".type===", ".GUILD_CATEGORY?", "().icon"]},
|
||||
"AutocompleteRoleResult": {"strings": [".hideDescription", ".colorString", ".Messages.MENTION_USERS_WITH_ROLE"]},
|
||||
"AutocompleteRowContentPrimary": {"strings": ["createElement(\"div\"", "autocompleteRowContentPrimary"]},
|
||||
"AutocompleteRowContentSecondary": {"strings": ["createElement(", "autocompleteRowContentSecondary"]},
|
||||
"AutocompleteRowIcon": {"strings": ["createElement(\"div\"", "autocompleteRowIcon"]},
|
||||
"AutocompleteUserResult": {"strings": [".descriptionUsername", ".descriptionDiscriminator", "\"#\"", "Sizes.SIZE_24"]},
|
||||
"BlobMask": {"protos": ["getBadgePositionInterpolation", "getUpperBadgeStyles"]},
|
||||
"BlockedMessageGroup": {"strings": ["collapsed-message-item", "isBeforeGroup", "collapsedReason"]},
|
||||
"ChannelCall": {"strings": ["maybeLeaveFullScreen", "handleFullscreenParticipant", "CHANNEL_CALL_POPOUT"]},
|
||||
|
@ -457,6 +459,7 @@
|
|||
"RecentMentions": {"strings": ["canCloseAllMessages", "RECENT_MENTIONS", "badgeable"]},
|
||||
"RecentsChannelHeader": {"strings": [".subtextContainer", ".channelNameSpan", ".channelNameHeader", ".gotoChannel"]},
|
||||
"RichChannelMention": {"strings": ["iconType:", "Messages.DELETED_CHANNEL_PLACEHOLDER"]},
|
||||
"RichRoleMention": {"strings": [".color?null", ".guildId", ".roles[", "\"@\""]},
|
||||
"RichUserMention": {"strings": ["hidePersonalInformation", "getUser", "userTooltip"]},
|
||||
"SearchBar": {"strings": [").inputRef", ".containerRef", ".handleOnChange"]},
|
||||
"SearchPopout": {"strings": [".handleHintClick", ".selectedIndex", "token.start"]},
|
||||
|
@ -504,7 +507,7 @@
|
|||
"UserSettingsAppearance": {"protos": ["renderTheme", "renderDisplayMode", "renderMessageGroupSpacingSlider"]},
|
||||
"UserThemedBanner": {"strings": [".showPremiumBadgeUpsell", ".isPremiumAtLeast", ".SETTINGS"]},
|
||||
"UserThemedPopoutAvatar": {"strings": [".avatarPositionPremiumNoBanner", "VIEW_PROFILE"]},
|
||||
"UserThemedPopoutBody": {"strings": [".customStatusActivity", ".canDM", ".hidePersonalInformation"]},
|
||||
"UserThemedPopoutBody": {"strings": [".customStatusActivity", ".canDM", ".hidePersonalInformation", ".showCopiableUsername"]},
|
||||
"VoiceUser": {"protos": ["renderPrioritySpeaker", "renderIcons", "renderAvatar"]},
|
||||
"VoiceUsers": {"strings": ["hidePreview", "previewIsOpen", "previewUserIdAfterDelay"]}
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name EditRoles
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 1.1.2
|
||||
* @version 1.1.3
|
||||
* @description Allows you to locally edit Roles
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -60,19 +60,19 @@ module.exports = (_ => {
|
|||
|
||||
return class EditRoles extends Plugin {
|
||||
onLoad () {
|
||||
this.patchedModules = {
|
||||
before: {
|
||||
RoleMention: "default",
|
||||
AutocompleteRoleResult: "render",
|
||||
MessageHeader: "default",
|
||||
ChannelMembers: "render",
|
||||
MemberListItem: "render",
|
||||
UserPopoutBodySection: "default",
|
||||
UserPopoutBody: "default"
|
||||
},
|
||||
after: {
|
||||
RichRoleMention: "RoleMention"
|
||||
}
|
||||
this.modulePatches = {
|
||||
before: [
|
||||
"AutocompleteRoleResult",
|
||||
"ChannelMembers",
|
||||
"MemberListItem",
|
||||
"MessageContent",
|
||||
"RoleMention",
|
||||
"UserPopoutBody",
|
||||
"UserThemedPopoutBody"
|
||||
],
|
||||
after: [
|
||||
"RichRoleMention"
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -159,19 +159,17 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
onUserContextMenu (e) {
|
||||
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" && changedRoles[child.props.id]) {
|
||||
let data = changedRoles[child.props.id];
|
||||
let renderLabel = child.props.label;
|
||||
child.props.label = BDFDB.TimeUtils.suppress((...args) => {
|
||||
let label = renderLabel(...args);
|
||||
if (data.color && label.props.children[0] && label.props.children[0].props) label.props.children[0].props.color = BDFDB.ColorUtils.convert(data.color, "hex");
|
||||
if (data.name && label.props.children[1] && label.props.children[1].props && label.props.children[1].props.children) label.props.children[1].props.children = data.name;
|
||||
return label;
|
||||
}, "Error in renderLabel of UserRolesItems", this);
|
||||
}
|
||||
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" && changedRoles[child.props.id]) {
|
||||
let data = changedRoles[child.props.id];
|
||||
let renderLabel = child.props.label;
|
||||
child.props.label = BDFDB.TimeUtils.suppress((...args) => {
|
||||
let label = renderLabel(...args);
|
||||
if (data.color && label.props.children[0] && label.props.children[0].props) label.props.children[0].props.color = BDFDB.ColorUtils.convert(data.color, "hex");
|
||||
if (data.name && label.props.children[1] && label.props.children[1].props && label.props.children[1].props.children) label.props.children[1].props.children = data.name;
|
||||
return label;
|
||||
}, "Error in renderLabel of UserRolesItems", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,29 +215,27 @@ module.exports = (_ => {
|
|||
e.returnvalue.props.children
|
||||
].flat(10).filter(n => n);
|
||||
}
|
||||
|
||||
processRichRoleMention (e) {
|
||||
if (e.instance.props.id && changedRoles[e.instance.props.id]) {
|
||||
e.returnvalue.props.color = changedRoles[e.instance.props.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.id].color, "int") : e.returnvalue.props.color;
|
||||
e.returnvalue.props.children[1] = changedRoles[e.instance.props.id].name || e.returnvalue.props.children[1];
|
||||
|
||||
processMessageContent (e) {
|
||||
if (!BDFDB.ArrayUtils.is(e.instance.props.content)) return;
|
||||
for (let ele of e.instance.props.content) if (BDFDB.ReactUtils.isValidElement(ele) && ele.props && ele.props.type == "mention" && ele.props.roleId && changedRoles[ele.props.roleId]) {
|
||||
ele.props.roleColor = changedRoles[ele.props.roleId].color ? BDFDB.ColorUtils.convert(changedRoles[ele.props.roleId].color, "int") : ele.props.roleColor;
|
||||
if (changedRoles[ele.props.roleId].name) ele.props.children = ["@" + changedRoles[ele.props.roleId].name];
|
||||
}
|
||||
}
|
||||
|
||||
processRoleMention (e) {
|
||||
if (e.instance.props.roleId && changedRoles[e.instance.props.roleId]) {
|
||||
e.instance.props.roleColor = changedRoles[e.instance.props.roleId].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.roleId].color, "int") : e.instance.props.roleColor;
|
||||
e.instance.props.children = [`@${changedRoles[e.instance.props.roleId].name || e.instance.props.children[1]}`];
|
||||
if (e.instance.props.content && e.instance.props.content[0]) e.instance.props.content[0].content = `@${changedRoles[e.instance.props.roleId].name || e.instance.props.children[1]}`;
|
||||
}
|
||||
processRichRoleMention (e) {
|
||||
if (!e.instance.props.id || !changedRoles[e.instance.props.id]) return;
|
||||
e.returnvalue.props.color = changedRoles[e.instance.props.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.id].color, "int") : e.returnvalue.props.color;
|
||||
e.returnvalue.props.children[1] = changedRoles[e.instance.props.id].name || e.returnvalue.props.children[1];
|
||||
}
|
||||
|
||||
processAutocompleteRoleResult (e) {
|
||||
if (e.instance.props.role && changedRoles[e.instance.props.role.id]) {
|
||||
e.instance.props.role = Object.assign({}, e.instance.props.role);
|
||||
e.instance.props.role.color = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "int") : e.instance.props.role.color;
|
||||
e.instance.props.role.colorString = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "hex") : e.instance.props.role.colorString;
|
||||
e.instance.props.role.name = changedRoles[e.instance.props.role.id].name || e.instance.props.role.name;
|
||||
}
|
||||
if (!e.instance.props.role || !changedRoles[e.instance.props.role.id]) return;
|
||||
e.instance.props.role = Object.assign({}, e.instance.props.role);
|
||||
e.instance.props.role.color = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "int") : e.instance.props.role.color;
|
||||
e.instance.props.role.colorString = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "hex") : e.instance.props.role.colorString;
|
||||
e.instance.props.role.name = changedRoles[e.instance.props.role.id].name || e.instance.props.role.name;
|
||||
}
|
||||
|
||||
processChannelMembers (e) {
|
||||
|
@ -256,13 +252,12 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
processMemberListItem (e) {
|
||||
if (e.instance.props.user) {
|
||||
let member = BDFDB.LibraryStores.GuildMemberStore.getMember(e.instance.props.guildId, e.instance.props.user.id);
|
||||
if (member) e.instance.props.colorString = member.colorString;
|
||||
}
|
||||
if (!e.instance.props.user) return;
|
||||
let member = BDFDB.LibraryStores.GuildMemberStore.getMember(e.instance.props.guildId, e.instance.props.user.id);
|
||||
if (member) e.instance.props.colorString = member.colorString;
|
||||
}
|
||||
|
||||
processUserPopoutBodySection (e) {
|
||||
processUserThemedPopoutBody (e) {
|
||||
if (e.instance.props.guild) e.instance.props.guild = this.changeRolesInGuild(e.instance.props.guild);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue