Made image detection get the proxy URL, added ad-hoc large file message

This commit is contained in:
TheEssem 2020-02-25 15:07:36 -06:00
parent 5455b2682c
commit e28f45cfec
2 changed files with 12 additions and 8 deletions

View file

@ -55,10 +55,14 @@ module.exports = async (message) => {
await client.createMessage(message.channel.id, result); await client.createMessage(message.channel.id, result);
} }
} catch (error) { } catch (error) {
logger.error(error.toString()); if (!error.toString().includes("Request entity too large")) {
await client.createMessage(message.channel.id, "Uh oh! I ran into an error while running this command. Please report the content of the attached file here or on the esmBot Support server: <https://github.com/TheEssem/esmBot/issues>", [{ logger.error(error.toString());
file: Buffer.from(`Message: ${error}\n\nStack Trace: ${error.stack}`), await client.createMessage(message.channel.id, "Uh oh! I ran into an error while running this command. Please report the content of the attached file here or on the esmBot Support server: <https://github.com/TheEssem/esmBot/issues>", [{
name: "error.txt" file: Buffer.from(`Message: ${error}\n\nStack Trace: ${error.stack}`),
}]); name: "error.txt"
}]);
} else {
await client.createMessage(message.channel.id, `${message.author.mention}, the resulting file was too large to upload. Try again with a smaller image if possible.`);
}
} }
}; };

View file

@ -46,18 +46,18 @@ module.exports = async (cmdMessage) => {
if (type === false) continue; if (type === false) continue;
return type; return type;
} else if (message.embeds[0].thumbnail) { } else if (message.embeds[0].thumbnail) {
const type = await typeCheck(message.embeds[0].thumbnail.url); const type = await typeCheck(message.embeds[0].thumbnail.proxy_url);
if (type === false) continue; if (type === false) continue;
return type; return type;
// if there isn't a thumbnail check the image area // if there isn't a thumbnail check the image area
} else if (message.embeds[0].image) { } else if (message.embeds[0].image) {
const type = await typeCheck(message.embeds[0].image.url); const type = await typeCheck(message.embeds[0].image.proxy_url);
if (type === false) continue; if (type === false) continue;
return type; return type;
} }
} else if (message.attachments.length !== 0) { } else if (message.attachments.length !== 0) {
// get type of file // get type of file
const type = await typeCheck(message.attachments[0].url); const type = await typeCheck(message.attachments[0].proxy_url);
// move to the next message if the file isn't an image // move to the next message if the file isn't an image
if (type === false) continue; if (type === false) continue;
// if the file is an image then return it // if the file is an image then return it