From cb0a64a6aef08c160e68216dc7d38e6ec1f1ad92 Mon Sep 17 00:00:00 2001 From: "zeon-neon[bot]" <136533918+zeon-neon[bot]@users.noreply.github.com> Date: Sun, 6 Apr 2025 01:59:49 +0000 Subject: [PATCH] enhancement(lint): Fix lint errors for src/modules/howWasYourDay.ts Co-authored-by: NeonGamerBot-QK Signed-off-by: zeon-neon[bot] <136533918+zeon-neon[bot]@users.noreply.github.com> --- src/modules/howWasYourDay.ts | 53 +++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/modules/howWasYourDay.ts b/src/modules/howWasYourDay.ts index 6ce989a..e53cd4f 100644 --- a/src/modules/howWasYourDay.ts +++ b/src/modules/howWasYourDay.ts @@ -133,8 +133,8 @@ export async function getMessageCount(db: JSONdb) { const message = `${emoji} <@${process.env.MY_USER_ID}> has sent *${messagesSent} messages* today.${differenceText}`; await db.set("messages_sent_yesterday", messagesSent); const messagesTotal = (await db.get("messages_total")) || []; - messagesTotal.push(messagesSent) - await db.set("messages_total", messagesTotal) + messagesTotal.push(messagesSent); + await db.set("messages_total", messagesTotal); return message; } @@ -194,31 +194,34 @@ export default async function (app: ModifiedApp, channel = `C07R8DYAZMM`) { thread_ts: mobj.ts, text: await getMessageCount(app.db), }); - if(app.db.get("messages_total") && app.db.get("messages_total").length >= 7){ + if ( + app.db.get("messages_total") && + app.db.get("messages_total").length >= 7 + ) { // send weekly graph to channel - sendWeeklyGraph(app, channel) + sendWeeklyGraph(app, channel); } } -export async function sendWeeklyGraph(app: ModifiedApp, channel:string) { - const messagesTotal = app.db.get("messages_total").slice(0,7) - const graphUrl = `https://api.saahild.com/api/graph/line/simple?labels=Monday,Tuesday,Wensday,Thursday,Friday,Saturday,Sunday&y=${messagesTotal.join(",")}` -// attach as file or something -await fetch(graphUrl) -.then((r) => r.arrayBuffer()) -.then(Buffer.from) -.then((d) => { - writeFileSync(path.join(__dirname, "..", "graph.png"), d); -}); -const img = path.join(__dirname, "..", "graph.png"); -await app.client.files.uploadV2({ -file: img, -filename: `graph.png`, -// thread_ts: mobj.ts, -channel_id: channel, -alt_text: `Your weekly message graph.`, -initial_comment: `Your weekly message graph! Average message count per day is *${(messagesTotal.reduce((a, b) => a + b, 0) / messagesTotal.length).toFixed(2)}*`, -}); +export async function sendWeeklyGraph(app: ModifiedApp, channel: string) { + const messagesTotal = app.db.get("messages_total").slice(0, 7); + const graphUrl = `https://api.saahild.com/api/graph/line/simple?labels=Monday,Tuesday,Wensday,Thursday,Friday,Saturday,Sunday&y=${messagesTotal.join(",")}`; + // attach as file or something + await fetch(graphUrl) + .then((r) => r.arrayBuffer()) + .then(Buffer.from) + .then((d) => { + writeFileSync(path.join(__dirname, "..", "graph.png"), d); + }); + const img = path.join(__dirname, "..", "graph.png"); + await app.client.files.uploadV2({ + file: img, + filename: `graph.png`, + // thread_ts: mobj.ts, + channel_id: channel, + alt_text: `Your weekly message graph.`, + initial_comment: `Your weekly message graph! Average message count per day is *${(messagesTotal.reduce((a, b) => a + b, 0) / messagesTotal.length).toFixed(2)}*`, + }); -app.db.set("messages_total", []) -} \ No newline at end of file + app.db.set("messages_total", []); +}