Closed adrien-gllmt closed 2 years ago
How come? Even in your screenshot it's not undefined
. Need to see a code which returns undefined to be sure, but it looks like a problem on your side.
Here it is : And here is the code im running with. I tried several things but it always fails at the same point, this code was my last attempt :
const { 0: rank} = await r6api.getRanks(platform, player.id, {regionIds: 'emea', boardIds: 'pvp_ranked' })
const { seasons: { "-1": { regions: { emea: { boards: { pvp_ranked }} } } } } = rank;
console.log(rank);
----------------------------------
//.addFields comes from discordjs lib
.addFields(
{ name: 'K/D', value: `${/* kd will be displayed here */}`, inline: true },
)
Not a package related issue.
There will never be season with array index of -1
, change it to:
const { 0: rank } = await r6api.getRanks(
platform, id, { regionIds: 'emea', boardIds: 'pvp_ranked' }
);
if (!rank) return;
const { seasons: { 25: { regions: { emea: { boards: { pvp_ranked }} } } } } = rank;
console.log(pvp_ranked);
Or even better to:
const rank = await r6api.getRanks(
platform, id, { regionIds: 'emea', boardIds: 'pvp_ranked' }
).catch(console.error);
if (!rank || !rank.length) return; // handle error
const latestSeason = Object.values(rank[0]?.seasons || {}).slice(-1)[0];
if (!latestSeason) return; // handle error
const { regions: { emea: { boards: { pvp_ranked } } } } = latestSeason;
console.log(pvp_ranked);
Hey ! So im now trying for hours to get the seasonal KD out of
getRanks
, but this always return this : and always return thatregions
is undefined.Did i miss something ? Or mby some parts are not working anymore ?