남우성

Fix bugs

......@@ -2,7 +2,7 @@ const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed } = require('discord.js');
const axios = require("axios");
const cheerio = require("cheerio");
const request = require("request-promise");
module.exports = {
data: new SlashCommandBuilder()
......@@ -24,16 +24,8 @@ module.exports = {
let info_island = [];
let info_contents = [];
let All_contents = ["유령선", "카오스 게이트"];
const $IslandList = $("ul.today-quest-list").children("li.list");
const $ContentList = $("ul.item-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()
}
})
$ContentList.each(function(i, elem){
for(var i = 0; i < All_contents.length; i++){
if($(this).find("h4.item-title span").text() === All_contents[i]){
......@@ -42,20 +34,12 @@ module.exports = {
}
})
let island_print = "";
for(var i = 0; i < info_island.length; i++){
let rewordImage = "";
if(info_island[i].reword === "카드"){
rewordImage = "<:cardpack:976389392702791710>"
} else if(info_island[i].reword === "골드"){
rewordImage = "<:golds:976389688132788245>"
} else if(info_island[i].reword === "주화"){
rewordImage = "<:piratecoin:976389403662508092>"
} else if(info_island[i].reword === "실링"){
rewordImage = "<:shillings:976389357558710292>"
}
island_print += `${info_island[i].name}: ${info_island[i].reword} ${rewordImage}\n`;
const $Bosscontent = $('div.main-inner-box ul.item-list').children('li'.list);
$Bosscontent.each(function(i, elem){
if($(this).find("h4.item-title").text() == "모아케"){
info_contents.push("필드 보스");
}
})
let content_print = "";
......@@ -67,7 +51,38 @@ module.exports = {
content_print = "오늘은 이용가능한 컨텐츠가 없어요";
}
const termembed = new MessageEmbed()
//api 출처: 로학원생
url = "http://152.70.248.4:5000/adventureisland/";
request(url, function(err, res, body){
if(err){
throw err;
}
let island_data = JSON.parse(body);
for(var i = 0; i < island_data.Island.length; i++){
info_island[i] = {
name : island_data.Island[i].Name,
reward : island_data.Island[i].Reward
}
}
}).then(function(){
let island_print = "";
for(var i = 0; i < info_island.length; i++){
let rewardImage = "";
if(info_island[i].reward === "카드"){
rewardImage = "<:cardpack:976389392702791710>"
} else if(info_island[i].reward === "골드"){
rewardImage = "<:golds:976389688132788245>"
} else if(info_island[i].reward === "주화"){
rewardImage = "<:piratecoin:976389403662508092>"
} else if(info_island[i].reward === "실링"){
rewardImage = "<:shillings:976389357558710292>"
}
island_print += `${info_island[i].name}: ${info_island[i].reward} ${rewardImage}\n`;
}
const compassembed = new MessageEmbed()
.setColor('#008B8B')
.setTitle('프로키온의 나침반')
.setDescription(`오늘 이용가능한 컨텐츠 정보`)
......@@ -76,7 +91,8 @@ module.exports = {
{name: "오늘의 콘텐츠", value: content_print, inline: true}
)
interaction.reply({ embeds: [termembed], allowedMentions: {repliedUser: false} });
interaction.reply({ embeds: [compassembed], allowedMentions: {repliedUser: false} });
})
})
},
};
......
......@@ -11,7 +11,29 @@ module.exports ={
.addStringOption((option) =>
option.setName('클래스')
.setDescription('각인 정보를 알고싶은 직업')
.setRequired(true)),
.setRequired(true)
.addChoices({ name: '디스트로이어', value: '디스트로이어'})
.addChoices({ name: '버서커', value: '버서커'})
.addChoices({ name: '워로드', value: '워로드'})
.addChoices({ name: '홀리나이트', value: '홀리나이트'})
.addChoices({ name: '기공사', value: '기공사'})
.addChoices({ name: '배틀마스터', value: '배틀마스터'})
.addChoices({ name: '스트라이커', value: '스트라이커'})
.addChoices({ name: '인파이터', value: '인파이터'})
.addChoices({ name: '창술사', value: '창술사'})
.addChoices({ name: '건슬리어', value: '건슬리어'})
.addChoices({ name: '데빌헌터', value: '데빌헌터'})
.addChoices({ name: '블래스터', value: '블래스터'})
.addChoices({ name: '스카우터', value: '스카우터'})
.addChoices({ name: '호크아이', value: '호크아이'})
.addChoices({ name: '바드', value: '바드'})
.addChoices({ name: '서머너', value: '서머너'})
.addChoices({ name: '소서리스', value: '소서리스'})
.addChoices({ name: '아르카나', value: '아르카나'})
.addChoices({ name: '데모닉', value: '데모닉'})
.addChoices({ name: '리퍼', value: '리퍼'})
.addChoices({ name: '블레이드', value: '블레이드'})
.addChoices({ name: '도화가', value: '도화가'})),
async execute(interaction){
const class_name = interaction.options.getString('클래스');
......@@ -41,7 +63,6 @@ module.exports ={
case '리퍼' : job_number = 6; class_number = 3; break;
case '블레이드' : job_number = 6; class_number = 4; break;
case '도화가' : job_number = 7; class_number = 2; break;
default: interaction.reply('올바른 직업명을 입력해주세요!'); return;
}
const tempembed = new MessageEmbed()
.setColor('#F7819F')
......@@ -53,7 +74,14 @@ module.exports ={
const page = await browser.newPage();
await page.goto('https://loawa.com/rank');
await page.click(`#contents > article > form > div > div:nth-child(${job_number}) > div > div:nth-child(2) > div > label:nth-child(${class_number}) > span`);
if(job_number ==7 && class_number ==2){
let button = await page.$(`#contents > article > form > div > div:nth-child(7) > div > div:nth-child(2) > div > label.checkbox-group.server-width > span`);
await button.evaluate(b => b.click());
} else{
let button = await page.$(`#contents > article > form > div > div:nth-child(${job_number}) > div > div:nth-child(2) > div > label:nth-child(${class_number}) > span`);
await button.evaluate(b => b.click());
}
await page.waitForSelector('#contents > article > table > tbody > tr:nth-child(20) > td:nth-child(11) > a > svg > path');
await page.waitForTimeout(1000);
......