Validating that there actually is songs in the channel

This commit is contained in:
Kasper Rynning-Tønnesen
2019-01-30 13:42:18 +01:00
committed by GitHub
parent b7eeefa634
commit 4589299f52

View File

@@ -299,7 +299,7 @@ function change_song(coll, error, id, conf, callback, socket) {
}, { }, {
$limit:2 $limit:2
}], function(err, now_playing_doc){ }], function(err, now_playing_doc){
if((id && id == now_playing_doc[0].id) || !id) { if(now_playing_doc.length > 0 && ((id && id == now_playing_doc[0].id) || !id)) {
if(error && now_playing_doc[0].source == "youtube"){ if(error && now_playing_doc[0].source == "youtube"){
request('http://img.youtube.com/vi/'+now_playing_doc[0].id+'/mqdefault.jpg', function (err, response, body) { request('http://img.youtube.com/vi/'+now_playing_doc[0].id+'/mqdefault.jpg', function (err, response, body) {
if (err || response.statusCode == 404) { if (err || response.statusCode == 404) {
@@ -362,7 +362,7 @@ function change_song(coll, error, id, conf, callback, socket) {
} }
} }
} else { } else {
if(now_playing_doc[0].now_playing == true && now_playing_doc.length > 1 && now_playing_doc[1].id == id) { if(now_playing_doc.length > 0 && now_playing_doc[0].now_playing == true && now_playing_doc.length > 1 && now_playing_doc[1].id == id) {
db.collection(coll).update({id: now_playing_doc[0].id}, {$set: {now_playing: false}}, function(e, d) { db.collection(coll).update({id: now_playing_doc[0].id}, {$set: {now_playing: false}}, function(e, d) {
change_song(coll, error, id, conf, callback, socket); change_song(coll, error, id, conf, callback, socket);
}) })