Closed trololo151 closed 5 years ago
I noticed this problem yesterday too. Alongside the game there was also an update to the api which sadly broke the bot for now.. The changelog (which can be found here) only said the following:
[PC] Matches and season stats from 10/3 onwards will be global and sharded by platform. PC Data prior to 10/3 and Xbox data will still be accessible with the old URL format
Fact is: as of yesterday the /seasons
endpoint of the pubg api does not return a season object where the isCurrentSeason
property is set to true
. This leads to the error message when searching for the current season during the !statg stats
command.
I will look into this, but I am not quite sure how to fix this. Any help would be much appreciated.
Well, looks like it fixed itself 😄 Just polled the api at https://api.playbattlegrounds.com/shards/pc-eu/seasons
and got the following reponse:
{
"data": [
...
{
"type": "season",
"id": "division.bro.official.pc-2018-01",
"attributes": {
"isCurrentSeason": true,
"isOffseason": false
}
}
]
...
}
The !statg stats
seems to work too. Could you report on whether its working for you as well so I can close this issue?
2018-10-04 16:04:29 [info]: Handling stats command! 2018-10-04 16:04:29 [debug]: checking if player is registered 2018-10-04 16:04:29 [debug]: Successfully fetched seasons data! 2018-10-04 16:04:29 [debug]: Id of current season: division.bro.official.pc-2018-01 2018-10-04 16:04:29 [debug]: Fetching stats... 2018-10-04 16:04:30 [debug]: Successfully fetched stats! 2018-10-04 16:04:30 [debug]: onResolved
!statg stats•Сегодня в 21:04
Hmm, looks like this is another problem than I initially assumed. Have you played games since yesterday?
Oh sure
Well, then did the problem not fix itself 😢 Give me some time to look into this
Of course, I don’t have time yet, I wanted to show how I added automatic role assignment, I can just send the code here
I would to see your role assignment feature 👍 Best way to share your code would be to fork this repo and create a pull request. If the changes you made are quite small, you could post them here too, I guess 😄
Back to topic: I don't really see what's going wrong. After re-reading the changelog and the api docs, it looks to me as if only the format of season names has changed, which doesn't really matter because the season name is fetched through /shards/[region-name]/seasons
. The season stats for any given player are still located at /shards/[region-name]/players/[player-name]/seasons/[season-name]
. Only problem is that the values under the gameModeStats
property are all 0 since yesterday, e.g.
...
"gameModeStats": {
"duo": {
"assists": 0,
"bestRankPoint": 0,
"boosts": 0,
"dBNOs": 0,
"dailyKills": 0,
"dailyWins": 0,
"damageDealt": 0,
"days": 0,
"headshotKills": 0,
"heals": 0,
"killPoints": 0,
"kills": 0,
"longestKill": 0,
"longestTimeSurvived": 0,
"losses": 0,
"maxKillStreaks": 0,
"mostSurvivalTime": 0,
"rankPoints": 0,
"revives": 0,
"rideDistance": 0,
"roadKills": 0,
"roundMostKills": 0,
"roundsPlayed": 0,
"suicides": 0,
"swimDistance": 0,
"teamKills": 0,
"timeSurvived": 0,
"top10s": 0,
"vehicleDestroys": 0,
"walkDistance": 0,
"weaponsAcquired": 0,
"weeklyKills": 0,
"weeklyWins": 0,
"winPoints": 0,
"wins": 0
},
...
So any help would still be much appreciated.
let availableRoles = ["IdRole1", "IdRole2", "IdRolesN"];
let rolesToAssign = bot.servers["IdServer"].members[cmd.discordUser.id].roles.filter(r => !availableRoles.includes(r));
let kill = avgStats.avgKills;
if (kill >= 3 && avgStats.roundsPlayed > 50) {
rolesToAssign.push(availableRoles[0]);
} else if (kill >= 2.5 && avgStats.roundsPlayed > 50) {
// and more ifs..
}
request({
url: "https://discordapp.com/api/v6/guilds/482986292997783562/members/"+cmd.discordUser.id,
headers: {
"User-Agent": "DiscordBot (Custom API request, 1.0)",
"Authorization": "Bot "+ "TokenBot",
"Content-Type": "application/json"
},
method: "PATCH",
body: JSON.stringify({roles: rolesToAssign})
}, function(error, response, body) {
if (response.statusCode.toString().match(/^2\d\d$/) && avgStats.roundsPlayed > 50) {
bot.sendMessage({to: "IdChanel", message: "Roles assigned: "+rolesToAssign.map(r => ""+bot.servers["IdServer"].roles[r].name+"
").join(", ")});
}
});
request removes all roles, leaves which were and assigns the role depending on KD
Finally found the "new way" of getting the seasons stats in the official forums here. For the solution and the fix see kuper-adrian/pubg-royale#4. I will close this issue as soon as the other one closes and I have published and updated the pubg-royale package through npm.
@trololo151 Thanks for sharing your code 👍 Give me some time and I will look into integrating a role assignment feature "natively" into statg (of course you are still welcome to open a pull request if you have a working solution already).
After updating the game, does not show statistics, shows error NAN