남우성

Fix bugs

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