Fixes Colored Text for development branch (#531)

* Fix colored text for development branch too.

* Fix ChannelStore
This commit is contained in:
Strencher 2021-02-05 23:51:54 +01:00 committed by GitHub
parent 1bb613942f
commit 99270038b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import Builtin from "../../structs/builtin"; 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; const originalType = messageContent.type.type;
if (originalType.__originalMethod) return; // Don't patch again if (originalType.__originalMethod) return; // Don't patch again
const self = this;
messageContent.type.type = function (childProps) { messageContent.type.type = function (childProps) {
const returnValue = originalType(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}; returnValue.props.style = {color: roleColor};
return returnValue; return returnValue;
}; };
@ -38,6 +39,14 @@ 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() { removeColoredText() {
document.querySelectorAll(".markup-2BOw-j").forEach(elem => { document.querySelectorAll(".markup-2BOw-j").forEach(elem => {
elem.style.setProperty("color", ""); elem.style.setProperty("color", "");

View File

@ -28,7 +28,7 @@ export default Utilities.memoizeObject({
get GuildPermissions() {return WebpackModules.getByProps("getGuildPermissions");}, get GuildPermissions() {return WebpackModules.getByProps("getGuildPermissions");},
/* Channel Store & Actions */ /* Channel Store & Actions */
get ChannelStore() {return WebpackModules.getByProps("getChannels", "getDMFromUserId");}, get ChannelStore() {return WebpackModules.getByProps("getChannel", "getDMFromUserId");},
get SelectedChannelStore() {return WebpackModules.getByProps("getLastSelectedChannelId");}, get SelectedChannelStore() {return WebpackModules.getByProps("getLastSelectedChannelId");},
get ChannelActions() {return WebpackModules.getByProps("selectChannel");}, get ChannelActions() {return WebpackModules.getByProps("selectChannel");},
get PrivateChannelActions() {return WebpackModules.getByProps("openPrivateChannel");}, get PrivateChannelActions() {return WebpackModules.getByProps("openPrivateChannel");},