Add artist count check to getTopArtists
All checks were successful
CI / CI (push) Successful in 22s

This commit is contained in:
SileNce5k 2025-09-07 07:49:10 +02:00
commit 69872ba0d1
Signed by: SileNce
GPG key ID: B0A142BB4291B204

View file

@ -77,7 +77,8 @@ module.exports = async function (userID, option, guild, compatibility=false) {
fetch(`https://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=${lastfmUsername}&period=${option[0]}&api_key=${process.env.LAST_FM_API_KEY}&format=json`)
.then(response => response.json())
.then(data => {
for(let i = 0; i < 10; i++){
const maxIterations = data.topartists.artist.length >= 10 ? 10 : data.topartists.artist.length;
for(let i = 0; i < maxIterations; i++){
let artist = {}
let currentArtist = data.topartists.artist[i];
artist.name = currentArtist.name;