chore: merge branch dev
to main
#200
4 changed files with 34 additions and 12 deletions
|
@ -13,6 +13,7 @@ import {
|
|||
discord_limit_autocompletion_list_length,
|
||||
discord_limit_autocompletion_value_length,
|
||||
} from "../../utils/constants";
|
||||
import { timeToString } from "../../utils/time";
|
||||
|
||||
export default {
|
||||
scope: () => [],
|
||||
|
@ -179,12 +180,19 @@ export default {
|
|||
queue.node.play();
|
||||
}
|
||||
|
||||
// TODO: When added to an existing queue (size of queue > 0):
|
||||
// - Add position in queue
|
||||
// - Add estimated time until playing
|
||||
// https://git.mylloon.fr/ConfrerieDuKassoulait/Botanique/issues/184
|
||||
const positionEstimation = () => {
|
||||
const pos = queue.node.getTrackPosition(result.tracks[0]) + 1;
|
||||
|
||||
if (pos === 0) {
|
||||
return loc.get("c_play_sub2_name");
|
||||
}
|
||||
|
||||
return `${loc.get("c_play10")} ${pos} (${loc.get("c_play11")} ≈${estimation})`;
|
||||
};
|
||||
const estimation = timeToString(queue.estimatedDuration);
|
||||
|
||||
return await interaction.followUp({
|
||||
content: `⏱️ | \`${title}\` ${loc.get("c_play5")}.`,
|
||||
content: `⏱️ | \`${title}\` ${loc.get("c_play5")}, ${loc.get("c_play12")} : ${positionEstimation()}.`,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -96,6 +96,9 @@
|
|||
"c_play7": "Currently playing",
|
||||
"c_play8": "Asked by",
|
||||
"c_play9": "No results were found",
|
||||
"c_play10": "position",
|
||||
"c_play11": "estimation",
|
||||
"c_play12": "play",
|
||||
|
||||
"c_stop_name": "stop",
|
||||
"c_stop_desc": "Stop the music",
|
||||
|
|
|
@ -96,6 +96,9 @@
|
|||
"c_play7": "Joue actuellement",
|
||||
"c_play8": "Demandé par",
|
||||
"c_play9": "Aucun résultat trouvé",
|
||||
"c_play10": "position",
|
||||
"c_play11": "estimation",
|
||||
"c_play12": "joue",
|
||||
|
||||
"c_stop_name": "stop",
|
||||
"c_stop_desc": "Stop la musique",
|
||||
|
|
|
@ -94,14 +94,12 @@ export const strToSeconds = (time: string) => {
|
|||
};
|
||||
|
||||
/**
|
||||
* Calculating the difference between a date and now
|
||||
* @param lang Locale
|
||||
* @param time Time
|
||||
* @returns Delta between the time and now
|
||||
* Returns the time in a readable way
|
||||
* @param seconds Time in milliseconds
|
||||
* @returns Time as string
|
||||
*/
|
||||
export const timeDeltaToString = (time: number) => {
|
||||
const now = Date.now();
|
||||
let secondsDifference = Math.abs(Math.ceil((time - now) / 1000));
|
||||
export const timeToString = (time: number) => {
|
||||
let secondsDifference = Math.abs(Math.ceil(time / 1000));
|
||||
|
||||
if (secondsDifference === 0) {
|
||||
return "0s";
|
||||
|
@ -123,3 +121,13 @@ export const timeDeltaToString = (time: number) => {
|
|||
.filter(Boolean)
|
||||
.join(" ");
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculating the difference between a date and now
|
||||
* @param time Time in milliseconds
|
||||
* @returns Delta between the time and now
|
||||
*/
|
||||
export const timeDeltaToString = (time: number) => {
|
||||
const now = Date.now();
|
||||
return timeToString(time - now);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue