aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-07-14 22:44:45 +0100
committerGravatar GitHub <[email protected]>2024-07-14 22:44:45 +0100
commitd86a910ac774da0e4d0035e66a2c32595b00ea57 (patch)
tree249853513d9b6a72dd32c19e4f553682015f75d4
parentMerge pull request #3117 from python-discord/dependabot/pip/sentry-sdk-2.9.0 (diff)
parentSuppress ResponseCodeErrors when fetching alts in !user (diff)
Merge pull request #3120 from python-discord/jb3/bugfix/user-alts-response-code-error
Suppress ResponseCodeErrors when fetching alts in !user
-rw-r--r--bot/exts/info/information.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py
index e02559220..df79fbb80 100644
--- a/bot/exts/info/information.py
+++ b/bot/exts/info/information.py
@@ -343,8 +343,16 @@ class Information(Cog):
async def user_alt_count(self, user: MemberOrUser) -> tuple[str, int | str]:
"""Get the number of alts for the given member."""
- resp = await self.bot.api_client.get(f"bot/users/{user.id}")
- return ("Associated accounts", len(resp["alts"]) or "No associated accounts")
+ try:
+ resp = await self.bot.api_client.get(f"bot/users/{user.id}")
+ return ("Associated accounts", len(resp["alts"]) or "No associated accounts")
+ except ResponseCodeError as e:
+ # If user is not found, return a soft-error regarding this.
+ if e.response.status == 404:
+ return ("Associated accounts", "User not found in site database.")
+
+ # If we have any other issue, re-raise the exception
+ raise e
async def basic_user_infraction_counts(self, user: MemberOrUser) -> tuple[str, str]: