-
Notifications
You must be signed in to change notification settings - Fork 9
/
hackPack.js
44 lines (40 loc) · 1.03 KB
/
hackPack.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
import { getInfoForUser, transcript, airFind, airCreate } from '../../utils'
export const names = [
'Hack Pack',
'github student developer pack',
'github pack',
'sdp',
'github sdp',
]
export const details = 'Available for club leaders to give their members'
export async function run(bot, message) {
const { user } = message
const { leader, club } = await getInfoForUser(user)
if (!leader || !club) {
await bot.replyPrivateDelayed(
message,
transcript('promos.githubSDP.notAuthorized')
)
return
}
const findPackReferrer = await airFind(
'Sources',
'Name',
club.fields['Name'],
{ base: 'sdp' }
)
const newRecordFields = {
Name: club.fields['Name'],
Notes: `Airtable club id: ${club.id}`,
Type: 'Hack Club',
}
const packReferrer =
findPackReferrer ||
(await airCreate('Sources', newRecordFields, { base: 'sdp' }))
await bot.replyPrivateDelayed(
message,
transcript('promos.githubSDP.success', {
referrer: packReferrer.fields['Name'],
})
)
}