From 10df67768736914493fd4f4d38681117da596bed Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sat, 13 Jul 2024 21:07:05 +0100 Subject: Suppress ResponseCodeErrors when fetching alts in !user --- bot/exts/info/information.py | 12 ++++++++++-- 1 file 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]: -- cgit v1.2.3