ThemeAttributes: add data-author-username to messages (#2422)

This commit is contained in:
Overcast Warmth System 2024-05-12 06:57:48 +10:00 committed by GitHub
parent 2eb8ba1841
commit 9b328da4ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -15,6 +15,7 @@ This allows themes to more easily theme those elements or even do things that ot
### Chat Messages ### Chat Messages
- `data-author-id` contains the id of the author - `data-author-id` contains the id of the author
- `data-author-username` contains the username of the author
- `data-is-self` is a boolean indicating whether this is the current user's message - `data-is-self` is a boolean indicating whether this is the current user's message
![image](https://github.com/Vendicated/Vencord/assets/45497981/34bd5053-3381-402f-82b2-9c812cc7e122) ![image](https://github.com/Vendicated/Vencord/assets/45497981/34bd5053-3381-402f-82b2-9c812cc7e122)

View file

@ -36,10 +36,12 @@ export default definePlugin({
], ],
getMessageProps(props: { message: Message; }) { getMessageProps(props: { message: Message; }) {
const authorId = props.message?.author?.id; const author = props.message?.author;
const authorId = author?.id;
return { return {
"data-author-id": authorId, "data-author-id": authorId,
"data-is-self": authorId && authorId === UserStore.getCurrentUser()?.id "data-author-username": author?.username,
"data-is-self": authorId && authorId === UserStore.getCurrentUser()?.id,
}; };
} }
}); });