aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar shtlrs <[email protected]>2024-01-01 22:51:27 +0100
committerGravatar shtlrs <[email protected]>2024-01-01 22:53:54 +0100
commitbbb1b5d4a71795eddc8caccfe7d52f2241eb8b15 (patch)
treeaf5a5e90959e237686f7c68adee5e0bd4d3c4be6
parentbump ruff to 0.1.9 (diff)
display correct text upon missing activity/messages
This also updates the return type hints to reflect what's being returned
-rw-r--r--bot/exts/info/information.py14
1 files 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."""