Blame last.fm if there is an error
This commit is contained in:
parent
a8575f6f25
commit
8b012829c1
1 changed files with 11 additions and 1 deletions
|
@ -22,7 +22,13 @@ module.exports = async function(userID, guild) {
|
|||
.then(response => response.json())
|
||||
.then(data => {
|
||||
let scrobble = {};
|
||||
let track = data.recenttracks.track[0];
|
||||
let track;
|
||||
try {
|
||||
track = data.recenttracks.track[0];
|
||||
} catch (error) {
|
||||
scrobble.error = true;
|
||||
resolve(scrobble);
|
||||
}
|
||||
scrobble.artist = track.artist["#text"];
|
||||
scrobble.song = track.name;
|
||||
scrobble.album = track.album["#text"];
|
||||
|
@ -38,6 +44,10 @@ module.exports = async function(userID, guild) {
|
|||
reject(error);
|
||||
});
|
||||
});
|
||||
if(scrobble.error){
|
||||
sendText.text = "Last.fm is probably having problems. Try again later.";
|
||||
return sendText;
|
||||
}
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setAuthor(`Now playing - ${nickname}`, user.user.avatarURL({ dynamic: true, size: 4096 }))
|
||||
.setThumbnail(scrobble.cover)
|
||||
|
|
Loading…
Add table
Reference in a new issue