Properly catch large images

This commit is contained in:
Essem 2022-02-23 15:51:20 -06:00
parent 241c272c48
commit d00bc32b01
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
2 changed files with 4 additions and 2 deletions

View file

@ -125,7 +125,7 @@ export default async (client, cluster, worker, ipc, message) => {
}
}
if (result.file.length > fileSize) {
if (process.env.TEMPDIR !== "") {
if (process.env.TEMPDIR && process.env.TEMPDIR !== "") {
const filename = `${Math.random().toString(36).substring(2, 15)}.${result.name.split(".")[1]}`;
await promises.writeFile(`${process.env.TEMPDIR}/${filename}`, result.file);
const imageURL = `${process.env.TMP_DOMAIN || "https://tmp.projectlounge.pw"}/${filename}`;
@ -142,6 +142,8 @@ export default async (client, cluster, worker, ipc, message) => {
},
}]
}, reference));
} else {
await client.createMessage(message.channel.id, "The resulting image was more than 8MB in size, so I can't upload it.");
}
} else {
await client.createMessage(message.channel.id, Object.assign({

View file

@ -47,7 +47,7 @@ class Shard extends BaseClusterWorker {
await database.setup(this.ipc);
// register events
log("info", `Attempting to load events...`);
log("info", "Attempting to load events...");
for await (const file of this.getFiles("./events/")) {
log("log", `Loading event from ${file}...`);
const eventArray = file.split("/");