Move to asset folder

This commit is contained in:
loicbersier 2019-11-04 14:41:45 +01:00
parent ecedfc1e3e
commit ea193818b0
5 changed files with 9 additions and 12 deletions

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

View file

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View file

@ -18,10 +18,10 @@ class dosentexistCommand extends Command {
async exec(message) { async exec(message) {
fetch('https://thispersondoesnotexist.com/image') fetch('https://thispersondoesnotexist.com/image')
.then(res => { .then(res => {
const dest = fs.createWriteStream('./img/de.png'); const dest = fs.createWriteStream('./asset/img/de.png');
res.body.pipe(dest); res.body.pipe(dest);
dest.on('finish', () => { dest.on('finish', () => {
return message.channel.send({files: ['./img/de.png']}); return message.channel.send({files: ['./asset/img/de.png']});
}); });
}); } }); }
} }

View file

@ -1,6 +1,7 @@
const { Command } = require('discord-akairo'); const { Command } = require('discord-akairo');
const fs = require('fs'); const fs = require('fs');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const os = require('os');
class spbCommand extends Command { class spbCommand extends Command {
constructor() { constructor() {
@ -33,10 +34,10 @@ class spbCommand extends Command {
fetch(link) fetch(link)
.then(res => { .then(res => {
const dest = fs.createWriteStream('./img/spb.png'); const dest = fs.createWriteStream(`${os.tmpdir()}/${message.id}.jpg`);
res.body.pipe(dest); res.body.pipe(dest);
dest.on('finish', () => { dest.on('finish', () => {
return message.channel.send({files: ['./img/spb.png']}); return message.channel.send({files: [`${os.tmpdir()}/${message.id}.jpg`]});
}); });
}); });
} }

View file

@ -2,6 +2,7 @@ const { Command } = require('discord-akairo');
const { createCanvas, loadImage } = require('canvas'); const { createCanvas, loadImage } = require('canvas');
const superagent = require('superagent'); const superagent = require('superagent');
const fs = require('fs'); const fs = require('fs');
const os = require('os');
const util = require('util'); const util = require('util');
const exec = util.promisify(require('child_process').exec); const exec = util.promisify(require('child_process').exec);
@ -42,20 +43,15 @@ class nolightCommand extends Command {
ctx.fillStyle = '#FFFFFF'; ctx.fillStyle = '#FFFFFF';
ctx.fillText(text, 10, 20); 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) { if (err) {
return console.error(err); return console.error(err);
} }
}); });
async function apng() { async function apng() {
if (fs.existsSync('./img/nolight.png')) { const { stdout, stderr } = await exec(`apngasm -o ${os.tmpdir()}/${message.id}nolight.png img/frame00*.png -s`)
fs.unlink('./img/nolight.png', (err) => { .then(() => message.channel.send({files: [`${os.tmpdir()}/${message.id}nolight.png`]}));
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']}));
console.log(`stdout: ${stdout}`); console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`); console.log(`stderr: ${stderr}`);
} }