Fixed some download not working

This commit is contained in:
loicbersier 2020-02-25 14:05:43 +01:00
parent ec071d8025
commit d330b5ff04

View file

@ -45,9 +45,9 @@ class DownloadCommand extends Command {
let fileName; let fileName;
if (args.spoiler) { if (args.spoiler) {
fileName = `SPOILER_${message.author.id}_video`; fileName = `SPOILER_${message.id}_video`;
} else { } else {
fileName = `${message.author.id}_video`; fileName = `${message.id}_video`;
} }
@ -72,9 +72,11 @@ class DownloadCommand extends Command {
loadingmsg.delete(); loadingmsg.delete();
return message.channel.send('An error has occured, I can\'t download from the link you provided.'); return message.channel.send('An error has occured, I can\'t download from the link you provided.');
} }
let ext = 'mp4';
let ext = await filetype.fromFile(`${os.tmpdir()}/${fileName}`); if (fs.existsSync(`${os.tmpdir()}/${fileName}`)) {
ext = ext.ext; // This look stupid but hey, it work 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}`); fs.renameSync(`${os.tmpdir()}/${fileName}`, `${os.tmpdir()}/${fileName}.${ext}`);