Skip to content

Commit

Permalink
Merge pull request #4 from GreepTheSheep/develop
Browse files Browse the repository at this point in the history
1.1.0
  • Loading branch information
GreepTheSheep authored Feb 14, 2021
2 parents 7c5741d + fcd7908 commit 931e579
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
21 changes: 9 additions & 12 deletions src/Players/players.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -46,6 +50,7 @@ module.exports = {
getPlayer,
getPlayerTrophies,
searchPlayer,
playersGroup,
playerCOTD
}
},
Expand Down
1 change: 1 addition & 0 deletions src/httpOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
"club": "club",
"events": "competitions",
"player": "player",
"players": "players",
"trophies":"trophies",
"leaderboard": "leaderboard",
"map": "map"
Expand Down

0 comments on commit 931e579

Please sign in to comment.