From 535e623ff20f1c28fbb64e5594fbe9d8e63954cb Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 29 Mar 2020 03:04:21 +0200 Subject: [PATCH] Don't allow downloading of files bigger than 50 mb --- commands/fun/ytp.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/commands/fun/ytp.js b/commands/fun/ytp.js index c5369a9c..f460e2e5 100644 --- a/commands/fun/ytp.js +++ b/commands/fun/ytp.js @@ -124,12 +124,18 @@ class ytpCommand extends Command { } if (url) { - return youtubedl.exec(url, ['--format=mp4', '-o', `./asset/ytp/userVid/${message.id}.mp4`], {}, function(err) { + return youtubedl.exec(url, ['--max-filesize', '50m', '--format=mp4', '-o', `./asset/ytp/userVid/${message.id}.mp4`], {}, function(err, output) { + console.log(output[2]); if (err) { console.error(err); loadingmsg.delete(); return message.channel.send('An error has occured, I can\'t download from the link you provided. Is it an mp4?'); } else { + if (output[2].includes('File is larger than max-filesize')) { + loadingmsg.delete(); + return message.channel.send(output[2]); + } + let mp4 = []; fs.readdirSync('./asset/ytp/userVid/').forEach(file => { if (file.endsWith('mp4')) {