message.channel.send('An error has occured, I can\'t download from the link you provided.');
});
video.on('info',asyncfunction(info){
letduration=info.duration;
if(duration){
duration=duration.replace(/:/g,'');
if(duration>500){
video.pause();
video.unpipe();
loadingmsg.delete();
returnmessage.channel.send('Can\'t download video longer than 5 minutes');
}
}
console.log('Download started');
console.log('filename: '+info._filename);
console.log('size: '+info.size);
//Compress vid if bigger than 8MB
if(fileSize>8){
console.log('file bigger than 8MB');
letcompressmsg=awaitmessage.channel.send('Video bigger than 8MB compressing now <a:loadingmin:527579785212329984> (This can take a long time!)\nWant it to go faster? Donate to the dev with the donate command, so i can get a better server and do it faster!');
returnmessage.channel.send('An error has occured while compressing the video');
});
handbrake.on('progress',progress=>{
console.log(
'Percent complete: %s, ETA: %s',
progress.percentComplete,
progress.eta
);
});
handbrake.on('end',asyncfunction(){
message.delete();
compressmsg.delete();
returnmessage.channel.send(`Downloaded by ${message.author.username}`,{files:[`${os.tmpdir()}/${fileName}compressed.mp4`]})
.catch(err=>{
console.error(err);
compressmsg.delete();
returnmessage.channel.send('File too big');
});
});
}else{
console.log('file smaller than 8MB');
message.delete();
message.delete();
loadingmsg.delete();
loadingmsg.delete();
returnmessage.channel.send(`Downloaded by ${message.author.username}`,{files:[`${os.tmpdir()}/${fileName}.mp4`]})
returnmessage.channel.send(`Downloaded by ${message.author.username}`,{files:[`${os.tmpdir()}/${fileName}.mp4`]})
.catch(err=>{
.catch(err=>{
console.error(err);
console.error(err);
loadingmsg.delete();
loadingmsg.delete();
returnmessage.channel.send('File too big');
returnmessage.channel.send('File too big');
});
});
}
}
letcompressmsg=awaitmessage.channel.send('Video bigger than 8MB compressing now <a:loadingmin:527579785212329984> (This can take a long time!)\nWant it to go faster? Donate to the dev with the donate command, so i can get a better server and do it faster!');