From f4dca21e82eb3044927bdf6c981f94d8056027dc Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 27 Feb 2020 19:47:56 +0100 Subject: [PATCH] Show file size --- commands/fun/audio2image.js | 7 ++++--- commands/fun/image2audio.js | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/commands/fun/audio2image.js b/commands/fun/audio2image.js index 08ff5372..721a2552 100644 --- a/commands/fun/audio2image.js +++ b/commands/fun/audio2image.js @@ -72,10 +72,11 @@ class audio2imageCommand extends Command { .on('end', () => { console.log('finished'); loadingmsg.delete(); - return message.channel.send({files: [`${os.tmpdir()}/a2i${message.id}.png`]}) + let file = fs.statSync(`${os.tmpdir()}/a2i${message.id}.png`); + let fileSize = (file.size / 1000000.0).toFixed(2); + return message.channel.send(`Image is ${fileSize} MB for ${args.video_size} resolution`, {files: [`${os.tmpdir()}/a2i${message.id}.png`]}) .catch(() => { - return message.channel.send('End result is too big to fit on discord!'); - }); + return message.channel.send(`End result is too big to fit on discord! File is ${fileSize} MB`); }); }) .run(); }) diff --git a/commands/fun/image2audio.js b/commands/fun/image2audio.js index 25356573..a4bc1d60 100644 --- a/commands/fun/image2audio.js +++ b/commands/fun/image2audio.js @@ -62,9 +62,11 @@ class image2audioCommand extends Command { .on('end', () => { console.log('finished'); loadingmsg.delete(); - return message.channel.send({files: [`${os.tmpdir()}/i2a_${message.id}.mp3`]}) + let file = fs.statSync(`${os.tmpdir()}/i2a_${message.id}.mp3`); + let fileSize = (file.size / 1000000.0).toFixed(2); + return message.channel.send(`Audio file is ${fileSize} MB`, {files: [`${os.tmpdir()}/i2a_${message.id}.mp3`]}) .catch(() => { - return message.channel.send('End result is too big to fit on discord!'); + return message.channel.send(`End result is too big to fit on discord! File is ${fileSize} MB`); }); }) .run();