small bugfix

This commit is contained in:
Flummi 2023-07-02 13:11:11 +02:00
parent f2757f08af
commit 85212051d0

View File

@ -23,10 +23,9 @@ export default async bot => {
f: e => { f: e => {
const links = e.message.match(regex.all)?.filter(link => !link.includes(cfg.main.url)) || []; const links = e.message.match(regex.all)?.filter(link => !link.includes(cfg.main.url)) || [];
let repost; let repost;
if(e.media) if(e.media)
links.push(e.media); links.push(e.media);
if(links.length === 0) if(links.length === 0)
return false; return false;
@ -65,11 +64,12 @@ export default async bot => {
ext = meta.ext; ext = meta.ext;
} catch(err) { } catch(err) {
const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"]; const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"];
ext = tmphead; // this can be undefined for unsupported mime types, but will be caught in the general mime check below
ext = cfg.mimes[tmphead];
} }
if(!Object.values(cfg.mimes).includes(ext.toLowerCase())) { if(!Object.values(cfg.mimes).includes(ext?.toLowerCase())) {
return await e.reply('mime schmime '+ext); return 'mime schmime ' + ext;
} }
const msg = await e.reply(`[charging the f0cker] downloading: ${uuid}`, { const msg = await e.reply(`[charging the f0cker] downloading: ${uuid}`, {