diff --git a/commands/games/apples-to-apples.js b/commands/games/apples-to-apples.js index f3795e21..34f438df 100644 --- a/commands/games/apples-to-apples.js +++ b/commands/games/apples-to-apples.js @@ -38,7 +38,7 @@ module.exports = class ApplesToApplesCommand extends Command { return msg.say('Game could not be started...'); } const players = await this.generatePlayers(awaitedPlayers); - let czars = Array.from(players.values()); + const czars = Array.from(players.values()); let winner = null; while (!winner) { const czar = czars[0]; diff --git a/commands/search/vocaloid.js b/commands/search/vocaloid.js index 131a80e4..77c24107 100644 --- a/commands/search/vocaloid.js +++ b/commands/search/vocaloid.js @@ -1,7 +1,7 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { shorten, duration } = require('../../util/Util'); +const { shorten } = require('../../util/Util'); module.exports = class VocaloidCommand extends Command { constructor(client) { @@ -36,7 +36,6 @@ module.exports = class VocaloidCommand extends Command { }); if (!body.items.length) return msg.say('Could not find any results.'); const data = body.items[0]; - const { minutes, seconds } = duration(data.lengthSeconds * 1000); const embed = new MessageEmbed() .setColor(0x86D2D0) .setAuthor('VocaDB', 'https://i.imgur.com/6QwraDT.jpg') @@ -47,9 +46,7 @@ module.exports = class VocaloidCommand extends Command { .addField('❯ Artist', data.artistString) .addField('❯ Publish Date', - new Date(data.publishDate).toDateString(), true) - .addField('❯ Length', - `${minutes}:${seconds}`, true); + new Date(data.publishDate).toDateString(), true); return msg.embed(embed); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/util/info.js b/commands/util/info.js index 1779b0fd..53a4e9cb 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -31,7 +31,7 @@ module.exports = class InfoCommand extends Command { .addField('❯ Memory Usage', `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`, true) .addField('❯ Uptime', - duration(this.client.uptime).format(), true) + duration(this.client.uptime), true) .addField('❯ Version', `v${version}`, true) .addField('❯ Node Version', diff --git a/commands/util/uptime.js b/commands/util/uptime.js index 773fd4f6..982f53fb 100644 --- a/commands/util/uptime.js +++ b/commands/util/uptime.js @@ -13,6 +13,6 @@ module.exports = class UptimeCommand extends Command { } run(msg) { - return msg.say(duration(this.client.uptime).format()); + return msg.say(duration(this.client.uptime)); } }; diff --git a/package.json b/package.json index 8858f530..41463736 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "id-length": "off", "no-await-in-loop": "off", "no-console": "off", - "no-process-env": "off" + "no-process-env": "off", + "prefer-const": "error" } } } diff --git a/util/Util.js b/util/Util.js index 19dc878d..b6d4192e 100644 --- a/util/Util.js +++ b/util/Util.js @@ -32,15 +32,10 @@ class Util { } static duration(ms) { - const sec = Math.floor((ms / 1000) % 60); - const min = Math.floor((ms / (1000 * 60)) % 60); - const hrs = Math.floor(ms / (1000 * 60 * 60)); - return { - hours: hrs, - minutes: min, - seconds: sec, - format: () => `${hrs < 10 ? `0${hrs}` : hrs}:${min < 10 ? `0${min}` : min}:${sec < 10 ? `0${sec}` : sec}` - }; + const sec = Math.floor((ms / 1000) % 60).toString(); + const min = Math.floor((ms / (1000 * 60)) % 60).toString(); + const hrs = Math.floor(ms / (1000 * 60 * 60)).toString(); + return `${hrs.padStart(2, '0')}:${min.padStart(2, '0')}:${sec.padStart(2, '0')}`; } static randomRange(min, max) {