diff --git a/src/Player.js b/src/Player.js index 4fd8145..58cc220 100644 --- a/src/Player.js +++ b/src/Player.js @@ -74,7 +74,7 @@ class Player { this.queues = this.queues.filter((g) => g.guildID !== voiceChannel.id); return new Promise(async (resolve, reject) => { // Searches the song - let video = await Util.getFirstYoutubeResult(songName, this.SYA).catch(() => {}); + let video = await Util.getFirstYoutubeResult(songName, this.SYA); if(!video) reject('Song not found'); // Joins the voice channel let connection = await voiceChannel.join(); diff --git a/src/Util.js b/src/Util.js index 1181de0..f6b41f5 100644 --- a/src/Util.js +++ b/src/Util.js @@ -17,17 +17,21 @@ class Util { return new Promise(async (resolve, reject) => { search = search.replace(/<(.+)>/g, "$1"); // Try with URL - let video = await SYA.getVideo(search).catch(() => {}); - if(video){ - video = await video.fetch() + SYA.getVideo(search).then(async (video) => { + video = await video.fetch(); resolve(video); - } - // Try with song name - let results = await SYA.searchVideos(search, 1); - if(results.length < 1) reject('Not found'); - let fetched = await results.shift().fetch(); - results.push(fetched) - resolve(results.pop()); + }).catch(async (err) => { + if(err.message === "Bad Request"){ + reject('Invalid Youtube Data v3 API key.'); + } else { + // Try with song name + let results = await SYA.searchVideos(search, 1); + if(results.length < 1) return reject('Not found'); + let fetched = await results.shift().fetch(); + results.push(fetched); + resolve(results.pop()); + } + }); }); }