From 772559a2f3a3aeab92b9f0420e0bc9375d779792 Mon Sep 17 00:00:00 2001 From: Matthew Stanciu Date: Tue, 17 Nov 2020 16:19:53 -0500 Subject: [PATCH 1/2] Add /countstatus command --- api/app.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api/app.js b/api/app.js index a87ad02..343a139 100644 --- a/api/app.js +++ b/api/app.js @@ -201,6 +201,20 @@ app.event('message', async (body) => { } }); +app.command('/countstatus', async ({ command, ack, respond }) => { + await ack() + const { text, user_id } = command + const channel = 'CDJMS683D' + + let oldest = await fetchOldest(channel); + let latest = await fetchLatest(channel); + + await respond({ + text: `The day's current progress is *${latest - oldest}*!`, + response_type: 'ephemeral' + }) +}); + (async (req, res) => { // Start your app try { From 77b854ab4f7e57b988941020a5403ba9b4d9edd5 Mon Sep 17 00:00:00 2001 From: Matthew Stanciu Date: Tue, 17 Nov 2020 16:24:12 -0500 Subject: [PATCH 2/2] clean up --- api/app.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/app.js b/api/app.js index 343a139..7f2f6c6 100644 --- a/api/app.js +++ b/api/app.js @@ -203,11 +203,10 @@ app.event('message', async (body) => { app.command('/countstatus', async ({ command, ack, respond }) => { await ack() - const { text, user_id } = command const channel = 'CDJMS683D' - let oldest = await fetchOldest(channel); - let latest = await fetchLatest(channel); + let oldest = await fetchOldest(channel) + let latest = await fetchLatest(channel) await respond({ text: `The day's current progress is *${latest - oldest}*!`,