fix: RoleColorEverywhere (#1884)

Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
redstonekasi 2023-10-26 00:56:39 +02:00 committed by GitHub
parent 6b28e5ad85
commit 9eaeb24196
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,10 +49,10 @@ export default definePlugin({
patches: [
// Chat Mentions
{
find: 'className:"mention"',
find: "CLYDE_AI_MENTION_COLOR:null,",
replacement: [
{
match: /user:(\i),channel:(\i).{0,300}?"@"\.concat\(.+?\)/,
match: /user:(\i),channel:(\i).{0,400}?"@"\.concat\(.+?\)/,
replace: "$&,color:$self.getUserColor($1?.id,{channelId:$2?.id})"
}
],
@ -60,37 +60,34 @@ export default definePlugin({
},
// Slate
{
// taken from CommandsAPI
find: ".source,children",
find: ".userTooltip,children",
replacement: [
{
match: /function \i\((\i)\).{5,20}id.{5,20}guildId.{5,10}channelId.{100,150}hidePersonalInformation.{5,50}jsx.{5,20},{/,
replace: "$&color:$self.getUserColor($1.id,{guildId:$1?.guildId}),"
match: /let\{id:(\i),guildId:(\i)[^}]*\}.*?\.default,{(?=children)/,
replace: "$&color:$self.getUserColor($1,{guildId:$2}),"
}
],
predicate: () => settings.store.chatMentions,
},
// Member List Role Names
{
find: ".memberGroupsPlaceholder",
find: 'tutorialId:"whos-online',
replacement: [
{
match: /(memo\(\(function\((\i)\).{300,500}CHANNEL_MEMBERS_A11Y_LABEL.{100,200}roleIcon.{5,20}null,).," \u2014 ",.\]/,
replace: "$1$self.roleGroupColor($2)]"
match: /\i.roleIcon,\.\.\.\i/,
replace: "$&,color:$self.roleGroupColor(arguments[0])"
},
{
match: /children:\[.," \u2014 ",.\]/,
replace: "children:[$self.roleGroupColor(arguments[0])]"
match: /null,\i," — ",\i\]/,
replace: "null,$self.roleGroupColor(arguments[0])]"
},
],
predicate: () => settings.store.memberList,
},
// Voice chat users
{
find: "renderPrioritySpeaker",
replacement: [
{
match: /renderName=function\(\).{50,75}speaking.{50,100}jsx.{5,10}{/,
match: /renderName\(\).{0,100}speaking:.{50,100}jsx.{5,10}{/,
replace: "$&...$self.getVoiceProps(this.props),"
}
],
@ -113,11 +110,15 @@ export default definePlugin({
const guild = GuildStore.getGuild(guildId);
const role = guild?.roles[id];
return <span style={{
color: role?.colorString,
fontWeight: "unset",
letterSpacing: ".05em"
}}>{title ?? label} &mdash; {count}</span>;
return (
<span style={{
color: role?.colorString,
fontWeight: "unset",
letterSpacing: ".05em"
}}>
{title ?? label} &mdash; {count}
</span>
);
},
getVoiceProps({ user: { id: userId }, guildId }: { user: { id: string; }; guildId: string; }) {