utility.presence: fix timestamps
This commit is contained in:
parent
c87d1e1422
commit
147e1d5028
1 changed files with 25 additions and 23 deletions
|
@ -754,33 +754,35 @@ presence.callback = async function (msg, line) {
|
||||||
if (activity.state) descLines.push(activity.state);
|
if (activity.state) descLines.push(activity.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.timestamps.start && !activity.timestamps.end) {
|
if (activity.timestamps) {
|
||||||
descLines.push(
|
if (activity.timestamps.start && !activity.timestamps.end) {
|
||||||
formatTime(Date.now() - activity.timestamps.start) + " elapsed"
|
descLines.push(
|
||||||
);
|
formatTime(Date.now() - activity.timestamps.start) + " elapsed"
|
||||||
} else if (!activity.timestamps.start && activity.timestamps.end) {
|
);
|
||||||
descLines.push(
|
} else if (!activity.timestamps.start && activity.timestamps.end) {
|
||||||
formatTime(activity.timestamps.end - Date.now()) + " remaining"
|
descLines.push(
|
||||||
);
|
formatTime(activity.timestamps.end - Date.now()) + " remaining"
|
||||||
} else {
|
);
|
||||||
const position = Date.now() - activity.timestamps.start;
|
} else {
|
||||||
const length = activity.timestamps.end - activity.timestamps.start;
|
const position = Date.now() - activity.timestamps.start;
|
||||||
|
const length = activity.timestamps.end - activity.timestamps.start;
|
||||||
|
|
||||||
const timeEnd = formatTime(length);
|
const timeEnd = formatTime(length);
|
||||||
const timePos = formatTime(position);
|
const timePos = formatTime(position);
|
||||||
|
|
||||||
const progress = position / length;
|
const progress = position / length;
|
||||||
const barLength = Math.round(progress * NOWPLAYING_BAR_LENGTH);
|
const barLength = Math.round(progress * NOWPLAYING_BAR_LENGTH);
|
||||||
|
|
||||||
const bar = `\`[${"=".repeat(barLength)}${" ".repeat(
|
const bar = `\`[${"=".repeat(barLength)}${" ".repeat(
|
||||||
NOWPLAYING_BAR_LENGTH - barLength
|
NOWPLAYING_BAR_LENGTH - barLength
|
||||||
)}]\``;
|
)}]\``;
|
||||||
const time = `\`${timePos}${" ".repeat(
|
const time = `\`${timePos}${" ".repeat(
|
||||||
NOWPLAYING_BAR_LENGTH + 2 - timePos.length - timeEnd.length
|
NOWPLAYING_BAR_LENGTH + 2 - timePos.length - timeEnd.length
|
||||||
)}${timeEnd}\``;
|
)}${timeEnd}\``;
|
||||||
|
|
||||||
descLines.push(bar);
|
descLines.push(bar);
|
||||||
descLines.push(time);
|
descLines.push(time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
embed.description = descLines.join("\n");
|
embed.description = descLines.join("\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue