presence: inline time

This commit is contained in:
Cynthia Foxwell 2025-05-01 21:44:03 -06:00
parent 6dcddd5011
commit 3fe77473f1
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -227,18 +227,15 @@ presence.callback = async function (msg, line) {
const timeEnd = formatTime(length); const timeEnd = formatTime(length);
const timePos = formatTime(position); const timePos = formatTime(position);
const numBarChars = NOWPLAYING_BAR_LENGTH - timePos.length - timeEnd.length - 2;
const progress = position >= length ? 1 : position / length; const progress = position >= length ? 1 : position / length;
const barLength = Math.round(progress * NOWPLAYING_BAR_LENGTH); const barLength = Math.round(progress * numBarChars);
const bar = `\`\`\`ansi\n${NOWPLAYING_BAR_CHAR.repeat(barLength)}\x1b[30m${NOWPLAYING_BAR_CHAR.repeat(
NOWPLAYING_BAR_LENGTH - barLength
)}\x1b[39m`;
const time = `${timePos}${" ".repeat(
NOWPLAYING_BAR_LENGTH - timePos.length - timeEnd.length
)}${timeEnd}\`\`\``;
const bar = `\`\`\`ansi\n${timePos} ${NOWPLAYING_BAR_CHAR.repeat(
barLength
)}\x1b[30m${NOWPLAYING_BAR_CHAR.repeat(numBarChars - barLength)}\x1b[39m ${timeEnd}`;
descLines.push(bar); descLines.push(bar);
descLines.push(time);
} }
} }