diff --git a/img/frame002.png b/asset/img/frame002.png similarity index 100% rename from img/frame002.png rename to asset/img/frame002.png diff --git a/img/gold.png b/asset/img/gold.png similarity index 100% rename from img/gold.png rename to asset/img/gold.png diff --git a/commands/fun/doesntexist.js b/commands/fun/doesntexist.js index 5cdb8232..d099328d 100644 --- a/commands/fun/doesntexist.js +++ b/commands/fun/doesntexist.js @@ -18,10 +18,10 @@ class dosentexistCommand extends Command { async exec(message) { fetch('https://thispersondoesnotexist.com/image') .then(res => { - const dest = fs.createWriteStream('./img/de.png'); + const dest = fs.createWriteStream('./asset/img/de.png'); res.body.pipe(dest); dest.on('finish', () => { - return message.channel.send({files: ['./img/de.png']}); + return message.channel.send({files: ['./asset/img/de.png']}); }); }); } } diff --git a/commands/fun/spb.js b/commands/fun/spb.js index 88d416b7..73dd329e 100644 --- a/commands/fun/spb.js +++ b/commands/fun/spb.js @@ -1,6 +1,7 @@ const { Command } = require('discord-akairo'); const fs = require('fs'); const fetch = require('node-fetch'); +const os = require('os'); class spbCommand extends Command { constructor() { @@ -33,10 +34,10 @@ class spbCommand extends Command { fetch(link) .then(res => { - const dest = fs.createWriteStream('./img/spb.png'); + const dest = fs.createWriteStream(`${os.tmpdir()}/${message.id}.jpg`); res.body.pipe(dest); dest.on('finish', () => { - return message.channel.send({files: ['./img/spb.png']}); + return message.channel.send({files: [`${os.tmpdir()}/${message.id}.jpg`]}); }); }); } diff --git a/commands/images/nolight.js b/commands/images/nolight.js index f5ef6fec..74bf46a3 100644 --- a/commands/images/nolight.js +++ b/commands/images/nolight.js @@ -2,6 +2,7 @@ const { Command } = require('discord-akairo'); const { createCanvas, loadImage } = require('canvas'); const superagent = require('superagent'); const fs = require('fs'); +const os = require('os'); const util = require('util'); const exec = util.promisify(require('child_process').exec); @@ -42,20 +43,15 @@ class nolightCommand extends Command { ctx.fillStyle = '#FFFFFF'; ctx.fillText(text, 10, 20); - fs.writeFile('./img/frame001.png', canvas.toBuffer(), function (err) { + fs.writeFile('./asset/img/frame001.png', canvas.toBuffer(), function (err) { if (err) { return console.error(err); } }); async function apng() { - if (fs.existsSync('./img/nolight.png')) { - fs.unlink('./img/nolight.png', (err) => { - if (err) throw err; - }); - } - const { stdout, stderr } = await exec('apngasm -o img/nolight.png img/frame00*.png -s') - .then(() => message.channel.send({files: ['./img/nolight.png']})); + const { stdout, stderr } = await exec(`apngasm -o ${os.tmpdir()}/${message.id}nolight.png img/frame00*.png -s`) + .then(() => message.channel.send({files: [`${os.tmpdir()}/${message.id}nolight.png`]})); console.log(`stdout: ${stdout}`); console.log(`stderr: ${stderr}`); }