Skip to content

Commit

Permalink
Group unnamed families at the bottom of stats
Browse files Browse the repository at this point in the history
Correctly pluralise the message
Convert capitals to capitalised
  • Loading branch information
connorhsm committed Aug 5, 2023
1 parent a262897 commit 50bff2d
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 5 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mysql-connector-python = "*"
python-dotenv = "*"
python-dateutil = "*"
requests = "*"
inflect = "*"

[dev-packages]

Expand Down
141 changes: 140 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions dictator/cogs/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

import socket
from datetime import date
import inflect

class Stats(commands.Cog):

def __init__(self, dictator: commands.Bot) -> None:
self.dictator = dictator
self.p = inflect.engine()

@commands.Cog.listener()
async def on_ready(self) -> None:
Expand Down Expand Up @@ -126,13 +128,17 @@ async def process_player_list(self, parsed_player_list: str) -> str:

async def format_family_list(self, family_list: str) -> str:
formatted_families = ""
unnamed_families = 0
for family in family_list:
family_name = family[1]
family_name = family[1].title()
if not family_name:
family_name = "UNNAMED"
formatted_families += f"{family_name}: {family[2]}\n"
unnamed_families += 1
continue
formatted_families += f"{family[2]} in {family_name}\n"

formatted_families += f"\n*v1, subject to change*"
if unnamed_families:
formatted_families += f"{unnamed_families} Unnamed {self.p.plural('family', unnamed_families)}"
formatted_families += f"\n\n*v1, subject to change*"
return formatted_families

async def open_collective_forecast_embed(self) -> discord.Embed:
Expand Down

0 comments on commit 50bff2d

Please sign in to comment.