-
Notifications
You must be signed in to change notification settings - Fork 1
/
slack-senders.js
33 lines (29 loc) · 1 KB
/
slack-senders.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
const helpers = require('./helpers.js')
const lookupPackOfCardsBySet = require('./card-lookups').lookupPackOfCardsBySet
const renderListOfCards = require('./renderers').renderListOfCards
const sendDraftToEachPlayer = draftPlayerList => {
console.log('players: ' + draftPlayerList)
draftPlayerList.forEach(function (player) {
player = strip(player)
const set = 'SCG'
// const DMSender
const renderedListOfCards = lookupPackOfCardsBySet(set)
.then(renderListOfCards)
Promise.all([renderedListOfCards, helpers.getUserList()])
.then(values => {
console.log('Cards rendered and member list fetched')
const DMChannel = helpers.makeDMSender(values, player)
.then(json => { console.log(json) })
})
})
}
const getIdByName = (memberList, name) => {
const result = memberList.filter(function (o) { return o['name'] == name; })['id']
return result
}
const strip = (str) => {
return str.replace(/^\s+|\s+$/g, '');
}
module.exports = {
sendDraftToEachPlayer
}