Update EditUsers.plugin.js

This commit is contained in:
Mirco Wittrien 2020-10-07 10:15:09 +02:00
parent 5dae1ef72f
commit a29f0ec311
1 changed files with 10 additions and 9 deletions

View File

@ -5,12 +5,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "EditUsers", "name": "EditUsers",
"author": "DevilBro", "author": "DevilBro",
"version": "3.9.7", "version": "3.9.8",
"description": "Allows you to change the icon, name, tag and color of users." "description": "Allows you to change the icon, name, tag and color of users."
}, },
"changeLog": { "changeLog": {
"added": { "fixed": {
"Do not overwrite role color": "Added option to not overwrite rolecolor in chats and memberlist" "Chat": "Works again in chat"
} }
} }
}; };
@ -549,19 +549,20 @@ module.exports = (_ => {
processMessageHeader (e) { processMessageHeader (e) {
if (e.instance.props.message && settings.changeInChatWindow) { if (e.instance.props.message && settings.changeInChatWindow) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue.props.children.slice(1), {name: "Popout", props: [["className", BDFDB.disCN.messageusername]]}); let headerText = BDFDB.ReactUtils.findChild(e.returnvalue.props.children, {props: [["className", BDFDB.disCN.messageheadertext]]});
if (index > -1) { if (headerText && headerText.props && headerText.props.children) {
let children = headerText.props.children && headerText.props.children.props ? headerText.props.children.props.children : headerText.props.children;
let data = changedUsers[e.instance.props.message.author.id]; let data = changedUsers[e.instance.props.message.author.id];
if (data && (data.color1 || data.color2)) { if (data && (data.color1 || data.color2)) {
if (children[index].props && typeof children[index].props.children == "function") { if (children[0].props && typeof children[0].props.children == "function") {
let renderChildren = children[index].props.children; let renderChildren = children[0].props.children;
children[index].props.children = (...args) => { children[0].props.children = (...args) => {
let renderedChildren = renderChildren(...args); let renderedChildren = renderChildren(...args);
this.changeUserColor(renderedChildren, e.instance.props.message.author.id, {guildId: (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id}); this.changeUserColor(renderedChildren, e.instance.props.message.author.id, {guildId: (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id});
return renderedChildren; return renderedChildren;
} }
} }
else this.changeUserColor(children[index], e.instance.props.message.author.id, {guildId: (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id}); else this.changeUserColor(children[0], e.instance.props.message.author.id, {guildId: (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id});
} }
this.injectBadge(children, e.instance.props.message.author.id, (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id, 2, { this.injectBadge(children, e.instance.props.message.author.id, (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id, 2, {
tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy, tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy,