[Discord Bot] 미세먼지 시각화로 보여주기
글 작성자: pental
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'); }, };
이 글은
(새창열림)
본 저작자 표시, 비영리 규칙 하에 배포할 수 있습니다. 자세한 내용은 Creative Commons 라이선스를 확인하세요.
Creative Commons
본 저작자 표시
비영리
'이것저것 > 디스코드 봇' 카테고리의 다른 글
[Discord Bot] 코로나 확진자 보여주기 (0) | 2020.03.29 |
---|---|
[Discord Bot] 네이버 실시간 급상승 Top20 (0) | 2020.02.08 |
[Discord Bot] 롤 전적 검색기 (0) | 2020.02.08 |
댓글
이 글 공유하기
다른 글
-
[Discord Bot] 코로나 확진자 보여주기
[Discord Bot] 코로나 확진자 보여주기
2020.03.29 -
[Discord Bot] 네이버 실시간 급상승 Top20
[Discord Bot] 네이버 실시간 급상승 Top20
2020.02.08 -
[Discord Bot] 롤 전적 검색기
[Discord Bot] 롤 전적 검색기
2020.02.08
댓글을 사용할 수 없습니다.