@ -90,6 +89,7 @@ class DownloadCommand extends Command {
if(duration>500){
video.pause();
video.unpipe();
loadingmsg.delete();
returnmessage.channel.send('Can\'t download video longer than 5 minutes');
}
}
@ -103,16 +103,20 @@ class DownloadCommand extends Command {
needCompress=true;
}
});
video.on('end',function(){
video.on('end',asyncfunction(){
if(!needCompress){
message.delete();
loadingmsg.delete();
returnmessage.channel.send(`Downloaded by ${message.author.username}`,{files:[`${os.tmpdir()}/${fileName}.mp4`]})
.catch(err=>{
console.error(err);
loadingmsg.delete();
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!');
@ -121,15 +125,10 @@ class DownloadCommand extends Command {
//Compress vid if bigger than 8MB
lethandbrake=hbjs.spawn(options);
handbrake.on('start',function(){
message.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!').then(msg=>{
handbrake.on('end',asyncfunction(){
awaitmsg.delete();
});
});
});
handbrake.on('error',err=>{
console.error(err);
loadingmsg.delete();
compressmsg.delete();
returnmessage.channel.send('An error has occured while compressing the video');
});
handbrake.on('progress',progress=>{
@ -139,11 +138,15 @@ class DownloadCommand extends Command {
progress.eta
);
});
handbrake.on('end',function(){
handbrake.on('end',asyncfunction(){
message.delete();
loadingmsg.delete();
compressmsg.delete();
returnmessage.channel.send(`Downloaded by ${message.author.username}`,{files:[`${os.tmpdir()}/${fileName}compressed.mp4`]})