handle error

This commit is contained in:
Loic Bersier 2018-11-20 19:47:54 +01:00
parent 4571b2a641
commit d2ce8049de

View file

@ -33,10 +33,14 @@ module.exports = class downloadCommand extends Command {
}) })
let video = youtubedl(link, [`--username=${fbuser}`,`--password=${fbpasswd}`]) let video = youtubedl(link, [`--username=${fbuser}`,`--password=${fbpasswd}`])
video.pipe(fs.createWriteStream('video.mp4')) video.pipe(fs.createWriteStream('video.mp4'))
video.on('error', function error(err) {
console.log('error 2:', err);
message.say("An error has occured, i can't download from the link you provided.")
});
video.on('end', function() { video.on('end', function() {
message.delete(); message.delete();
message.channel.send(`Downloaded by ${message.author.username}`, {files: ["./video.mp4"]}) message.channel.send(`Downloaded by ${message.author.username}`, {files: ["./video.mp4"]})
.catch(error => message.say('An error has occured, the file might be too big or i cant download the link you provided')) .catch(error => message.say('File too big'))
}) })
} else } else
message.say("You need to input a valid link") message.say("You need to input a valid link")