Add timeouts to many projectlounge requests, fixed command bug
This commit is contained in:
parent
4684db06e8
commit
516570efe4
6 changed files with 60 additions and 22 deletions
|
@ -118,8 +118,13 @@ module.exports = async (client, cluster, worker, ipc, message) => {
|
|||
const filename = `${Math.random().toString(36).substring(2, 15)}.${result.name.split(".")[1]}`;
|
||||
await fs.promises.writeFile(`${process.env.TEMPDIR}/${filename}`, result.file);
|
||||
const imageURL = `${process.env.TMP_DOMAIN == "" ? "https://tmp.projectlounge.pw" : process.env.TMP_DOMAIN}/${filename}`;
|
||||
const controller = new AbortController(); // eslint-disable-line no-undef
|
||||
const timeout = setTimeout(() => {
|
||||
controller.abort();
|
||||
}, 5000);
|
||||
try {
|
||||
await fetch(imageURL);
|
||||
await fetch(imageURL, { signal: controller.signal });
|
||||
clearTimeout(timeout);
|
||||
} catch {
|
||||
// this is here to make sure the image is properly cached by discord
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue