diff options
author | 2024-07-14 22:44:45 +0100 | |
---|---|---|
committer | 2024-07-14 22:44:45 +0100 | |
commit | d86a910ac774da0e4d0035e66a2c32595b00ea57 (patch) | |
tree | 249853513d9b6a72dd32c19e4f553682015f75d4 | |
parent | Merge pull request #3117 from python-discord/dependabot/pip/sentry-sdk-2.9.0 (diff) | |
parent | Suppress 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.py | 12 |
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]: |