async def getErbsLeaderboard(self, ctx, gameMode: str): """Gets Global Leaderboard of a specific game mode.""" mode = gameModeSwitch(gameMode) if not mode: embedVar.add_field( name='getErbsLeaderboard', value= f'Game mode was incorrect. Please input any ONE of these:| Solo(s) | Duo(s) | Squad(s) |' ) await ctx.send(embed=embedVar) return leaders = await getLeaderboard(baseUrl=BASE_URL, seasonId=currentSeasonId, teamMode=mode, apiKey=API_KEY) if leaders: embeds: list = [] i = 1 for page in leaders: embeds.append( discord.Embed(color=ctx.author.color).add_field( name=f"Rank {i}-{i+24}", value=f"{''.join(page)}")) i += 25 paginator = Pagination.AutoEmbedPaginator(ctx) await paginator.run(embeds) else: embedVar.add_field(name="getErbsSquadLeaderboard", value=f"No Leaderboard was found.", inline=False) await ctx.send(embed=embeds)
async def getItemTree(self, ctx, *, itemName: str): item = await findItem(itemName) fields = parseItem(item) embeds: list = [] tree: dict = {} embed = discord.Embed() if 'makeMaterial1' in item and item['makeMaterial1']: parseBuildTree(item['makeMaterial1'], item['makeMaterial2'], item['name'], tree) fields.append( ("Builds From: ", f"```{tree[item['name']][0]} + {tree[item['name']][1]}```", True)) print(tree) i = 0 for name, value, inline in fields: if i < 25: embed.add_field(name=name, value=value, inline=inline) i += 1 else: i = 0 embeds.append(embed) embed = discord.Embed() embed.add_field(name=name, value=value, inline=inline) embeds.append(embed) if tree: for node in tree: print(tree[node]) if item['name'] == node: continue else: embed = discord.Embed() item = await findItem(node) fields: list = parseItem(item) fields.append( ("Builds From: ", f"```{tree[node][0]} + {tree[node][1]}```", True)) i = 0 for name, value, inline in fields: if i < 25: embed.add_field(name=name, value=value, inline=inline) i += 1 else: i = 0 embeds.append(embed) embed = discord.Embed() embed.add_field(name=name, value=value, inline=inline) embeds.append(embed) for x in range(len(embeds)): embeds[x].set_thumbnail(url=getThumbnailUrl()) paginator = Pagination.AutoEmbedPaginator(ctx) await paginator.run(embeds)
async def getMatchHistory(self, ctx, gameId: Greedy[int] = None, nickname: str = ''): """Gets the author's match history in a specific game mode. If no nickname passed, uses linked account assigned to user. If a gameId is passed in, will user's stats for that game.""" user: dict if nickname: user = await getUser(baseUrl=BASE_URL, nickname=nickname, apiKey=API_KEY) else: erbsUsername = await getAccountName(ctx.author.name) if not erbsUsername: embedVar.add_field( name="getMatchHistory", value= f"No erbs account name was found linked to this user.", inline=False) await ctx.send(embed=embedVar) return else: user = (await getUser(baseUrl=BASE_URL, nickname=erbsUsername, apiKey=API_KEY)) if not user: embedVar.add_field(name="getMatchHistory", value=f"User was not found in ERBS.", inline=False) await ctx.send(embed=embedVar) return else: history = await getMatchHistory(baseUrl=BASE_URL, userId=user['userNum'], apiKey=API_KEY) if not history: embedVar.add_field(name="getMatchHistory", value=f"No history was found for this user.", inline=False) await ctx.send(embed=embedVar) return elif gameId: while (True): match = await findGameStats(matchHistory=history, gameId=gameId[0]) if not match: if not 'next' in history: embedVar.add_field( name="getMatchHistory", value= f"No game with that id was found for this user.", inline=False) await ctx.send(embed=embedVar) return else: history = await getMatchHistory(baseUrl=BASE_URL, userId=user['userNum'], apiKey=API_KEY, nextId=history['next']) continue else: embeds: list = [] page0 = [ ("Game ID", f"```{match['id']}```", False), ("Character", f"```{match['character']}```", True), ("Ranked", f"```{match['placement']}```", True), ("Game Mode", f"```{match['mode']}```", True), ("Kills", f"```{match['kills']}```", True), ("Assists", f"```{match['assists']}```", True), ("Hunts", f"```{match['hunts']}```", True), ("Max HP", f"```{match['maxHp']}```", True), ("Max SP", f"```{match['maxSp']}```", True), ("Attack Power", f"```{match['attackPower']}```", True), ("Defense", f"```{match['defense']}```", True), ("HP Regen", f"```{match['hpRegen']}```", True), ("SP Regen", f"```{match['spRegen']}```", True), ("Attack Speed", f"```{match['attackSpeed']}```", True), ("Move Speed", f"```{match['moveSpeed']}```", True), ("Sight Range", f"```{match['sightRange']}```", True), ("Attack Range", f"```{match['attackRange']}```", True), ("Critical Chance", f"```{match['criticalStrikeChance']}```", True), ("Critical Damage", f"```{match['criticalStrikeDamage']}```", True), ("Cooldown Reduction", f"```{match['coolDownReduction']}```", True), ("LifeSteal", f"```{match['lifeSteal']}```", True) ] skills = "" for skill in match['skillLevelOrder']: skills = skills + f"{skill}: {match['skillLevelOrder'][skill]}" mastery = "" for masteryCode in match['masteryLevels']: mastery = mastery + f"```{masteryCode}: {match['masteryLevels'][masteryCode]}```" page1 = [("Level", f"```{match['level']}```", False), ("Mastery", f"{mastery}", False), ("Skill Order", f"```{skills}```", False), ("Weapon", f"```{match['weapon']}```", True), ("Chest", f"```{match['chest']}```", True), ("Head", f"```{match['head']}```", True), ("Gloves", f"```{match['gloves']}```", True), ("Boots", f"```{match['boots']}```", True), ("Accessory", f"```{match['accessory']}```", True)] embeds.append(discord.Embed()) for name, value, inline in page0: embeds[0].add_field(name=name, value=value, inline=inline) embeds.append(discord.Embed()) for name, value, inline in page1: embeds[1].add_field(name=name, value=value, inline=inline) for x in range(len(embeds)): embeds[x].set_thumbnail(url=getThumbnailUrl()) paginator = Pagination.AutoEmbedPaginator(ctx) await paginator.run(embeds) return else: embeds: list = [] while True: matchHistory = history["userGames"] for match in matchHistory: fields = [ ("Game: ", f"```{match['gameId']}```", False), ("Mode: ", f"```{gameModeSwitch(match['matchingTeamMode'])}```", False), ("Level: ", f"```{match['characterLevel']}```", False), ("Placement: ", f"```{match['gameRank']}```", False), ("Kills: ", f"```{match['playerKill']}```", False), ("Assists: ", f"```{match['playerAssistant']}```", False), ("Hunts: ", f"```{match['monsterKill']}```", False) ] embeds.append(discord.Embed()) for name, value, inline in fields: embeds[len(embeds) - 1].add_field(name=name, value=value, inline=inline) for x in range(len(embeds)): embeds[x].set_thumbnail(url=getThumbnailUrl()) if 'next' in history: history = await getMatchHistory(baseUrl=BASE_URL, userId=user['userNum'], apiKey=API_KEY, nextId=history['next']) else: break paginator = Pagination.AutoEmbedPaginator(ctx) await paginator.run(embeds)