1+ import type { APIRole , APIUser , Snowflake } from "discord-api-types/v10" ;
12import * as React from "react" ;
23import type { ComponentProps } from "react" ;
34import { useMemo } from "react" ;
5+ import { useTranslation } from "react-i18next" ;
46import ChatTag from "../ChatTag" ;
5- import RoleIcon from "./RoleIcon" ;
6- import getAvatar from "../utils/getAvatar" ;
7- import * as Styles from "./style/author" ;
8- import type { APIRole , APIUser , Snowflake } from "discord-api-types/v10" ;
97import { useConfig } from "../core/ConfigContext" ;
8+ import getAvatar from "../utils/getAvatar" ;
109import getDisplayName from "../utils/getDisplayName" ;
11- import { useTranslation } from "react-i18next" ;
10+ import RoleIcon from "./RoleIcon" ;
11+ import * as Styles from "./style/author" ;
1212
1313interface AutomodAuthorProps {
1414 isAvatarAnimated ?: boolean ;
@@ -96,14 +96,19 @@ function MessageAuthor({
9696 return color > 0 ? `#${ color . toString ( 16 ) . padStart ( 6 , "0" ) } ` : undefined ;
9797 } , [ isGuildMember , resolveRole , member ] ) ;
9898
99+ const clickable = userOnClick !== undefined ;
100+
99101 if ( onlyShowUsername ) {
100102 return (
101103 < Styles . MessageAuthor
102- clickable = { userOnClick !== undefined }
104+ clickable = { clickable }
103105 { ...props }
104106 onClick = { ( e ) => userOnClick ?.( author , e . currentTarget ) }
105107 >
106- < Styles . Username style = { { color : dominantRoleColor } } >
108+ < Styles . Username
109+ clickable = { clickable }
110+ style = { { color : dominantRoleColor } }
111+ >
107112 { displayName }
108113 </ Styles . Username >
109114 </ Styles . MessageAuthor >
@@ -112,7 +117,7 @@ function MessageAuthor({
112117
113118 return (
114119 < Styles . MessageAuthor
115- clickable = { userOnClick !== undefined }
120+ clickable = { clickable }
116121 { ...props }
117122 onClick = { ( e ) => userOnClick ?.( author , e . currentTarget ) }
118123 >
@@ -150,9 +155,13 @@ function MessageAuthor({
150155 </ Styles . AnimatedAvatar >
151156 ) }
152157 </ Styles . AnimatedAvatarTrigger >
153- < Styles . Username style = { { color : dominantRoleColor } } >
158+ < Styles . Username
159+ clickable = { clickable }
160+ style = { { color : dominantRoleColor } }
161+ >
154162 { displayName }
155163 </ Styles . Username >
164+
156165 { dominantRoleIconRole !== null && (
157166 < RoleIcon role = { dominantRoleIconRole } />
158167 ) }
0 commit comments