<reponame>STEUSSO/steusso<gh_stars>0
from discord import Embed
from discord.ext import commands
from requests.models import HTTPError
from riotwatcher import LolWatcher
from os import getenv
from dotenv import load_dotenv
from json import load

load_dotenv(dotenv_path="config")
prefix = getenv("PREFIX")

class ladder(commands.Cog):
    def __init__(
        self,
        client
    ):
        self.client = client

    @commands.command()
    async def ladder(
        self,
        ctx,
        *,
        region : str = None
    ):
        watcher = LolWatcher(getenv("API_KEY"))
        data = watcher.league.challenger_by_queue(region, "RANKED_SOLO_5x5")
        lps = []
        for i in range(0, len(data["entries"])):
            lp = int(data["entries"][i]["leaguePoints"])
            name = data["entries"][i]["summonerName"]
            y = f"{lp} - {name}"
            lps.append(y)
        await ctx.send(lps)