Added toggle for temporary image storage

This commit is contained in:
TheEssem 2020-04-23 21:14:03 -05:00
parent af8bce1d3e
commit 881dfd34d7
2 changed files with 4 additions and 2 deletions

View File

@ -27,6 +27,8 @@ DBL=
# Put HTML help page output location here, leave blank to disable
OUTPUT=
# Put temporary image dir here (make sure it's accessible via a web server), leave blank to disable
TEMPDIR=
# Enable/disable Twitter bot (true/false)
TWITTER=false

View File

@ -43,9 +43,9 @@ module.exports = async (message) => {
if (typeof result === "string" || (typeof result === "object" && result.embed)) {
await client.createMessage(message.channel.id, result);
} else if (typeof result === "object" && result.file) {
if (result.file.length > 8388119) {
if (result.file.length > 8388119 && process.env.TEMPDIR !== "") {
const filename = `${Math.random().toString(36).substring(2, 15)}.${result.name.split(".")[1]}`;
await promisify(fs.writeFile)(`/var/www/html/tmp/${filename}`, result.file);
await promisify(fs.writeFile)(`${process.env.TEMPDIR}/${filename}`, result.file);
await client.createMessage(message.channel.id, {
embed: {
color: 16711680,