Fixed durations

This commit is contained in:
Essem 2021-08-06 15:39:04 -05:00
parent dea160c73b
commit f2ace6ee52
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
6 changed files with 54 additions and 31 deletions

View file

@ -1,13 +1,11 @@
const { version } = require("../../package.json");
const day = require("dayjs");
day.extend(require("dayjs/plugin/duration"));
const os = require("os");
const Command = require("../../classes/command.js");
class StatsCommand extends Command {
async run() {
const duration = day.duration(this.client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
const uptime = day.duration(process.uptime(), "seconds").format(" D [days], H [hrs], m [mins], s [secs]");
const uptime = process.uptime();
const connUptime = this.client.uptime;
const owner = await this.ipc.fetchUser(process.env.OWNER);
const stats = await this.ipc.getStats();
return {
@ -34,11 +32,11 @@ class StatsCommand extends Command {
},
{
"name": "Bot Uptime",
"value": uptime
"value": `${Math.trunc(uptime / 86400000)} days, ${Math.trunc(uptime / 3600000) % 24} hrs, ${Math.trunc(uptime / 60000) % 60} mins, ${Math.trunc(uptime / 1000) % 60} secs`
},
{
"name": "Connection Uptime",
"value": duration
"value": `${Math.trunc(connUptime / 86400000)} days, ${Math.trunc(connUptime / 3600000) % 24} hrs, ${Math.trunc(connUptime / 60000) % 60} mins, ${Math.trunc(connUptime / 1000) % 60} secs`
},
{
"name": "Host",

View file

@ -1,7 +1,5 @@
const fetch = require("node-fetch");
const day = require("dayjs");
const duration = require("dayjs/plugin/duration");
day.extend(duration);
const format = require("format-duration");
const MusicCommand = require("../../classes/musicCommand.js");
class NowPlayingCommand extends MusicCommand {
@ -36,7 +34,7 @@ class NowPlayingCommand extends MusicCommand {
},
{
"name": `${"▬".repeat(parts)}🔘${"▬".repeat(10 - parts)}`,
"value": `${day.duration(player.state.position).format("m:ss", { trim: false })}/${track.isStream ? "∞" : day.duration(track.length).format("m:ss", { trim: false })}`
"value": `${format(player.state.position)}/${track.isStream ? "∞" : format(track.length)}`
}]
}
};

View file

@ -1,8 +1,6 @@
const soundPlayer = require("../../utils/soundplayer.js");
const fetch = require("node-fetch");
const day = require("dayjs");
const duration = require("dayjs/plugin/duration");
day.extend(duration);
const format = require("format-duration");
const paginator = require("../../utils/pagination/pagination.js");
const MusicCommand = require("../../classes/musicCommand.js");
@ -21,7 +19,7 @@ class QueueCommand extends MusicCommand {
const trackList = [];
const firstTrack = tracks.shift();
for (const [i, track] of tracks.entries()) {
trackList.push(`${i + 1}. ${track.info.author} - **${track.info.title}** (${track.info.isStream ? "∞" : day.duration(track.info.length).format("m:ss", { trim: false })})`);
trackList.push(`${i + 1}. ${track.info.author} - **${track.info.title}** (${track.info.isStream ? "∞" : format(track.info.length)})`);
}
const pageSize = 5;
const embeds = [];
@ -42,7 +40,7 @@ class QueueCommand extends MusicCommand {
},
"fields": [{
"name": "🎶 Now Playing",
"value": `${firstTrack.info.author} - **${firstTrack.info.title}** (${firstTrack.info.isStream ? "∞" : day.duration(firstTrack.info.length).format("m:ss", { trim: false })})`
"value": `${firstTrack.info.author} - **${firstTrack.info.title}** (${firstTrack.info.isStream ? "∞" : format(firstTrack.info.length)})`
}, {
"name": "🔁 Looping?",
"value": player.loop ? "Yes" : "No"

53
package-lock.json generated
View file

@ -11,12 +11,12 @@
"dependencies": {
"@top-gg/sdk": "^3.1.1",
"cowsay2": "^2.0.4",
"dayjs": "^1.10.4",
"dotenv": "^9.0.2",
"emoji-regex": "^9.2.2",
"eris": "^0.15.1",
"eris-fleet": "github:esmBot/eris-fleet",
"file-type": "^16.1.0",
"format-duration": "^1.4.0",
"jsqr": "^1.3.1",
"lavacord": "^1.1.9",
"node-addon-api": "^3.2.1",
@ -564,6 +564,11 @@
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/add-zero": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/add-zero/-/add-zero-1.0.0.tgz",
"integrity": "sha1-iOIhaWcX9m20Z2cvP5qgBN6fGiw="
},
"node_modules/ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
@ -1054,11 +1059,6 @@
"node": ">= 8"
}
},
"node_modules/dayjs": {
"version": "1.10.6",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.6.tgz",
"integrity": "sha512-AztC/IOW4L1Q41A86phW5Thhcrco3xuAA+YX/BLpLWWjRcTj5TOt/QImBLmCKlrF7u7k47arTnOyL6GnbG8Hvw=="
},
"node_modules/debug": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
@ -1682,6 +1682,15 @@
"resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz",
"integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
},
"node_modules/format-duration": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/format-duration/-/format-duration-1.4.0.tgz",
"integrity": "sha512-Mcg3hOAiKxo6JRBgfrQ+sbVvr3D9/4wE7eDQXx3WV2d/yKmrcHXHJS4OhrqVeg+iiFE2Op+pHhdOkQUl8yIclw==",
"dependencies": {
"add-zero": "^1.0.0",
"parse-ms": "^1.0.1"
}
},
"node_modules/fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
@ -2419,6 +2428,14 @@
"node": ">=6"
}
},
"node_modules/parse-ms": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-1.0.1.tgz",
"integrity": "sha1-VjRtR0nXjyNDDKDHE4UK75GqNh0=",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/path-exists": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
@ -4044,6 +4061,11 @@
"dev": true,
"requires": {}
},
"add-zero": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/add-zero/-/add-zero-1.0.0.tgz",
"integrity": "sha1-iOIhaWcX9m20Z2cvP5qgBN6fGiw="
},
"ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
@ -4432,11 +4454,6 @@
"which": "^2.0.1"
}
},
"dayjs": {
"version": "1.10.6",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.6.tgz",
"integrity": "sha512-AztC/IOW4L1Q41A86phW5Thhcrco3xuAA+YX/BLpLWWjRcTj5TOt/QImBLmCKlrF7u7k47arTnOyL6GnbG8Hvw=="
},
"debug": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
@ -4904,6 +4921,15 @@
"resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz",
"integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
},
"format-duration": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/format-duration/-/format-duration-1.4.0.tgz",
"integrity": "sha512-Mcg3hOAiKxo6JRBgfrQ+sbVvr3D9/4wE7eDQXx3WV2d/yKmrcHXHJS4OhrqVeg+iiFE2Op+pHhdOkQUl8yIclw==",
"requires": {
"add-zero": "^1.0.0",
"parse-ms": "^1.0.1"
}
},
"fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
@ -5478,6 +5504,11 @@
"callsites": "^3.0.0"
}
},
"parse-ms": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-1.0.1.tgz",
"integrity": "sha1-VjRtR0nXjyNDDKDHE4UK75GqNh0="
},
"path-exists": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",

