presence: inline time
This commit is contained in:
parent
6dcddd5011
commit
3fe77473f1
1 changed files with 6 additions and 9 deletions
|
@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue