Use link API for Neopia in time

This commit is contained in:
Daniel Odendahl Jr
2018-09-20 17:02:31 +00:00
parent 2fcb14888a
commit fabf577ed8
+2 -6
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command');
const moment = require('moment-timezone');
const { firstUpperCase } = require('../../util/Util');
moment.tz.link('America/Vancouver|Neopia');
module.exports = class TimeCommand extends Command {
constructor(client) {
@@ -24,16 +25,11 @@ module.exports = class TimeCommand extends Command {
}
run(msg, { timeZone }) {
let neopia = false;
if (timeZone === 'neopia') {
timeZone = 'america/vancouver';
neopia = true;
}
if (!moment.tz.zone(timeZone)) {
return msg.reply('Invalid time zone. Refer to <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>.');
}
const time = moment().tz(timeZone).format('hh:mm:ss A');
const location = neopia ? ['neopia'] : timeZone.split('/');
const location = timeZone.split('/');
const main = firstUpperCase(location[0], /[_ ]/);
const sub = location[1] ? firstUpperCase(location[1], /[_ ]/) : null;
const subMain = location[2] ? firstUpperCase(location[2], /[_ ]/) : null;