diff options
| author | 2019-12-22 14:43:24 -0800 | |
|---|---|---|
| committer | 2019-12-22 14:43:24 -0800 | |
| commit | ae6eefbdcad5dbbd02edc33adba8e481be14fa2b (patch) | |
| tree | c54b0c9580b01438ce0fd25bf952ac3c6196c8cd | |
| parent | Use more specific error message for infraction DM user fetch (diff) | |
Show only status code in Discord msg when infraction post fails
When debugging, the response_text exceeds the character limit since it's
basically an entire HTML document.
| -rw-r--r-- | bot/cogs/moderation/utils.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/bot/cogs/moderation/utils.py b/bot/cogs/moderation/utils.py index 160ced501..73335ca30 100644 --- a/bot/cogs/moderation/utils.py +++ b/bot/cogs/moderation/utils.py @@ -56,10 +56,7 @@ async def post_user(ctx: Context, user: MemberObject) -> t.Optional[dict]: return response except ResponseCodeError as e: log.error(f"Failed to add user {user.id} to the DB. {e}") - await ctx.send( - ":x: The attempt to add the user to the DB failed: " - f"{e.status}, {e.response_text if e.response_text else 'no message received'}." - ) + await ctx.send(f":x: The attempt to add the user to the DB failed: status {e.status}") async def post_infraction( @@ -90,14 +87,14 @@ async def post_infraction( try: response = await ctx.bot.api_client.post('bot/infractions', json=payload) return response - except ResponseCodeError as exp: - if exp.status == 400 and 'user' in exp.response_json: + except ResponseCodeError as e: + if e.status == 400 and 'user' in e.response_json: # Only one attempt to add the user to the database, not two: if not should_post_user or await post_user(ctx, user) is None: return else: log.exception(f"Unexpected error while adding an infraction for {user}:") - await ctx.send(":x: There was an error adding the infraction.") + await ctx.send(f":x: There was an error adding the infraction: status {e.status}.") return |