Properly catch large images
This commit is contained in:
parent
241c272c48
commit
d00bc32b01
2 changed files with 4 additions and 2 deletions
|
@ -125,7 +125,7 @@ export default async (client, cluster, worker, ipc, message) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result.file.length > fileSize) {
|
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]}`;
|
const filename = `${Math.random().toString(36).substring(2, 15)}.${result.name.split(".")[1]}`;
|
||||||
await promises.writeFile(`${process.env.TEMPDIR}/${filename}`, result.file);
|
await promises.writeFile(`${process.env.TEMPDIR}/${filename}`, result.file);
|
||||||
const imageURL = `${process.env.TMP_DOMAIN || "https://tmp.projectlounge.pw"}/${filename}`;
|
const imageURL = `${process.env.TMP_DOMAIN || "https://tmp.projectlounge.pw"}/${filename}`;
|
||||||
|
@ -142,6 +142,8 @@ export default async (client, cluster, worker, ipc, message) => {
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
}, reference));
|
}, reference));
|
||||||
|
} else {
|
||||||
|
await client.createMessage(message.channel.id, "The resulting image was more than 8MB in size, so I can't upload it.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await client.createMessage(message.channel.id, Object.assign({
|
await client.createMessage(message.channel.id, Object.assign({
|
||||||
|
|
2
shard.js
2
shard.js
|
@ -47,7 +47,7 @@ class Shard extends BaseClusterWorker {
|
||||||
await database.setup(this.ipc);
|
await database.setup(this.ipc);
|
||||||
|
|
||||||
// register events
|
// register events
|
||||||
log("info", `Attempting to load events...`);
|
log("info", "Attempting to load events...");
|
||||||
for await (const file of this.getFiles("./events/")) {
|
for await (const file of this.getFiles("./events/")) {
|
||||||
log("log", `Loading event from ${file}...`);
|
log("log", `Loading event from ${file}...`);
|
||||||
const eventArray = file.split("/");
|
const eventArray = file.split("/");
|
||||||
|
|
Loading…
Reference in a new issue