From 325615fe7d21653770a107b3aed03af7be8220b0 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 20 Sep 2018 20:21:05 +0000 Subject: [PATCH] Fix time trimming --- commands/events/days-until.js | 7 ++++--- commands/events/neko-atsume-password.js | 2 +- commands/util/info.js | 2 +- package.json | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/commands/events/days-until.js b/commands/events/days-until.js index 0a9130fb..96bf2f32 100644 --- a/commands/events/days-until.js +++ b/commands/events/days-until.js @@ -31,8 +31,9 @@ module.exports = class DaysUntilCommand extends Command { let year = now.getMonth() + 1 <= month ? now.getFullYear() : now.getFullYear() + 1; if (month === now.getMonth() + 1 && now.getDate() >= day) ++year; const future = new Date(`${month}/${day}/${year}`); - const time = moment.duration(future - now).format('M [months and] d [days]'); - if (time === 'Invalid date') return msg.reply('Invalid date.'); - return msg.say(`There are ${time} until ${moment.utc(future).format('dddd, MMMM Do, YYYY')}!`); + const futureFormat = moment.utc(future).format('dddd, MMMM Do, YYYY'); + const time = moment.duration(future - now); + const link = time.months() === 1 ? 'is' : 'are'; + return msg.say(`There ${link} ${time.format('M [months and] d [days]')} until ${futureFormat}!`); } }; diff --git a/commands/events/neko-atsume-password.js b/commands/events/neko-atsume-password.js index 08d28025..18ec20cc 100644 --- a/commands/events/neko-atsume-password.js +++ b/commands/events/neko-atsume-password.js @@ -33,7 +33,7 @@ module.exports = class NekoAtsumePasswordCommand extends Command { const data = await this.fetchPassword(locale); return msg.say(stripIndents` The current Neko Atsume password is **${data.password}**. - It will expire in **${moment.duration(data.expires - data.date).format('hh:mm:ss')}**. + It will expire in **${moment.duration(data.expires - data.date).format('hh:mm:ss', { trim: false })}**. ${data.gold} ${this.goldFish} ${data.silver} ${this.silverFish} `); diff --git a/commands/util/info.js b/commands/util/info.js index e26e52c8..07987fd7 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -30,7 +30,7 @@ module.exports = class InfoCommand extends Command { .addField('❯ Source Code', source ? `[Here](https://github.com/${XIAO_GITHUB_REPO_USERNAME}/${XIAO_GITHUB_REPO_NAME})` : 'N/A', true) .addField('❯ Memory Usage', `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`, true) - .addField('❯ Uptime', moment.duration(this.client.uptime).format('hh:mm:ss'), true) + .addField('❯ Uptime', moment.duration(this.client.uptime).format('hh:mm:ss', { trim: false }), true) .addField('❯ Version', `v${version}`, true) .addField('❯ Node Version', process.version, true) .addField('❯ Dependencies', this.parseDependencies()); diff --git a/package.json b/package.json index 201e3340..7fdc4a29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "91.8.9", + "version": "91.8.10", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {