From e9252eff541e04c4e33fd1ad5d6421aefa99c4de Mon Sep 17 00:00:00 2001 From: levbernstein Date: Tue, 16 Nov 2021 17:22:07 -0500 Subject: [PATCH] Brawlstats command displays clan name below stats, resolves #13 --- Bot.py | 2 +- README.MD | 2 +- bb_test.py | 2 +- brawl.py | 28 ++++++++++++---------------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Bot.py b/Bot.py index ef8e2bd..e1a4d8f 100644 --- a/Bot.py +++ b/Bot.py @@ -1,5 +1,5 @@ """ Beardless Bot """ -__version__ = "Full Release 1.6.9" +__version__ = "Full Release 1.6.10" import asyncio from random import choice, randint diff --git a/README.MD b/README.MD index e9777ce..44303fc 100644 --- a/README.MD +++ b/README.MD @@ -1,6 +1,6 @@ # Beardless Bot -### Full Release 1.6.9 +### Full Release 1.6.10 A Discord bot supporting gambling (coin flips and blackjack), a currency system, fun facts, and more. diff --git a/bb_test.py b/bb_test.py index dfc35cd..0dbc566 100644 --- a/bb_test.py +++ b/bb_test.py @@ -665,7 +665,7 @@ def test_getStats(): user.id = 196354892208537600 emb = brawl.getStats(user, brawlKey) assert emb.footer.text == "Brawl ID 7032472" - assert len(emb.fields) == 3 + assert len(emb.fields) in (3, 4) def test_getClan(): diff --git a/brawl.py b/brawl.py index 5836615..829515d 100644 --- a/brawl.py +++ b/brawl.py @@ -275,7 +275,6 @@ def getRank(target: discord.Member, brawlKey: str) -> discord.Embed: def getStats(target: discord.Member, brawlKey: str) -> discord.Embed: - # TODO: add clan below name, make this look not terrible brawlID = fetchBrawlID(target.id) if not brawlID: return bbEmbed( @@ -298,9 +297,9 @@ def getStats(target: discord.Member, brawlKey: str) -> discord.Embed: emb = ( bbEmbed("Brawlhalla Stats for " + r["name"]) .set_footer(text=f"Brawl ID {brawlID}") + .add_field(name="Name", value=r["name"]) .add_field(name="Overall W/L", value=embVal) .set_author(name=str(target), icon_url=target.avatar_url) - .add_field(name="Name", value=r["name"]) ) if "legends" in r: topUsed = topWinrate = topDPS = topTTK = None @@ -335,21 +334,18 @@ def getStats(target: discord.Member, brawlKey: str) -> discord.Embed: ) if all((topUsed, topWinrate, topDPS, topTTK)): emb.add_field( - value=( - "**Most Played:** {}\n**Highest Winrate:** {}, {}%\n" - "**Highest Avg DPS:** {}, {}\n**Shortest Avg TTK:" - "** {}, {}s" - ).format( - topUsed[0], - topWinrate[0], - topWinrate[1], - topDPS[0], - topDPS[1], - topTTK[0], - topTTK[1] - ), - name="Legend Stats (20 game min)" + name="Legend Stats (20 game min)", value=( + f"**Most Played:** {topUsed[0]}\n**Highest Winrate:" + f"** {topWinrate[0]}, {topWinrate[1]}%\n**Highest Avg" + f" DPS:** {topDPS[0]}, {topDPS[1]}\n**Shortest Avg TTK:" + f"** {topTTK[0]}, {topTTK[1]}s" + ) ) + if "clan" in r: + emb.add_field( + name="Clan", + value=f"{r['clan']['clan_name']}\nClan ID: {r['clan']['clan_id']}" + ) return emb