From bbb1b5d4a71795eddc8caccfe7d52f2241eb8b15 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 1 Jan 2024 22:51:27 +0100 Subject: display correct text upon missing activity/messages This also updates the return type hints to reflect what's being returned --- bot/exts/info/information.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py index c7ee9065c..8ef68bd9e 100644 --- a/bot/exts/info/information.py +++ b/bot/exts/info/information.py @@ -420,7 +420,7 @@ class Information(Cog): return "Nominations", "\n".join(output) - async def user_messages(self, user: MemberOrUser) -> tuple[bool | str, tuple[str, str]]: + async def user_messages(self, user: MemberOrUser) -> tuple[str, str]: """ Gets the amount of messages for `member`. @@ -435,15 +435,21 @@ class Information(Cog): if e.status == 404: activity_output = "No activity" else: - activity_output.append(f"{user_activity['total_messages']:,}" or "No messages") - activity_output.append(f"{user_activity['activity_blocks']:,}" or "No activity") + total_message_text = ( + f"{user_activity['total_messages']:,}" if user_activity["total_messages"] else "No messages" + ) + activity_blocks_text = ( + f"{user_activity['activity_blocks']:,}" if user_activity["activity_blocks"] else "No activity" + ) + activity_output.append(total_message_text) + activity_output.append(activity_blocks_text) activity_output = "\n".join( f"{name}: {metric}" for name, metric in zip(["Messages", "Activity blocks"], activity_output, strict=True) ) - return ("Activity", activity_output) + return "Activity", activity_output def format_fields(self, mapping: Mapping[str, Any], field_width: int | None = None) -> str: """Format a mapping to be readable to a human.""" -- cgit v1.2.3