From a748f5a383e8ea3bd218bea0c007149162ab8ad2 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 24 Dec 2019 16:41:33 +0100 Subject: [PATCH] removed some console.log and delete the file after download --- commands/utility/download.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/commands/utility/download.js b/commands/utility/download.js index 35198853..3ff62143 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -75,11 +75,8 @@ class DownloadCommand extends Command { let file = fs.statSync(`${os.tmpdir()}/${fileName}.mp4`); let fileSize = file.size / 1000000.0; - console.log(fileSize); - //Compress vid if bigger than 8MB if (fileSize > 8) { - console.log('file bigger than 8MB'); let compressmsg = await 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!'); loadingmsg.delete(); @@ -115,8 +112,8 @@ class DownloadCommand extends Command { file = fs.statSync(`${os.tmpdir()}/${fileName}compressed.mp4`); fileSize = file.size / 1000000.0; - message.delete(); compressmsg.delete(); + message.delete(); if (fileSize > 8) { return message.channel.send('File too big!'); @@ -125,20 +122,25 @@ class DownloadCommand extends Command { return message.channel.send({embed: Embed, files: [`${os.tmpdir()}/${fileName}compressed.mp4`]}) .catch(err => { console.error(err); - compressmsg.delete(); - loadingmsg.delete(); return message.channel.send('File too big'); + }) + .then(() => { + // Delete file after it have been sent + fs.unlinkSync(`${os.tmpdir()}/${fileName}.mp4`); }); }); } else { loadingmsg.delete(); message.delete(); - return message.channel.send({embed: Embed, files: [`${os.tmpdir()}/${fileName}.mp4`]}) + message.channel.send({embed: Embed, files: [`${os.tmpdir()}/${fileName}.mp4`]}) .catch(err => { console.error(err); - loadingmsg.delete(); - return message.channel.send('File too big'); + message.channel.send('File too big'); + }) + .then(() => { + // Delete file after it have been sent + fs.unlinkSync(`${os.tmpdir()}/${fileName}.mp4`); }); } });