From 1e100b5055af00677d11f7610d21434927669ba3 Mon Sep 17 00:00:00 2001 From: nin0dev Date: Thu, 8 Aug 2024 14:44:13 -0400 Subject: [PATCH] added user data --- index.tsx | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/index.tsx b/index.tsx index 154981e..55f9ad4 100644 --- a/index.tsx +++ b/index.tsx @@ -53,8 +53,8 @@ async function getMessage(channelId: string, messageId: string): Promise { - // powered by generative ai, idk react :trolley: const [data, setData] = useState([]); + const [collapsed, collapse] = useState(true); useEffect(() => { const fetchData = async () => { @@ -81,14 +81,34 @@ const UserData = () => { return ( <> - { - data && data.map(user => <> -
- {/* @ts-ignore */} - {Parser.parse(`<@${user.id}>`)} with {user.count} husks -
- ) - } + User stats { collapsed ? collapse(false) : collapse(true); }}>[{collapsed ? "View all" : "Collapse"}] +
+ { + data && data.map(user => <> + { + collapsed && <> + { + data.indexOf(user) < 6 && +
+ {/* @ts-ignore */} + {Parser.parse(`<@${user.id}>`)} with {user.count} {user.count > 1 ? "husks" : "husk"} +
+ } + + } + { + !collapsed && <> + { +
+ {/* @ts-ignore */} + {Parser.parse(`<@${user.id}>`)} with {user.count} {user.count > 1 ? "husks" : "husk"} +
+ } + + } + ) + } +
); }; @@ -99,6 +119,7 @@ export default definePlugin({ flux: { async MESSAGE_REACTION_ADD(event) { try { + if (event.userId === "428188716641812481") return; const msg = await getMessage(event.channelId, event.messageId); if (msg!.author.id !== UserStore.getCurrentUser().id) return; if (!event.emoji.name.includes("husk")) return; @@ -121,7 +142,7 @@ export default definePlugin({ description: "User stats", component: (aaa) => ( <> - User stats + )