From 256e5a607edc1ba409dc323118fc917f7f911727 Mon Sep 17 00:00:00 2001 From: Benjamin Kraft Date: Tue, 14 May 2024 23:10:52 +0200 Subject: [PATCH] added eune support --- src/player.ts | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/player.ts b/src/player.ts index 88247f5..193e80a 100644 --- a/src/player.ts +++ b/src/player.ts @@ -54,18 +54,32 @@ export class Player { } async updateCurrentElo() { - let entries; - try { - entries = await riotAPI.league.getEntriesBySummonerId({ - region: PlatformId.EUW1, + const tryRegion = async (region: RiotAPITypes.LoLRegion) => { + return await riotAPI.league.getEntriesBySummonerId({ + region: region, summonerId: (await riotAPI.summoner.getByPUUID({ - region: PlatformId.EUW1, + region: region, puuid: this.puuid })).id }); + }; + + let entries; + + try { + entries = await tryRegion(PlatformId.EUW1); } catch (error){ - console.error(await(error as Response).json()); - return; + let response = error as Response; + console.error(await response.json()); + console.log(`Trying EUNE Region...`); + try { + entries = await tryRegion(PlatformId.EUNE1); + console.log(`Success with EUNE`); + } catch (error){ + let response = error as Response; + console.error(await response.json()); + return; + } } let soloQ = entries.find(e => e.queueType == "RANKED_SOLO_5x5");