-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeadline.js
28 lines (23 loc) · 878 Bytes
/
deadline.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
const { Command } = require('discord.js-commando')
const _ = require('lodash')
const moment = require('moment-timezone')
const fplapi = require('./../../fpl/api')
module.exports = class DeadlineCommand extends Command {
constructor(client) {
super(client, {
group: 'fpl',
name: 'deadline',
memberName: 'deadline',
description: 'Get the current week\'s deadline',
})
}
run(message) {
const timezone = process.env.BOT_TIMEZONE
fplapi.events().then((weeks) => {
let week = _.filter(weeks, function (week) {
return (week.is_current && !week.finished) || week.is_next
})[0]
return message.channel.send(`Game Week ${week.id} Deadline: ${moment(week.deadline_time).tz(timezone).format('h:mm A DD MMM YYYY')}`)
})
}
}