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);
}
} catch (error) {
logger.error(error.toString());
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>", [{
file: Buffer.from(`Message: ${error}\n\nStack Trace: ${error.stack}`),
name: "error.txt"
}]);
if (!error.toString().includes("Request entity too large")) {
logger.error(error.toString());
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>", [{
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;
return type;
} 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;
return type;
// if there isn't a thumbnail check the image area
} 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;
return type;
}
} else if (message.attachments.length !== 0) {
// 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
if (type === false) continue;
// if the file is an image then return it