From 64c45f87c047aa30c823ee3bc830f38fa13717bd Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 28 Aug 2024 20:52:38 +0200 Subject: [PATCH] Enforce file size limit before downloading --- commands/utility/vid2gif.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/commands/utility/vid2gif.js b/commands/utility/vid2gif.js index ecb0467..5de58f4 100644 --- a/commands/utility/vid2gif.js +++ b/commands/utility/vid2gif.js @@ -63,6 +63,13 @@ export default { return interaction.editReply({ content: '❌ This does not look like a valid url!', ephemeral: true }); } + const aproxFileSize = await utils.getVideoSize(url, 'bestvideo[height<=?480]'); + console.log(aproxFileSize); + + if (aproxFileSize > 4) { + return interaction.editReply('The file you are trying to convert is too big! Limit is 4 MB'); + }; + utils.downloadVideo(url, interaction.id) .then(async () => { const file = fs.readdirSync(os.tmpdir()).filter(fn => fn.startsWith(interaction.id));