View file

@ -26,12 +26,12 @@
"dependencies": {
"@top-gg/sdk": "^3.1.1",
"cowsay2": "^2.0.4",
"dayjs": "^1.10.4",
"dotenv": "^9.0.2",
"emoji-regex": "^9.2.2",
"eris": "^0.15.1",
"eris-fleet": "github:esmBot/eris-fleet",
"file-type": "^16.1.0",
"format-duration": "^1.4.0",
"jsqr": "^1.3.1",
"lavacord": "^1.1.9",
"node-addon-api": "^3.2.1",

View file

@ -1,9 +1,7 @@
const logger = require("./logger.js");
const fetch = require("node-fetch");
const fs = require("fs");
const day = require("dayjs");
const duration = require("dayjs/plugin/duration");
day.extend(duration);
const format = require("format-duration");
const { Manager } = require("lavacord");
let nodes;
@ -121,7 +119,7 @@ exports.nextSong = async (client, message, connection, track, info, music, voice
},
{
"name": `${"▬".repeat(parts)}🔘${"▬".repeat(10 - parts)}`,
"value": `${day.duration(0).format("m:ss", { trim: false })}/${info.isStream ? "∞" : day.duration(info.length).format("m:ss", { trim: false })}`
"value": `0:00/${info.isStream ? "∞" : format(info.length)}`
}]
}
});