const request = require('request-promise');
const Pageres = require('pageres');
const fs = require('fs-extra');
const path = require('path');
const { RichEmbed } = require('discord.js');
async function capture() {
await new Pageres({delay: 2, filename: 'dust'})
.src('https://earth.nullschool.net/#current/particulates/surface/level/overlay=pm10/orthographic=127.53,39.09,2196/loc=127.333,37.782', ['1024x768'], {crop: true})
.dest(process.cwd())
.run();
}
async function getMap(args) {
console.log(process.cwd())
await capture(); //캡쳐
fs.copySync(path.resolve(process.cwd(),'dust.png'), '/var/www/html/dust/dust.png');
// console.log('Finished generating screenshots!');
const title = ('``미세먼지 확인 지도``');
// let description = ('http://bot.system32.kr/dust/dust.png');
// let image = ('http://bot.system32.kr/dust/dust.png');
return new RichEmbed()
.setTitle(title);
// .setDescription(description)
// .setThumbnail(image);
}
module.exports = {
name: '!미세먼지',
description: '',
async execute(message, args) {
let result = null;
if (!args.length) {
result = new RichEmbed()
.setTitle('``미세먼지 실시간 확인``')
.setDescription('`!미세먼지 korea` 또는 `!미세먼지 k`');
} else {
switch (args[0]) {
case 'korea':
case '한국':
case 'k':
result = await getMap(args);
break;
default:
result = `\`${args[0]}\` 은(는) 알 수 없는 명령이다`;
break;
}
}
await message.channel.send(result);
await message.reply('http://bot.system32.kr/dust/dust.png');
},
};