From ea3c27f3fc2f2688aaf4244b533a1b66d0ccdd3f Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Sat, 25 Jul 2020 11:59:16 +0200 Subject: [PATCH] :zap: Use promises instead of callbacks for ytsr --- src/Player.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Player.js b/src/Player.js index 978c4ce..5e8607d 100644 --- a/src/Player.js +++ b/src/Player.js @@ -203,11 +203,12 @@ class Player { if (matchYoutubeURL) { query = matchYoutubeURL[1] } - ytsr(query, (err, results) => { + ytsr(query).then((results) => { if (results.items.length < 1) return resolve([]) - if (err) return resolve([]) const resultsVideo = results.items.filter((i) => i.type === 'video') resolve(allResults ? resultsVideo.map((r) => new Track(r, null, null)) : [new Track(resultsVideo[0], null, null)]) + }).catch(() => { + return resolve([]) }) }) }