남우성

Create adventure island information supply method

const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed } = require('discord.js');
const axois = require('axios');
const cheerio = require('cheerio');
\ No newline at end of file
const axios = require("axios");
const cheerio = require("cheerio");
module.exports = {
data: new SlashCommandBuilder()
.setName('나침반')
.setDescription('오늘 이용가능한 프로키온의 나침반 스케줄 정보를 조회합니다.'),
async execute(interaction) {
const getHtml = async() => {
try {
return await axios.get("https://www.loawa.com/")
} catch (error){
console.error(error);
}
}
await getHtml()
.then(html => {
const $ = cheerio.load(html.data);
let info_island = []
let info_contents = []
const $IslandList = $("ul.today-quest-list").children("li.list");
$IslandList.each(function(i, elem){
info_island[i] = {
name : $(this).find('h4.island-name span').text(),
reword : $(this).find('h5.lang-text').text()
}
})
let island_print = ""
for(var i = 0; i < info_island.length; i++){
island_print += `${info_island[i].name} : ${info_island[i].reword}\n`;
}
const termembed = new MessageEmbed()
.setColor('#008B8B')
.setTitle('프로키온의 나침반')
.setDescription(`오늘 이용가능한 컨텐츠 정보`)
.addField(
"모험섬", island_print
)
interaction.reply({ embeds: [termembed], allowedMentions: {repliedUser: false} });
})
},
};
......
File mode changed