Ping the user when a response takes over 3 minutes, added config option for specifying a custom 8mb image domain

This commit is contained in:
TheEssem 2021-03-05 12:03:17 -06:00
parent 4d5ef3c24f
commit 45bb53d521
2 changed files with 9 additions and 4 deletions

View File

@ -45,6 +45,8 @@ CHROME=172.17.0.1:9222
OUTPUT=
# Put temporary image dir here (make sure it's accessible via a web server), leave blank to disable
TEMPDIR=
# Put temporary image web server domain
TMP_DOMAIN=
# Set this to true if you're using PM2 to manage the bot
PMTWO=false

View File

@ -69,7 +69,9 @@ module.exports = async (message) => {
logger.log("info", `${message.author.username} (${message.author.id}) ran command ${command}`);
try {
await database.addCount(collections.aliases.has(command) ? collections.aliases.get(command) : command);
const startTime = new Date();
const result = await cmd(message, args, content.replace(command, "").trim()); // we also provide the message content as a parameter for cases where we need more accuracy
const endTime = new Date();
if (typeof result === "string" || (typeof result === "object" && result.embed)) {
await client.createMessage(message.channel.id, result);
} else if (typeof result === "object" && result.file) {
@ -80,17 +82,18 @@ module.exports = async (message) => {
embed: {
color: 16711680,
title: "Here's your image!",
url: `https://projectlounge.pw/tmp/${filename}`,
url: `${process.env.TMP_DOMAIN == "" ? "https://projectlounge.pw/tmp" : process.env.TMP_DOMAIN}/${filename}`,
image: {
url: `https://projectlounge.pw/tmp/${filename}`
url: `${process.env.TMP_DOMAIN == "" ? "https://projectlounge.pw/tmp" : process.env.TMP_DOMAIN}/${filename}`
},
footer: {
text: "The result image was more than 8MB in size, so it was uploaded to an external site instead."
},
}
},
content: (endTime - startTime) >= 180000 ? message.author.mention : undefined
});
} else {
await client.createMessage(message.channel.id, result.text ? result.text : "", result);
await client.createMessage(message.channel.id, result.text ? result.text : ((endTime - startTime) >= 180000 ? message.author.mention : undefined), result);
}
}
} catch (error) {