From f13ea3d034cef415a7356e4d05e88eea58e3ff50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Harper?= Date: Mon, 14 Aug 2023 17:08:53 -0400 Subject: [PATCH] add a cancel button to not send message to some folks --- index.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a8c0ebc..fdf0a47 100644 --- a/index.js +++ b/index.js @@ -56,6 +56,16 @@ const welcomeMessagePart2 = process.env.WELCOME_PART2; style: 'primary', action_id: 'welcome_new_user', value: event.user.id + ',' + event.user.real_name + }, + { + type: 'button', + text: { + type: 'plain_text', + text: 'Nope' + }, + style: 'primary', + action_id: 'cancel', + value: event.user.real_name } ] } @@ -68,7 +78,6 @@ const welcomeMessagePart2 = process.env.WELCOME_PART2; // Listen to welcome_new_user app.action('welcome_new_user', async ({ action, ack, respond }) => { - // ack(); const newUser = action.value.split(','); @@ -98,6 +107,19 @@ const welcomeMessagePart2 = process.env.WELCOME_PART2; } }); + // Listen to cancelling + app.action('cancel', async ({ action, ack, respond }) => { + + try { + respond({ + text: 'Message *not* sent to ' + action.value, + replace_original: true + }); + } catch (error) { + console.error(error); + } + }); + // Test app.message('fredisawesome', async ({ message, say }) => { say('Hello');