From 444af32deff3e57c79d6b3ae6891e24b62f6ff69 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Mon, 8 Apr 2024 12:50:41 +0200 Subject: [PATCH] Check if user is not found --- util/lastfm/getCurrentScrobble.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/lastfm/getCurrentScrobble.js b/util/lastfm/getCurrentScrobble.js index 61653ed..b285af4 100644 --- a/util/lastfm/getCurrentScrobble.js +++ b/util/lastfm/getCurrentScrobble.js @@ -27,13 +27,17 @@ module.exports = async function(userID, guild) { track = data.recenttracks.track[0]; } catch (error) { scrobble.error = true; + if(data.message === "User not found"){ + scrobble.errorMsg = "User not found. Use `fm set ` to set your last.fm username."; + resolve(scrobble); + } + scrobble.errorMsg = "Last.fm is probably having problems. Try again later."; resolve(scrobble); } scrobble.artist = track.artist["#text"]; scrobble.song = track.name; scrobble.album = track.album["#text"]; scrobble.cover = track.image[3]["#text"]; - console.log(typeof track['@attr'].nowplaying); if(track['@attr'].nowplaying === "true"){ isCurrentScrobble = "Last"; } @@ -44,7 +48,7 @@ module.exports = async function(userID, guild) { reject(error); }); }); - if(scrobble.error){ + if(scrobble.error != null){ sendText.text = "Last.fm is probably having problems. Try again later."; return sendText; }