diff --git a/commands/music/music/nowplaying.js b/commands/music/music/nowplaying.js index b9f3b190..769c3282 100644 --- a/commands/music/music/nowplaying.js +++ b/commands/music/music/nowplaying.js @@ -1,5 +1,5 @@ -import format from "format-duration"; import MusicCommand from "#cmd-classes/musicCommand.js"; +import { formatDuration } from "#utils/misc.js"; class MusicNowPlayingCommand extends MusicCommand { async run() { @@ -44,7 +44,7 @@ class MusicNowPlayingCommand extends MusicCommand { }, { name: `${"▬".repeat(parts)}🔘${"▬".repeat(10 - parts)}`, - value: `${format(player.position)}/${track.info.isStream ? "∞" : format(track.info.length)}`, + value: `${formatDuration(player.position)}/${track.info.isStream ? "∞" : formatDuration(track.info.length)}`, }, ], }, diff --git a/commands/music/music/queue.js b/commands/music/music/queue.js index d4120f04..688126e5 100644 --- a/commands/music/music/queue.js +++ b/commands/music/music/queue.js @@ -1,6 +1,6 @@ -import format from "format-duration"; import MusicCommand from "#cmd-classes/musicCommand.js"; import paginator from "#pagination"; +import { formatDuration } from "#utils/misc.js"; class MusicQueueCommand extends MusicCommand { async run() { @@ -17,7 +17,7 @@ class MusicQueueCommand extends MusicCommand { if (!firstTrack) return this.getString("sound.notPlaying"); for (const [i, track] of tracks.entries()) { trackList.push( - `${i + 1}. ${track.info.author !== "" ? track.info.author : this.getString("sound.blank")} - **${track.info.title !== "" ? track.info.title : this.getString("sound.blank")}** (${track.info.isStream ? "∞" : format(track.info.length)})`, + `${i + 1}. ${track.info.author !== "" ? track.info.author : this.getString("sound.blank")} - **${track.info.title !== "" ? track.info.title : this.getString("sound.blank")}** (${track.info.isStream ? "∞" : formatDuration(track.info.length)})`, ); } const pageSize = 5; @@ -49,7 +49,7 @@ class MusicQueueCommand extends MusicCommand { fields: [ { name: `🎶 ${this.getString("sound.nowPlaying")}`, - value: `${firstTrack.info.author !== "" ? firstTrack.info.author : this.getString("sound.blank")} - **${firstTrack.info.title !== "" ? firstTrack.info.title : this.getString("sound.blank")}** (${firstTrack.info.isStream ? "∞" : format(firstTrack.info.length)})`, + value: `${firstTrack.info.author !== "" ? firstTrack.info.author : this.getString("sound.blank")} - **${firstTrack.info.title !== "" ? firstTrack.info.title : this.getString("sound.blank")}** (${firstTrack.info.isStream ? "∞" : formatDuration(firstTrack.info.length)})`, }, { name: `🔁 ${this.getString("sound.looping")}`, diff --git a/package.json b/package.json index 35eb9cec..300c19d1 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,6 @@ "bufferutil": "^4.1.0", "dotenv": "^17.4.2", "file-type": "^22.0.1", - "format-duration": "^3.0.2", "ipaddr.js": "^2.4.0", "node-addon-api": "^8.8.0", "oceanic.js": "1.14.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 680672d5..0850ee31 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,9 +17,6 @@ importers: file-type: specifier: ^22.0.1 version: 22.0.1 - format-duration: - specifier: ^3.0.2 - version: 3.0.2 ipaddr.js: specifier: ^2.4.0 version: 2.4.0 @@ -476,9 +473,6 @@ packages: fn.name@1.1.0: resolution: {integrity: sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==} - format-duration@3.0.2: - resolution: {integrity: sha512-pKzJDSRgK2lqAiPW3uizDaIJaJnataZclsahz25UMwfdryBGDa+1HlbXGjzpMvX/2kMh4O0sNevFXKaEfCjHsA==} - fs-extra@11.3.3: resolution: {integrity: sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==} engines: {node: '>=14.14'} @@ -1011,8 +1005,6 @@ snapshots: fn.name@1.1.0: {} - format-duration@3.0.2: {} - fs-extra@11.3.3: dependencies: graceful-fs: 4.2.11 diff --git a/src/utils/misc.ts b/src/utils/misc.ts index bd8508db..40314e54 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -291,3 +291,9 @@ export function maxFileSize(guild: Guild | null) { } return fileSize; } + +export function formatDuration(ms: number) { + const days = Math.floor(ms / 86400000); + const initDuration = new Date(ms).toISOString().slice(11, 19); + return (days ? days + ":" : "") + initDuration; +} diff --git a/src/utils/soundplayer.ts b/src/utils/soundplayer.ts index 9cd662cd..fbb691bb 100644 --- a/src/utils/soundplayer.ts +++ b/src/utils/soundplayer.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import process from "node:process"; import { setTimeout } from "node:timers/promises"; -import format from "format-duration"; import { type AnyVoiceChannel, type Client, @@ -25,6 +24,7 @@ import { } from "shoukaku"; import { getString } from "./i18n.ts"; import logger from "./logger.ts"; +import { formatDuration } from "./misc.ts"; export type SoundPlayer = { player: Player; @@ -252,7 +252,7 @@ export async function nextSong( }, { name: `🔘${"▬".repeat(10)}`, - value: `0:00/${info?.isStream ? "∞" : format(info?.length ?? 0)}`, + value: `00:00:00/${info?.isStream ? "∞" : formatDuration(info?.length ?? 0)}`, }, ], },