From 9b328da4ce2363fa0e9e2fc24795d09597df1ab7 Mon Sep 17 00:00:00 2001 From: Overcast Warmth System <110815694+OvercastWarmth@users.noreply.github.com> Date: Sun, 12 May 2024 06:57:48 +1000 Subject: [PATCH] ThemeAttributes: add data-author-username to messages (#2422) --- src/plugins/themeAttributes/README.md | 1 + src/plugins/themeAttributes/index.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/themeAttributes/README.md b/src/plugins/themeAttributes/README.md index 110eca57..87cb803c 100644 --- a/src/plugins/themeAttributes/README.md +++ b/src/plugins/themeAttributes/README.md @@ -15,6 +15,7 @@ This allows themes to more easily theme those elements or even do things that ot ### Chat Messages - `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 ![image](https://github.com/Vendicated/Vencord/assets/45497981/34bd5053-3381-402f-82b2-9c812cc7e122) diff --git a/src/plugins/themeAttributes/index.ts b/src/plugins/themeAttributes/index.ts index 8afc2121..b8ceac62 100644 --- a/src/plugins/themeAttributes/index.ts +++ b/src/plugins/themeAttributes/index.ts @@ -36,10 +36,12 @@ export default definePlugin({ ], getMessageProps(props: { message: Message; }) { - const authorId = props.message?.author?.id; + const author = props.message?.author; + const authorId = author?.id; return { "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, }; } });