Source code for lol.summoner
import datetime
import lol
[docs]class Summoner:
"""Represents a League of Legends summoner.
Attributes:
name (:class:`str`): The name of the summoner.
puuid (:class:`str`): The PUUID associated with the summoner.
level (:class:`int`): The current level for the summoner.
id (:class:`str`): The ID associated with the summoner.
account_id (:class:`str`): The account ID associated with the summoner.
revision_date (:class:`datetime.datetime`): The last time the summoner's data was updated.
This is *server-side*, keep in mind.
profile_icon_id (:class:`int`): The ID for the summoner's profile icon.
profile_icon (:class:`Image`): An Image which gives functionality for saving, reading, and
accessing the url of the image.
region (:class:`Region`): The region the summoner is located in.
"""
__slots__ = ("region", "profile_icon_id", "name", "puuid", "level", "id", "account_id", "revision_date", "_client")
def __init__(self, client, region: lol.Region, **data):
self.profile_icon_id = data.get("profileIconId")
self.name = data.get("name")
self.puuid = data.get("puuid")
self.level = data.get("summonerLevel")
self.id = data.get("id")
self.account_id = data.get("accountId")
self.revision_date = datetime.datetime.fromtimestamp(data.get("revisionDate") / 1000)
self.region = region
self._client = client
@property
def profile_icon(self):
return lol.Image(
self._client,
f"http://ddragon.leagueoflegends.com/cdn/9.8.1/img/profileicon/{self.profile_icon_id}.png"
)
async def fetch_masteries(self):
data = await self._client.request("GET", self.region.base_url, f"champion-mastery/v4/champion-masteries/by-summoner/{self.id}")
return [lol.MasteryChampion(self, **champ_data) for champ_data in data]
async def fetch_mastery(self, id: int = None, name: str = None):
if name is not None:
id = self._client.get_champion_data(name=name)["key"]
data = await self._client.request(
"GET",
self.region.base_url,
f"champion-mastery/v4/champion-masteries/by-summoner/{self.id}/by-champion/{id}"
)
return lol.MasteryChampion(self, **data)