-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmeetingList.js
41 lines (34 loc) · 1.13 KB
/
meetingList.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
import humanizeDuration from 'humanize-duration'
import { parseDate } from 'chrono-node'
import { getInfoForUser } from '../utils'
const interactionMeetingList = (bot, message) => {
getInfoForUser(message.user).then(({ leader, club, history }) => {
let reply = ''
if (history.meetings && history.meetings.length > 0) {
reply = history.meetings
.map(
h =>
`- \`${h.id}\` On *${h.fields['Date']}* _(${humanizeDuration(
Date.now() - parseDate(h.fields['Date']),
{
largest: 1,
}
)} ago)_, with *${h.fields['Attendance']} attendees*`
)
.join('\n')
}
if (history.meetings && history.meetings.length === 0) {
reply = `:warning: No meetings recorded for ${club.fields['Name']}`
}
if (!leader || !club) {
reply =
":warning: This command can only be run by club leaders. You aren't registered as a club leader."
}
bot.replyPrivateDelayed(message, reply, (err, response) => {
if (err) {
console.error(err)
}
})
})
}
export default interactionMeetingList