diff --git a/README.md b/README.md index 4216792..847c494 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,12 @@ If you're still unsure about your use of the API, feel free to DM Miss#8888 with --- ## Thanks -Thanks to Miss#8888 ([@codecat](https://github.com/codecat)) for creating trackmania.io and for helping me with their API *(and updating it everytime)*. +Thanks to [@codecat](https://github.com/codecat) for creating trackmania.io and for helping me with their API *(and updating it everytime)*. Thanks to Nadeo (Trackmania's studio) for giving an API to trackmania.io. -Thanks to dassschaf#0090 ([@dassschaf](https://github.com/dassschaf)) and [@stefan-baumann](https://github.com/stefan-baumann) for chat formatting remover code in regex *(it saves my life)* +Thanks to [@dassschaf](https://github.com/dassschaf) and [@stefan-baumann](https://github.com/stefan-baumann) for chat formatting remover code in regex *(it saves my life)* -Thanks to Flirno/Knacki#2477 ([@Flirno](https://github.com/Flirno)) for player searching and COTD results API +Thanks to [@Flirno](https://github.com/Flirno) for player COTD results API + +Thanks to [@jonese1234](https://github.com/jonese1234) for the dataset to get the players searching \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0c733e4..b073528 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "trackmania.io", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "trackmania.io", - "version": "1.0.0", + "version": "1.1.0", "license": "GPL-3.0", "dependencies": { "events": "^3.2.0", diff --git a/package.json b/package.json index a17392a..afe0760 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "trackmania.io", - "version": "1.0.0", + "version": "1.1.0", "description": "Node.js inplementation of Trackmania Live services (trackmania.io)", "main": "src/index.js", "scripts": { diff --git a/src/Players/players.js b/src/Players/players.js index 8b17d8e..8826f24 100644 --- a/src/Players/players.js +++ b/src/Players/players.js @@ -37,19 +37,16 @@ class Players { * @returns {array} The possible results */ async searchPlayer(name){ - var players = await f.getData.player.searchPlayer(name) - - var results_arr = [] - Object.entries(players).forEach(entry => { - const [key, value] = entry; - - results_arr.push({ - "displayName": key, - "accountid": value - }) - }); + return await f.getData.player.searchPlayer(name) + } - return results_arr + /** + * Gets the players in a group + * @param {string} group The group name: "Nadeo", "TMGL", (trackmania.io "Sponsor", "Team") + * @returns {array} The possible results + */ + async getGroupPlayers(group){ + return await f.getData.player.playersGroup(group.toLowerCase()) } /** diff --git a/src/functions.js b/src/functions.js index ca69a68..ecda7a8 100644 --- a/src/functions.js +++ b/src/functions.js @@ -24,7 +24,11 @@ function getPlayerTrophies(player){ } function searchPlayer(player){ - return fetch(`${url.tmstats.protocol}://${url.tmstats.host}/${url.tmstats.api}/${url.tmstats.tabs.searchPlayer}/${player.replace(' ', '%20')}`, headers).then(r=>r.json()) + return fetch(`${url.protocol}://${url.host}/${url.api}/${url.tabs.players}/find?search=${player.replace(' ', '%20')}`, headers).then(r=>r.json()) +} + +function playersGroup(group){ + return fetch(`${url.protocol}://${url.host}/${url.api}/${url.tabs.players}/group/${group}`, headers).then(r=>r.json()) } function playerCOTD(player){ @@ -46,6 +50,7 @@ module.exports = { getPlayer, getPlayerTrophies, searchPlayer, + playersGroup, playerCOTD } }, diff --git a/src/httpOptions.js b/src/httpOptions.js index 3d881ec..ac1e66b 100644 --- a/src/httpOptions.js +++ b/src/httpOptions.js @@ -15,6 +15,7 @@ module.exports = { "club": "club", "events": "competitions", "player": "player", + "players": "players", "trophies":"trophies", "leaderboard": "leaderboard", "map": "map"