added user data

This commit is contained in:
nin0dev 2024-08-08 14:44:13 -04:00
parent f9e7a2fc92
commit 1e100b5055

View file

@ -53,8 +53,8 @@ async function getMessage(channelId: string, messageId: string): Promise<Message
} }
} }
const UserData = () => { const UserData = () => {
// powered by generative ai, idk react :trolley:
const [data, setData] = useState([]); const [data, setData] = useState([]);
const [collapsed, collapse] = useState(true);
useEffect(() => { useEffect(() => {
const fetchData = async () => { const fetchData = async () => {
@ -81,14 +81,34 @@ const UserData = () => {
return ( return (
<> <>
{ <Forms.FormText style={{ fontSize: "1.07rem", fontWeight: "500" }}>User stats <a onClick={() => { collapsed ? collapse(false) : collapse(true); }}>[{collapsed ? "View all" : "Collapse"}]</a></Forms.FormText>
data && data.map(user => <> <div style={{ display: "grid", gridTemplateColumns: "auto auto" }}>
<div> {
{/* @ts-ignore */} data && data.map(user => <>
{Parser.parse(`<@${user.id}>`)} <Forms.FormText>with {user.count} husks</Forms.FormText> {
</div> collapsed && <>
</>) {
} data.indexOf(user) < 6 &&
<div style={{ marginTop: data.indexOf(user) < 2 ? "0" : "7px" }}>
{/* @ts-ignore */}
{Parser.parse(`<@${user.id}>`)} <Forms.FormText style={{ marginTop: "4px" }}>with {user.count} {user.count > 1 ? "husks" : "husk"}</Forms.FormText>
</div>
}
</>
}
{
!collapsed && <>
{
<div style={{ marginTop: data.indexOf(user) < 2 ? "0" : "7px" }}>
{/* @ts-ignore */}
{Parser.parse(`<@${user.id}>`)} <Forms.FormText style={{ marginTop: "4px" }}>with {user.count} {user.count > 1 ? "husks" : "husk"}</Forms.FormText>
</div>
}
</>
}
</>)
}
</div>
</> </>
); );
}; };
@ -99,6 +119,7 @@ export default definePlugin({
flux: { flux: {
async MESSAGE_REACTION_ADD(event) { async MESSAGE_REACTION_ADD(event) {
try { try {
if (event.userId === "428188716641812481") return;
const msg = await getMessage(event.channelId, event.messageId); const msg = await getMessage(event.channelId, event.messageId);
if (msg!.author.id !== UserStore.getCurrentUser().id) return; if (msg!.author.id !== UserStore.getCurrentUser().id) return;
if (!event.emoji.name.includes("husk")) return; if (!event.emoji.name.includes("husk")) return;
@ -121,7 +142,7 @@ export default definePlugin({
description: "User stats", description: "User stats",
component: (aaa) => ( component: (aaa) => (
<> <>
<Forms.FormText style={{ fontSize: "1.07rem", fontWeight: "500" }}>User stats</Forms.FormText>
<UserData /> <UserData />
</> </>
) )