From e328d831284ed9edd36b0b9ffb3e0c5031ba0568 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Thu, 27 Feb 2020 11:53:07 +0100 Subject: [PATCH] stuff --- .../BadgesEverywhere.plugin.js | 5 ++-- Plugins/CustomQuoter/CustomQuoter.plugin.js | 2 +- Plugins/EditUsers/EditUsers.plugin.js | 24 ++++++++++--------- .../MessageUtilities.plugin.js | 2 +- Plugins/OwnerTag/OwnerTag.plugin.js | 7 ++++-- Plugins/PersonalPins/PersonalPins.plugin.js | 10 ++++---- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Plugins/BadgesEverywhere/BadgesEverywhere.plugin.js b/Plugins/BadgesEverywhere/BadgesEverywhere.plugin.js index 9e8eb08911..f0820e2e47 100644 --- a/Plugins/BadgesEverywhere/BadgesEverywhere.plugin.js +++ b/Plugins/BadgesEverywhere/BadgesEverywhere.plugin.js @@ -7,7 +7,7 @@ var BadgesEverywhere = (_ => { return class BadgesEverywhere { getName () {return "BadgesEverywhere";} - getVersion () {return "1.5.2";} + getVersion () {return "1.5.3";} getAuthor () {return "DevilBro";} @@ -245,7 +245,8 @@ var BadgesEverywhere = (_ => { processMessageHeader (e) { if (e.instance.props.message && BDFDB.DataUtils.get(this, "settings", "showInChat")) { - this.injectBadges(e.instance, e.returnvalue.props.children[2].props.children, e.instance.props.message.author, "chat"); + let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue.props.children.slice(1), {name: "Popout"}); + if (index > -1) this.injectBadges(e.instance, children, e.instance.props.message.author, "chat"); } } diff --git a/Plugins/CustomQuoter/CustomQuoter.plugin.js b/Plugins/CustomQuoter/CustomQuoter.plugin.js index f46a74bed7..96261b6cae 100644 --- a/Plugins/CustomQuoter/CustomQuoter.plugin.js +++ b/Plugins/CustomQuoter/CustomQuoter.plugin.js @@ -222,7 +222,7 @@ var CustomQuoter = (_ => { let unquotedLines = message.content.split("\n").filter(line => !line.startsWith("> ")); unquotedLines = unquotedLines.slice(unquotedLines.findIndex(line => line.trim().length > 0)).join("\n"); - let guild = channel.guild_id ? (BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id) || {id: channel.guild_id, name: "Test Server"}) : {id: "@me", name: BDFDB.LanguageUtils.LanguageStrings.DIRECT_MESSAGES}; + let guild = channel.guild_id ? (BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id) || {id: channel.guild_id, name: "Test Server"}) : {id: BDFDB.DiscordConstants.ME, name: BDFDB.LanguageUtils.LanguageStrings.DIRECT_MESSAGES}; return BDFDB.StringUtils.insertNRST(customQuote) diff --git a/Plugins/EditUsers/EditUsers.plugin.js b/Plugins/EditUsers/EditUsers.plugin.js index 200974fa66..11943ce261 100644 --- a/Plugins/EditUsers/EditUsers.plugin.js +++ b/Plugins/EditUsers/EditUsers.plugin.js @@ -4,7 +4,7 @@ var EditUsers = (_ => { return class EditUsers { getName () {return "EditUsers";} - getVersion () {return "3.7.8";} + getVersion () {return "3.7.9";} getAuthor () {return "DevilBro";} @@ -484,19 +484,21 @@ var EditUsers = (_ => { processMessageHeader (e) { if (e.instance.props.message && BDFDB.DataUtils.get(this, "settings", "changeInChatWindow")) { - let data = BDFDB.DataUtils.load(this, "users", e.instance.props.message.author.id); - if (data && (data.color1 || data.color2)) { - let usernamePopout = BDFDB.ReactUtils.getValue(e, "returnvalue.props.children.2.props.children.1") - if (usernamePopout && usernamePopout.props && typeof usernamePopout.props.children == "function") { - let renderChildren = usernamePopout.props.children; - usernamePopout.props.children = (...args) => { - let renderedChildren = renderChildren(...args); - this.changeUserColor(renderedChildren, e.instance.props.message.author.id); - return renderedChildren; + let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue.props.children.slice(1), {name: "Popout"}); + if (index > -1) { + let data = BDFDB.DataUtils.load(this, "users", e.instance.props.message.author.id); + if (data && (data.color1 || data.color2)) { + if (children[index] && children[index].props && typeof children[index].props.children == "function") { + let renderChildren = children[index].props.children; + children[index].props.children = (...args) => { + let renderedChildren = renderChildren(...args); + this.changeUserColor(renderedChildren, e.instance.props.message.author.id); + return renderedChildren; + } } } + this.injectBadge(children, e.instance.props.message.author.id, (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id, 2, e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy); } - this.injectBadge(e.returnvalue.props.children[2].props.children, e.instance.props.message.author.id, (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id, 2, e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy); } } diff --git a/Plugins/MessageUtilities/MessageUtilities.plugin.js b/Plugins/MessageUtilities/MessageUtilities.plugin.js index aff370ecb1..e50ab8b822 100644 --- a/Plugins/MessageUtilities/MessageUtilities.plugin.js +++ b/Plugins/MessageUtilities/MessageUtilities.plugin.js @@ -324,7 +324,7 @@ var MessageUtilities = (_ => { doCopyLink ({messagediv, message}, action) { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id); if (channel) { - BDFDB.LibraryRequires.electron.clipboard.write({text:`https://discordapp.com/channels/${channel.guild_id || "@me"}/${channel.id}/${message.id}`}); + BDFDB.LibraryRequires.electron.clipboard.write({text:`https://discordapp.com/channels/${channel.guild_id || BDFDB.DiscordConstants.ME}/${channel.id}/${message.id}`}); if (BDFDB.DataUtils.get(this, "toasts", action)) BDFDB.NotificationUtils.toast("Messagelink has been copied.", {type:"success"}); } } diff --git a/Plugins/OwnerTag/OwnerTag.plugin.js b/Plugins/OwnerTag/OwnerTag.plugin.js index 064eaedf3d..d8d16091ec 100644 --- a/Plugins/OwnerTag/OwnerTag.plugin.js +++ b/Plugins/OwnerTag/OwnerTag.plugin.js @@ -4,7 +4,7 @@ var OwnerTag = (_ => { return class OwnerTag { getName () {return "OwnerTag";} - getVersion () {return "1.2.5";} + getVersion () {return "1.2.6";} getAuthor () {return "DevilBro";} @@ -161,7 +161,10 @@ var OwnerTag = (_ => { processMessageHeader (e) { if (e.instance.props.message && BDFDB.DataUtils.get(this, "settings", "addInChatWindow")) { let usertype = this.getUserType(e.instance.props.message.author); - if (usertype) this.injectOwnerTag(e.returnvalue.props.children[2].props.children, e.instance.props.message.author, usertype, e.instance.props.compact ? 0 : 2, e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy); + if (usertype) { + let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue.props.children.slice(1), {name: "Popout"}); + if (index > -1) this.injectOwnerTag(children, e.instance.props.message.author, usertype, e.instance.props.compact ? 0 : 2, e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy); + } } } diff --git a/Plugins/PersonalPins/PersonalPins.plugin.js b/Plugins/PersonalPins/PersonalPins.plugin.js index bde7beb8e8..a0219d6672 100644 --- a/Plugins/PersonalPins/PersonalPins.plugin.js +++ b/Plugins/PersonalPins/PersonalPins.plugin.js @@ -374,7 +374,7 @@ var PersonalPins = (_ => { messages = messages.filter(messagedata => messagedata.channel_id == currentchannel.id); break; case "server": - messages = messages.filter(messagedata => messagedata.guild_id == (currentchannel.guild_id || "@me")); + messages = messages.filter(messagedata => messagedata.guild_id == (currentchannel.guild_id || BDFDB.DiscordConstants.ME)); break; case "allservers": messages = messages; @@ -500,7 +500,7 @@ var PersonalPins = (_ => { if (!message) return; let notes = BDFDB.DataUtils.load(this, "notes"); channel = channel || BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id); - let guild_id = channel.guild_id || "@me"; + let guild_id = channel.guild_id || BDFDB.DiscordConstants.ME; notes[guild_id] = notes[guild_id] || {}; notes[guild_id][channel.id] = notes[guild_id][channel.id] || {} if (!notes[guild_id][channel.id][message.id]) { @@ -525,7 +525,7 @@ var PersonalPins = (_ => { getNoteData (message, channel) { if (!message) return; channel = channel || BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id); - let guild_id = channel.guild_id || "@me"; + let guild_id = channel.guild_id || BDFDB.DiscordConstants.ME; let notes = BDFDB.DataUtils.load(this, "notes"); return notes[guild_id] && notes[guild_id][channel.id] && notes[guild_id][channel.id][message.id]; } @@ -534,7 +534,7 @@ var PersonalPins = (_ => { let message = JSON.parse(note.message); let channel = JSON.parse(note.channel); if (!message || !channel) return; - let guild_id = channel.guild_id || "@me"; + let guild_id = channel.guild_id || BDFDB.DiscordConstants.ME; let notes = BDFDB.DataUtils.load(this, "notes"); notes[guild_id][channel.id][note.id].message = JSON.stringify(newmessage); BDFDB.DataUtils.save(notes, this, "notes"); @@ -545,7 +545,7 @@ var PersonalPins = (_ => { let message = JSON.parse(note.message); let channel = JSON.parse(note.channel); if (!message || !channel) return; - let guild_id = channel.guild_id || "@me"; + let guild_id = channel.guild_id || BDFDB.DiscordConstants.ME; let notes = BDFDB.DataUtils.load(this, "notes"); delete notes[guild_id][channel.id][note.id]; if (BDFDB.ObjectUtils.isEmpty(notes[guild_id][channel.id])) {