diff --git a/src/pluralkit/bot/embeds.py b/src/pluralkit/bot/embeds.py index 8a40b76d..cb6ea76b 100644 --- a/src/pluralkit/bot/embeds.py +++ b/src/pluralkit/bot/embeds.py @@ -121,10 +121,7 @@ async def member_card(conn, member: Member) -> discord.Embed: card.colour = int(member.color, 16) if member.birthday: - bday_val = member.birthday.strftime("%b %d, %Y") - if member.birthday.year == 1: - bday_val = member.birthday.strftime("%b %d") - card.add_field(name="Birthdate", value=bday_val) + card.add_field(name="Birthdate", value=member.birthday_string()) if member.pronouns: card.add_field(name="Pronouns", value=truncate_field_body(member.pronouns)) @@ -236,7 +233,7 @@ def member_list(system: System, all_members: List[Member], current_page: int, pa for member in all_members[current_page*page_size:current_page*page_size+page_size]: member_description = "**ID**: {}\n".format(member.hid) if member.birthday: - member_description += "**Birthday:** {}\n".format(member.birthday.isoformat()) + member_description += "**Birthday:** {}\n".format(member.birthday_string()) if member.pronouns: member_description += "**Pronouns:** {}\n".format(member.pronouns) if member.description: diff --git a/src/pluralkit/member.py b/src/pluralkit/member.py index 0f1a8341..442c4d63 100644 --- a/src/pluralkit/member.py +++ b/src/pluralkit/member.py @@ -161,4 +161,12 @@ class Member(namedtuple("Member", return await db.get_system(conn, self.system) async def message_count(self, conn) -> int: - return await db.get_member_message_count(conn, self.id) \ No newline at end of file + return await db.get_member_message_count(conn, self.id) + + def birthday_string(self) -> Optional[str]: + if not self.birthday: + return None + + if self.birthday.year == 1: + return self.birthday.strftime("%b %d") + return self.birthday.strftime("%b %d, %Y") \ No newline at end of file