mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
nice 404
This commit is contained in:
parent
6758555ade
commit
854cd092a2
2 changed files with 14 additions and 3 deletions
|
@ -124,7 +124,16 @@ async def update_lol(discord_id):
|
||||||
account.summoner_name = data["name"]
|
account.summoner_name = data["name"]
|
||||||
account.level = data["summonerLevel"]
|
account.level = data["summonerLevel"]
|
||||||
# Poll the League API for ranked data
|
# Poll the League API for ranked data
|
||||||
|
try:
|
||||||
soloq, flexq, ttq = await lol.get_rank_data("euw", lid)
|
soloq, flexq, ttq = await lol.get_rank_data("euw", lid)
|
||||||
|
except lol.LoLAPIError as e:
|
||||||
|
if e.status_code == 404:
|
||||||
|
account.soloq_tier = None
|
||||||
|
account.soloq_division = None
|
||||||
|
account.flexq_tier = None
|
||||||
|
account.flexq_division = None
|
||||||
|
account.ttq_tier = None
|
||||||
|
account.ttq_division = None
|
||||||
# Update the user data
|
# Update the user data
|
||||||
if soloq is not None:
|
if soloq is not None:
|
||||||
account.soloq_tier = lol.tiers.index(soloq["tier"])
|
account.soloq_tier = lol.tiers.index(soloq["tier"])
|
||||||
|
|
6
lol.py
6
lol.py
|
@ -5,7 +5,9 @@ import royalbotconfig
|
||||||
# https://euw.api.riotgames.com/api/lol/EUW/v1.4/summoner/52348350?api_key=RGAPI-1008c33d-b0a4-4091-8600-27022d570964
|
# https://euw.api.riotgames.com/api/lol/EUW/v1.4/summoner/52348350?api_key=RGAPI-1008c33d-b0a4-4091-8600-27022d570964
|
||||||
|
|
||||||
class LoLAPIError(Exception):
|
class LoLAPIError(Exception):
|
||||||
pass
|
def __init__(self, status_code, text):
|
||||||
|
self.status_code = status_code
|
||||||
|
self.text = text
|
||||||
|
|
||||||
|
|
||||||
tiers = ["BRONZE", "SILVER", "GOLD", "PLATINUM", "DIAMOND", "MASTER", "CHALLENGER"]
|
tiers = ["BRONZE", "SILVER", "GOLD", "PLATINUM", "DIAMOND", "MASTER", "CHALLENGER"]
|
||||||
|
@ -19,7 +21,7 @@ async def get_json(url, **kwargs):
|
||||||
async with session.get(url, **kwargs) as response:
|
async with session.get(url, **kwargs) as response:
|
||||||
json = await response.json()
|
json = await response.json()
|
||||||
if response.status != 200:
|
if response.status != 200:
|
||||||
raise LoLAPIError(f"Riot API returned {response.status}")
|
raise LoLAPIError(response.status, f"Riot API returned {response.status}")
|
||||||
return json
|
return json
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue