Showing
1 changed file
with
47 additions
and
0 deletions
... | @@ -4,5 +4,52 @@ const axios = require("axios"); | ... | @@ -4,5 +4,52 @@ const axios = require("axios"); |
4 | const cheerio = require("cheerio"); | 4 | const cheerio = require("cheerio"); |
5 | 5 | ||
6 | module.exports ={ | 6 | module.exports ={ |
7 | + data: new SlashCommandBuilder() | ||
8 | + .setName('공략') | ||
9 | + .setDescription('로스트아크 인벤의 군단장 레이드 공략 글 정보를 소개합니다.') | ||
10 | + .addStringOption((option) => | ||
11 | + option.setName('레이드') | ||
12 | + .setDescription('군단장 레이드 이름') | ||
13 | + .setRequired(true)), | ||
14 | + async execute(interaction){ | ||
15 | + const rade_name = interaction.options.getString('레이드'); | ||
16 | + | ||
17 | + const getHtml = async() => { | ||
18 | + try { | ||
19 | + return await axios.get("https://lostark.inven.co.kr/") | ||
20 | + } catch (error){ | ||
21 | + console.error(error); | ||
22 | + } | ||
23 | + } | ||
24 | + | ||
25 | + await getHtml() | ||
26 | + .then(html => { | ||
27 | + const $ = cheerio.load(html.data); | ||
28 | + | ||
29 | + const $radeList = $("div.menu_item01 div.item_body ul.list").children("li.row"); | ||
30 | + | ||
31 | + let rade_info = []; | ||
32 | + let rade_url = []; | ||
33 | + | ||
34 | + $radeList.each(function(i, elem){ | ||
35 | + if($(this).text().indexOf(rade_name) != -1){ | ||
36 | + rade_info.push($(this).text()); | ||
37 | + rade_url.push($(this).find('a').attr('href')); | ||
38 | + } | ||
39 | + }) | ||
40 | + | ||
41 | + let rade_print = ""; | ||
42 | + | ||
43 | + for(var i = 0; i < rade_info.length; i++){ | ||
44 | + rade_print += `[${rade_info[i]}](${rade_url[i]})\n`; | ||
45 | + } | ||
46 | + | ||
47 | + const guideembed = new MessageEmbed() | ||
48 | + .setColor('#6FF3E0') | ||
49 | + .setTitle("공략 정보") | ||
50 | + .setDescription(rade_print) | ||
7 | 51 | ||
52 | + interaction.reply({ embeds: [guideembed], allowedMentions: {repliedUser: false} }); | ||
53 | + }) | ||
54 | + } | ||
8 | } | 55 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment