removed some console.log and delete the file after download

This commit is contained in:
loicbersier 2019-12-24 16:41:33 +01:00
parent fd9959394d
commit a748f5a383

View file

@ -75,11 +75,8 @@ class DownloadCommand extends Command {
let file = fs.statSync(`${os.tmpdir()}/${fileName}.mp4`); let file = fs.statSync(`${os.tmpdir()}/${fileName}.mp4`);
let fileSize = file.size / 1000000.0; let fileSize = file.size / 1000000.0;
console.log(fileSize);
//Compress vid if bigger than 8MB //Compress vid if bigger than 8MB
if (fileSize > 8) { if (fileSize > 8) {
console.log('file bigger than 8MB');
let compressmsg = await 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!'); let compressmsg = await 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!');
loadingmsg.delete(); loadingmsg.delete();
@ -115,8 +112,8 @@ class DownloadCommand extends Command {
file = fs.statSync(`${os.tmpdir()}/${fileName}compressed.mp4`); file = fs.statSync(`${os.tmpdir()}/${fileName}compressed.mp4`);
fileSize = file.size / 1000000.0; fileSize = file.size / 1000000.0;
message.delete();
compressmsg.delete(); compressmsg.delete();
message.delete();
if (fileSize > 8) { if (fileSize > 8) {
return message.channel.send('File too big!'); 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`]}) return message.channel.send({embed: Embed, files: [`${os.tmpdir()}/${fileName}compressed.mp4`]})
.catch(err => { .catch(err => {
console.error(err); console.error(err);
compressmsg.delete();
loadingmsg.delete();
return message.channel.send('File too big'); return message.channel.send('File too big');
})
.then(() => {
// Delete file after it have been sent
fs.unlinkSync(`${os.tmpdir()}/${fileName}.mp4`);
}); });
}); });
} else { } else {
loadingmsg.delete(); loadingmsg.delete();
message.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 => { .catch(err => {
console.error(err); console.error(err);
loadingmsg.delete(); message.channel.send('File too big');
return message.channel.send('File too big'); })
.then(() => {
// Delete file after it have been sent
fs.unlinkSync(`${os.tmpdir()}/${fileName}.mp4`);
}); });
} }
}); });