From d9f6a890494b0c96405898e70ec7fddd5eade964 Mon Sep 17 00:00:00 2001 From: Supositware Date: Sun, 24 Mar 2019 18:07:18 +0100 Subject: [PATCH] Fixed downloading message and now delete the compression message --- commands/utility/download.js | 52 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/commands/utility/download.js b/commands/utility/download.js index b06a8e29..3762431d 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -36,6 +36,13 @@ class DownloadCommand extends Command { console.log('error 2:', err); message.channel.send('An error has occured, I can\'t download from the link you provided.'); }); + + message.channel.send('Downloading ').then(msg => { + video.on('end', function () { + msg.delete(); + }); + }); + video.on('info', function(info) { let duration = info.duration; if (duration) { @@ -69,31 +76,30 @@ class DownloadCommand extends Command { preset: 'General/Gmail Small 10 Minutes 288p30' }; //Compress vid if bigger than 8MB - hbjs.spawn(options) - .on('start', function() { - message.channel.send('Video bigger than 8MB compressing now (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!'); - }) - .on('error', err => { - message.channel.send('An error has occured while compressing the video'); - console.error(err); - }) - .on('progress', progress => { - console.log( - 'Percent complete: %s, ETA: %s', - progress.percentComplete, - progress.eta - ); - }) - .on('end', function () { - message.delete(); - message.channel.send(`Downloaded by ${message.author.username}`, { files: ['./videoReady.mp4'] }) - .catch(() => message.channel.send('File too big')); - }); - message.channel.send('Downloading ').then(msg => { - video.on('end', function () { - msg.delete(); + let handbrake = hbjs.spawn(options); + handbrake.on('start', function() { + message.channel.send('Video bigger than 8MB compressing now (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', function () { + msg.delete(); + }); }); }); + handbrake.on('error', err => { + message.channel.send('An error has occured while compressing the video'); + console.error(err); + }); + handbrake.on('progress', progress => { + console.log( + 'Percent complete: %s, ETA: %s', + progress.percentComplete, + progress.eta + ); + }); + handbrake.on('end', function () { + message.delete(); + message.channel.send(`Downloaded by ${message.author.username}`, { files: ['./videoReady.mp4'] }) + .catch(() => message.channel.send('File too big')); + }); }); } else {