Fix duration not changing in fmtt

This commit is contained in:
SileNce5k 2024-04-08 12:09:56 +02:00
parent 7bd728a16e
commit 60580483ec
No known key found for this signature in database
GPG key ID: 961132EB78C8915F

View file

@ -23,6 +23,27 @@ module.exports = async function (userID, option) {
if(option[0] === undefined)
option[0] = options[option[0]];
let duration = "";
switch (option[0]){
case "overall":
duration = "all time";
break;
case "7day":
duration = "weekly";
break;
case "1month":
duration = "monthly";
break;
case "3month":
duration = "quarterly";
break;
case "6month":
duration = "half year";
break;
case "12month":
duration = "yearly";
break;
}
const apiKey = process.env.LAST_FM_API_KEY;
if(lastfmUsername != undefined){
tracks = await new Promise ((resolve, reject) => {
@ -44,7 +65,7 @@ module.exports = async function (userID, option) {
reject(error);
});
});
sendText = `Top weekly tracks for ${lastfmUsername}:\n`;
sendText = `Top ${duration} tracks for ${lastfmUsername}:\n`;
for(let i = 0; i < tracks.length; i++){
sendText += `${i}. ${tracks[i].artist} - ${tracks[i].song} (${tracks[i].playcount} plays)\n`;
}