diff --git a/harambot/cogs/yahoo.py b/harambot/cogs/yahoo.py index 3e36106..28d09a7 100644 --- a/harambot/cogs/yahoo.py +++ b/harambot/cogs/yahoo.py @@ -141,7 +141,9 @@ async def trade(self, interaction: discord.Interaction): player_set0.append(player["name"]) api_details = ( self.get_player_text( - self.yahoo_api.get_player_details(player["name"], guild_id=interaction.guild_id) + self.yahoo_api.get_player_details( + player["name"], guild_id=interaction.guild_id + ) ) + "\n" ) @@ -155,7 +157,9 @@ async def trade(self, interaction: discord.Interaction): player_set1_details = "" for player in latest_trade["tradee_players"]: player_set1.append(player["name"]) - player_details = self.yahoo_api.get_player_details(player["name"], guild_id=interaction.guild_id) + player_details = self.yahoo_api.get_player_details( + player["name"], guild_id=interaction.guild_id + ) if player_details is None: await interaction.followup.send(self.error_message) return @@ -267,13 +271,11 @@ def get_player_embed(self, player): value=player["stats"]["total_points"], inline=False, ) - del player["stats"]["player_id"] - del player["stats"]["name"] - del player["stats"]["position_type"] - for key, value in player["stats"].items(): - if key == "total_points": - continue - embed.add_field(name=key, value=value) + if len(player["stats"].items()) < 20: + for key, value in player["stats"].items(): + if key == "total_points": + continue + embed.add_field(name=key, value=value) return embed def get_player_text(self, player): diff --git a/harambot/yahoo_api.py b/harambot/yahoo_api.py index 680a9c7..41562f8 100644 --- a/harambot/yahoo_api.py +++ b/harambot/yahoo_api.py @@ -190,15 +190,17 @@ def get_player_details(self, player_name, guild_id, week=None): req_type="week", week=week, )[0] - if len(stats) > 25: - player["stats"] = stats[:20] - else: - player["stats"] = stats else: - player["stats"] = self.league().player_stats( + stats = self.league().player_stats( [player["player_id"]], req_type="season", )[0] + del stats["player_id"] + del stats["name"] + del stats["position_type"] + if len(stats) > 20: + stats = {k: v for k, v in stats.items() if v != 0.0} + player["stats"] = stats return player except Exception: logger.exception(