diff --git a/src/builtins/appearance/coloredtext.js b/src/builtins/appearance/coloredtext.js index 69c17298..8d1275b8 100644 --- a/src/builtins/appearance/coloredtext.js +++ b/src/builtins/appearance/coloredtext.js @@ -1,5 +1,5 @@ import Builtin from "../../structs/builtin"; -import {WebpackModules} from "modules"; +import {WebpackModules, DiscordModules} from "modules"; @@ -26,9 +26,10 @@ export default new class ColoredText extends Builtin { const originalType = messageContent.type.type; if (originalType.__originalMethod) return; // Don't patch again - messageContent.type.type = function(childProps) { + const self = this; + messageContent.type.type = function (childProps) { const returnValue = originalType(childProps); - const roleColor = childProps.message.colorString || ""; + const roleColor = self.getRoleColor(childProps.message.channel_id, childProps.message.author.id) || ""; returnValue.props.style = {color: roleColor}; return returnValue; }; @@ -38,9 +39,17 @@ export default new class ColoredText extends Builtin { }); } + getRoleColor(channelId, memberId) { + const channel = DiscordModules.ChannelStore.getChannel(channelId); + if (!channel) return ""; + const member = DiscordModules.GuildMemberStore.getMember(channel.guild_id, memberId); + if (!member) return ""; + return member.colorString; + } + removeColoredText() { document.querySelectorAll(".markup-2BOw-j").forEach(elem => { elem.style.setProperty("color", ""); }); } -}; \ No newline at end of file +}; diff --git a/src/modules/discordmodules.js b/src/modules/discordmodules.js index 759146fe..bf05d36a 100644 --- a/src/modules/discordmodules.js +++ b/src/modules/discordmodules.js @@ -28,7 +28,7 @@ export default Utilities.memoizeObject({ get GuildPermissions() {return WebpackModules.getByProps("getGuildPermissions");}, /* Channel Store & Actions */ - get ChannelStore() {return WebpackModules.getByProps("getChannels", "getDMFromUserId");}, + get ChannelStore() {return WebpackModules.getByProps("getChannel", "getDMFromUserId");}, get SelectedChannelStore() {return WebpackModules.getByProps("getLastSelectedChannelId");}, get ChannelActions() {return WebpackModules.getByProps("selectChannel");}, get PrivateChannelActions() {return WebpackModules.getByProps("openPrivateChannel");}, @@ -153,4 +153,4 @@ export default Utilities.memoizeObject({ }, get LayerStack() {return WebpackModules.getByProps("pushLayer");} -}); \ No newline at end of file +});