Skip to content

Commit

Permalink
add a cancel button to not send message to some folks
Browse files Browse the repository at this point in the history
  • Loading branch information
fharper committed Aug 14, 2023
1 parent dc4e6bf commit f13ea3d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
Expand All @@ -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(',');

Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit f13ea3d

Please sign in to comment.