-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
39 lines (31 loc) · 1.13 KB
/
main.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
/*
Author : Guillaume Théret
Date : 05-06-2023
Description : Get op.gg link from team link amazonUniversity
*/
const getOpGG = async () => {
// get team name from link
const teamName = teamLink.split("/")[4];
const teamData = await fetch(
`https://api.universityesports.fr/api/v001/showcase/university-esports/equipo/${teamName}`
).then((res) => res.json());
const teamMembers = teamData.returnData.miembros;
const teamMembersData = await Promise.all(
teamMembers.map(async (member) => {
const memberData = await fetch(
`https://api.universityesports.fr/api/v001/showcase/university-esports/user/profile/${member.username}`
).then((res) => res.json());
return memberData.returnData.profile.gameNicks;
})
);
const nicks = teamMembersData.map((obj) => obj[0].nick);
// build op.gg link
//https://www.op.gg/multisearch/euw?summoners=Bouhahahahahaha,%20Rob%C3%A9b%C3%B8u
const opGGlink = encodeURI(
`https://www.op.gg/multisearch/euw?summoners=${nicks.join(",")}`
);
console.log(opGGlink);
};
const args = process.argv.slice(2);
const teamLink = args[0];
getOpGG(teamLink);