Showing
2 changed files
with
49 additions
and
2 deletions
| 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); | 1 | const { SlashCommandBuilder } = require('@discordjs/builders'); |
| 2 | const { MessageEmbed } = require('discord.js'); | 2 | const { MessageEmbed } = require('discord.js'); |
| 3 | -const axois = require('axios'); | ||
| 4 | -const cheerio = require('cheerio'); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 3 | +const axios = require("axios"); | ||
| 4 | +const cheerio = require("cheerio"); | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +module.exports = { | ||
| 8 | + data: new SlashCommandBuilder() | ||
| 9 | + .setName('나침반') | ||
| 10 | + .setDescription('오늘 이용가능한 프로키온의 나침반 스케줄 정보를 조회합니다.'), | ||
| 11 | + async execute(interaction) { | ||
| 12 | + const getHtml = async() => { | ||
| 13 | + try { | ||
| 14 | + return await axios.get("https://www.loawa.com/") | ||
| 15 | + } catch (error){ | ||
| 16 | + console.error(error); | ||
| 17 | + } | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + await getHtml() | ||
| 21 | + .then(html => { | ||
| 22 | + const $ = cheerio.load(html.data); | ||
| 23 | + | ||
| 24 | + let info_island = [] | ||
| 25 | + let info_contents = [] | ||
| 26 | + const $IslandList = $("ul.today-quest-list").children("li.list"); | ||
| 27 | + | ||
| 28 | + $IslandList.each(function(i, elem){ | ||
| 29 | + info_island[i] = { | ||
| 30 | + name : $(this).find('h4.island-name span').text(), | ||
| 31 | + reword : $(this).find('h5.lang-text').text() | ||
| 32 | + } | ||
| 33 | + }) | ||
| 34 | + | ||
| 35 | + let island_print = "" | ||
| 36 | + | ||
| 37 | + for(var i = 0; i < info_island.length; i++){ | ||
| 38 | + island_print += `${info_island[i].name} : ${info_island[i].reword}\n`; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + const termembed = new MessageEmbed() | ||
| 42 | + .setColor('#008B8B') | ||
| 43 | + .setTitle('프로키온의 나침반') | ||
| 44 | + .setDescription(`오늘 이용가능한 컨텐츠 정보`) | ||
| 45 | + .addField( | ||
| 46 | + "모험섬", island_print | ||
| 47 | + ) | ||
| 48 | + interaction.reply({ embeds: [termembed], allowedMentions: {repliedUser: false} }); | ||
| 49 | + }) | ||
| 50 | + }, | ||
| 51 | +}; | ... | ... |
commands/help.js
deleted
100644 → 0
File mode changed
-
Please register or login to post a comment