유병우

Merge branch 'release/2.0' into develop

...@@ -12,8 +12,14 @@ module.exports = { ...@@ -12,8 +12,14 @@ module.exports = {
12 var isMaintainence = false; 12 var isMaintainence = false;
13 await axios.get("https://lostark.game.onstove.com").then(html=>{ 13 await axios.get("https://lostark.game.onstove.com").then(html=>{
14 const $ = cheerio.load(html.data); 14 const $ = cheerio.load(html.data);
15 + textMaintainence = $("div.time_wraper").find("h3").text();
16 + timeMaintainence = $("strong#inspectionTime").text();
17 + console.log(timeMaintainence);
18 + if(textMaintainence == "예상 점검 완료 시간")
19 + isMaintainence = true;
15 }) 20 })
16 - const buttonsRow = new MessageActionRow() 21 + if(!isMaintainence){
22 + const buttonsRow = new MessageActionRow()
17 .addComponents( 23 .addComponents(
18 new MessageButton() 24 new MessageButton()
19 .setCustomId("12time_ago") 25 .setCustomId("12time_ago")
...@@ -32,72 +38,81 @@ module.exports = { ...@@ -32,72 +38,81 @@ module.exports = {
32 .setLabel("현재 마리샵 정보 조회") 38 .setLabel("현재 마리샵 정보 조회")
33 .setStyle("SECONDARY") 39 .setStyle("SECONDARY")
34 ); 40 );
35 - async function getHTML() {
36 - try {
37 - return await axios.get("https://lostark.game.onstove.com/Shop#mari");
38 - } catch (error) {
39 - console.error(error);
40 - }
41 - };
42 - await getHTML().then(html => {
43 - const $ = cheerio.load(html.data);
44 - const bodyList = $("ul.list-items").children("li");
45 - bodyList.each(function(i, elem) {
46 - itemInfo[i] = {
47 - name: $(this).find("span.item-name").text(),
48 - amount: $(this).find("span.amount").text()};
49 - });
50 - return itemInfo;
51 - });
52 -
53 - const embed = new MessageEmbed()
54 - .setTitle("마리샵 성장 추천 목록")
55 - .setColor("#FAA8F0")
56 - .setDescription("성장 추천");
57 - for(idx = 0; idx < 6; idx++) {
58 - embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
59 - embed.addField("\u200B", "전투ㆍ생활 추천", false);
60 - for(idx = 18; idx < 24; idx++) {
61 - embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
62 - interaction.reply({ embeds: [embed], components: [buttonsRow], allowedMentions: {repliedUser: false}});
63 41
64 - const filter = (interaction) => { return interaction.customId === "12time_ago" || "6time_ago" || "0time_ago" ;}; 42 + async function getHTML() {
65 - const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000}); 43 + try {
66 - collector.on("collect", async (interaction) => { 44 + return await axios.get("https://lostark.game.onstove.com/Shop#mari");
67 - if(interaction.customId === "12time_ago") { 45 + } catch (error) {
68 - const embed = new MessageEmbed() 46 + console.error(error);
69 - .setTitle("마리샵 성장 추천 목록")
70 - .setColor("#FAA8F0")
71 - .setDescription("성장 추천");
72 - for(idx = 6; idx < 12; idx++) {
73 - embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
74 - embed.addField("\u200B", "전투ㆍ생활 추천", false);
75 - for(idx = 24; idx < 30; idx++) {
76 - embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
77 - interaction.update({ embeds: [embed], components: [buttonsRow], allowedMentions: {repliedUser: false}});
78 - } else if(interaction.customId === "6time_ago"){
79 - const embed = new MessageEmbed()
80 - .setTitle("마리샵 성장 추천 목록")
81 - .setColor("#FAA8F0")
82 - .setDescription("성장 추천");
83 - for(idx = 12; idx < 18; idx++) {
84 - embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
85 - embed.addField("\u200B", "전투ㆍ생활 추천", false);
86 - for(idx = 30; idx < 36; idx++) {
87 - embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
88 - interaction.update({ embeds: [embed], components: [buttonsRow], allowedMentions: {repliedUser: false}});
89 - } else if(interaction.customId === "0time_ago"){
90 - const embed = new MessageEmbed()
91 - .setTitle("마리샵 성장 추천 목록")
92 - .setColor("#FAA8F0")
93 - .setDescription("성장 추천");
94 - for(idx = 0; idx < 6; idx++) {
95 - embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
96 - embed.addField("\u200B", "전투ㆍ생활 추천", false);
97 - for(idx = 18; idx <24; idx++) {
98 - embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
99 - interaction.update({ embeds: [embed], components: [buttonsRow], allowedMentions: {repliedUser: false}});
100 } 47 }
101 - }); 48 + };
49 + await getHTML().then(html => {
50 + const $ = cheerio.load(html.data);
51 + const bodyList = $("ul.list-items").children("li");
52 + bodyList.each(function(i, elem) {
53 + itemInfo[i] = {
54 + name: $(this).find("span.item-name").text(),
55 + amount: $(this).find("span.amount").text()};
56 + });
57 + return itemInfo;
58 + });
59 +
60 + const embed = new MessageEmbed()
61 + .setTitle("마리샵 성장 추천 목록")
62 + .setColor("#FAA8F0")
63 + .setDescription("성장 추천");
64 + for(idx = 0; idx < 6; idx++) {
65 + embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
66 + embed.addField("\u200B", "전투ㆍ생활 추천", false);
67 + for(idx = 18; idx < 24; idx++) {
68 + embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
69 + interaction.reply({ embeds: [embed], components: [buttonsRow], allowedMentions: {repliedUser: false}});
70 +
71 + const filter = (interaction) => { return interaction.customId === "12time_ago" || "6time_ago" || "0time_ago" ;};
72 + const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000});
73 + collector.on("collect", async (interaction) => {
74 + if(interaction.customId === "12time_ago") {
75 + const embed = new MessageEmbed()
76 + .setTitle("마리샵 성장 추천 목록")
77 + .setColor("#FAA8F0")
78 + .setDescription("성장 추천");
79 + for(idx = 6; idx < 12; idx++) {
80 + embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
81 + embed.addField("\u200B", "전투ㆍ생활 추천", false);
82 + for(idx = 24; idx < 30; idx++) {
83 + embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
84 + interaction.update({ embeds: [embed], components: [buttonsRow], allowedMentions: {repliedUser: false}});
85 + } else if(interaction.customId === "6time_ago"){
86 + const embed = new MessageEmbed()
87 + .setTitle("마리샵 성장 추천 목록")
88 + .setColor("#FAA8F0")
89 + .setDescription("성장 추천");
90 + for(idx = 12; idx < 18; idx++) {
91 + embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
92 + embed.addField("\u200B", "전투ㆍ생활 추천", false);
93 + for(idx = 30; idx < 36; idx++) {
94 + embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
95 + interaction.update({ embeds: [embed], components: [buttonsRow], allowedMentions: {repliedUser: false}});
96 + } else if(interaction.customId === "0time_ago"){
97 + const embed = new MessageEmbed()
98 + .setTitle("마리샵 성장 추천 목록")
99 + .setColor("#FAA8F0")
100 + .setDescription("성장 추천");
101 + for(idx = 0; idx < 6; idx++) {
102 + embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
103 + embed.addField("\u200B", "전투ㆍ생활 추천", false);
104 + for(idx = 18; idx <24; idx++) {
105 + embed.addField(`${(itemInfo[idx]).name}`, `${(itemInfo[idx]).amount}<:bluecrystal:952747773097295932>`, true); }
106 + interaction.update({ embeds: [embed], components: [buttonsRow], allowedMentions: {repliedUser: false}});
107 + }
108 + });
109 + }
110 + else{
111 + const embed = new MessageEmbed()
112 + .setTitle("현재 로스트아크가 점검중입니다.")
113 + .setColor("#FAA8F0")
114 + .setDescription(`예상 점검 시간: ${timeMaintainence}`);
115 + interaction.reply({ embeds: [embed], allowedMentions: {repliedUser: false} });
116 + }
102 }, 117 },
103 }; 118 };
...\ No newline at end of file ...\ No newline at end of file
......