diff --git a/src/Player.js b/src/Player.js index df432ba..372e13a 100644 --- a/src/Player.js +++ b/src/Player.js @@ -94,7 +94,7 @@ class Player { play(voiceChannel, songName) { this.queues = this.queues.filter((g) => g.guildID !== voiceChannel.id); return new Promise(async (resolve, reject) => { - if(typeof voiceChannel !== VoiceChannel) return reject("voiceChannel must be type of VoiceChannel. value="+voiceChannel); + if(!voiceChannel || typeof voiceChannel !== "object") return reject("voiceChannel must be type of VoiceChannel. value="+voiceChannel); if(typeof songName !== "string") return reject("songName must be type of string. value="+songName); // Searches the song let video = await Util.getFirstYoutubeResult(songName, this.SYA); diff --git a/src/Util.js b/src/Util.js index db8fc5f..683c198 100644 --- a/src/Util.js +++ b/src/Util.js @@ -25,12 +25,20 @@ class Util { 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()); + try { + // 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()); + } catch(err){ + if(err.message === "Bad Request"){ + reject('Invalid Youtube Data v3 API key.'); + } else { + reject(err); + } + } } }); });