-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
108 lines (99 loc) · 3.97 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const Discord = require('discord.js');
const { Client, Intents } = require("discord.js");
const request = require('request-promise-native')
const api_losonsil = {
item_search : (msg) => {
var options = {
uri :'https://api.losonsil.com/item/'+encodeURI(msg.content.substr(5)),
json: true
};
request(options).then(function (repos) {
if(!repos){
msg.reply(' 아이템을 찾을수 없습니다.');
return false;
}
if(repos.code){
msg.reply(' 아이템을 찾을수 없습니다.');
return false;
}
if(!repos.data){
msg.reply(' 아이템을 찾을수 없습니다.');
return false;
}
var item_name = '\u200B';
var avg_price = '\u200B';
var last_price = '\u200B';
var current_price = '\u200B';
for (var i=0; i<repos.data.length; i++) {
item_name += '`'+repos.data[i].item_name+" "+(repos.data[i].count?repos.data[i].count:'')+'`\n';
avg_price += '`'+repos.data[i].avg_price+'`\n';
last_price += '`'+repos.data[i].last_price+'`\n';
current_price += '`'+repos.data[i].current_price+'`\n';
}
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#EB539E')
.setTitle('거래소 정보')
.setDescription("`검색어` : "+msg.content.substr(5))
.addFields(
{ name: '아이템명', value:item_name, inline: true },
{ name: '최근 구매가', value: last_price, inline: true },
{ name: '최저가', value:current_price, inline: true },
)
.setTimestamp();
msg.channel.send(exampleEmbed);
}).catch(function (err) {
//msg.reply("\n```"+err.toString()+"```\n<@278650184978792449>");
return false;
});
},
mari_shop : (msg) => {
var options = {
uri :'https://api.losonsil.com/mari',
json: true
};
request(options).then(function (repos) {
if(!repos){
msg.reply(' 아이템을 찾을수 없습니다.');
return false;
}
if(!repos.T3){
msg.reply(' 아이템을 찾을수 없습니다.');
return false;
}
if(!repos.T2){
msg.reply(' 아이템을 찾을수 없습니다.');
return false;
}
var T3_name = '\u200B';
var T3_price = '\u200B';
var T2_name = '\u200B';
var T2_price = '\u200B';
for (var i=0; i<repos.T3.length; i++) {
T3_name+='`'+repos.T3[i].name+'`\n';
T3_price+='`'+repos.T3[i].price+'` 크리스탈\n';
}
for (var i=0; i<repos.T2.length; i++) {
T2_name+='`'+repos.T2[i].name+'`\n';
T2_price+='`'+repos.T2[i].price+'` 크리스탈\n';
}
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#B2CCFF')
.setTitle('로아와에서 상세 보기')
.setURL('https://loawa.com/shop')
.setAuthor('마리의 비밀상점', '', 'https://loawa.com/shop')
.setDescription("현재 판매중 상품")
.addFields(
{ name: 'T3 아이템명', value: T3_name, inline: true },
{ name: 'T3 가격', value: T3_price, inline: true },
{ name: '\u200B', value: '\u200B' },
{ name: 'T2 아이템명', value: T2_name, inline: true },
{ name: 'T2 가격', value: T2_price, inline: true },
)
.setTimestamp();
msg.channel.send(exampleEmbed);
}).catch(function (err) {
return false;
});
}
}
module.exports.api_losonsil = api_losonsil;