From d330b5ff046e02a5987dd71bfbeca39b4e9a723a Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 25 Feb 2020 14:05:43 +0100 Subject: [PATCH] Fixed some download not working --- commands/utility/download.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commands/utility/download.js b/commands/utility/download.js index e0e4ffe..ea4400a 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -45,9 +45,9 @@ class DownloadCommand extends Command { let fileName; if (args.spoiler) { - fileName = `SPOILER_${message.author.id}_video`; + fileName = `SPOILER_${message.id}_video`; } else { - fileName = `${message.author.id}_video`; + fileName = `${message.id}_video`; } @@ -72,9 +72,11 @@ class DownloadCommand extends Command { loadingmsg.delete(); return message.channel.send('An error has occured, I can\'t download from the link you provided.'); } - - let ext = await filetype.fromFile(`${os.tmpdir()}/${fileName}`); - ext = ext.ext; // This look stupid but hey, it work + let ext = 'mp4'; + if (fs.existsSync(`${os.tmpdir()}/${fileName}`)) { + ext = await filetype.fromFile(`${os.tmpdir()}/${fileName}`); + ext = ext.ext; // This look stupid but hey, it work + } fs.renameSync(`${os.tmpdir()}/${fileName}`, `${os.tmpdir()}/${fileName}.${ext}`);