-
Notifications
You must be signed in to change notification settings - Fork 9
/
meetingRemove.js
41 lines (34 loc) · 1.07 KB
/
meetingRemove.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 { getInfoForUser, transcript, airPatch } from '../utils'
const interactionMeetingRemove = async (bot, message) => {
const { user, text } = message
try {
const { leader, club, history } = await getInfoForUser(user)
if (text.trim == 'help' || text.trim == '') {
bot.replyPrivateDelayed(message, transcript('meetingRemove.help'))
return
}
if (!leader) {
throw new Error('This command can only be run by club leaders')
}
if (!club) {
throw new Error('No club found')
}
const meeting = history.meetings.find(h => h.id === text)
if (meeting) {
airPatch('History', meeting.id, { 'Deleted At': Date.now() }).then(
_record => {
bot.replyPrivateDelayed(
message,
transcript('meetingRemove.success')
)
}
)
} else {
bot.replyPrivateDelayed(message, transcript('meetingRemove.help'))
}
} catch (err) {
console.error(err)
bot.replyPrivateDelayed(message, transcript('errors.general', { err }))
}
}
export default interactionMeetingRemove