-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsendVolunteersNearAddress.js
51 lines (47 loc) · 1.49 KB
/
sendVolunteersNearAddress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { bot, token } = require("./bot");
const { volunteerWithCustomFields } = require("../volunteerWithCustomFields");
const {
getSection,
getVolunteerHeading,
getVolunteers,
getCopyPasteNumbers,
} = require("./message");
/**
* @param {Array} volunteersWithDistance An array of objects of the closest volunteers to the
* address, with distance from the address
* @param {string} user ID of the user who initiated the slash command
* @returns {void}
*/
const sendVolunteersNearAddress = async (volunteersWithDistance, user) => {
const volunteers = volunteersWithDistance.map((v) =>
volunteerWithCustomFields(v)
);
const nums = getCopyPasteNumbers(volunteers);
await bot.chat.postMessage({
token,
channel: user,
text: "Volunteers found!",
blocks: [
getVolunteerHeading(volunteers),
...getVolunteers(volunteers),
getSection("*And here are their numbers for easy copy/pasting:*"),
getSection(nums),
],
});
};
/**
* @param {string} user ID of the user who initiated the slash command
* @returns {void}
*/
const sendVolunteersNearAddressHelp = async (user) => {
await bot.chat.postMessage({
token,
channel: user,
text:
"This slash command takes an address and responds with nearby volunteers, just like when a new ticket is created. For example, try copy pasting the following into slack:\n\n `/volunteer-near 35-33 29th Street 11106`",
});
};
module.exports = {
sendVolunteersNearAddress,
sendVolunteersNearAddressHelp,
};