-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlol.js
42 lines (40 loc) · 1.21 KB
/
lol.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
const axios = require("axios");
const { Kayn, REGIONS } = require("kayn");
//const kayn = Kayn(process.env.RIOT_API)();
export const checkIfUserIsInGame = (nickname, onReady) => {
kayn.Summoner.by
.name(nickname)
.then(summoner => {
kayn.CurrentGame.by
.summonerID(summoner.id)
.then(info => {
onReady(true);
})
.catch(infoe => {
onReady(false);
});
})
.catch(error => console.error(error));
};
export const checkIfUserIsInGameopgg = (nickname, onReady) => {
axios
.get("https://na.op.gg/summoner/spectator/userName=" + nickname, {
responseType: "arraybuffer"
})
.then(fr => {
const text = require("buffer")
.Buffer.from(fr.data, "binary")
.toString();
if (text) {
onReady(
!(
text.includes("SpectatorError") ||
text.includes("is not in an active")
)
);
}
})
.catch(error => {
console.log(error);
});
};