diff options
| author | 2019-09-14 14:39:58 +0200 | |
|---|---|---|
| committer | 2019-09-14 14:39:58 +0200 | |
| commit | bbbdfcec41c06eaf0d031d7f2a58f111e8e88a16 (patch) | |
| tree | 434aa2e5227834a81a7b0e75be1f4a6b7db00721 /bot/utils/moderation.py | |
| parent | We now also detect bot tokens outside quotes. (diff) | |
Make ResponseErrorCode handle non-JSON response
The previous commit assumed the API respone to always be JSON. This
leads to issues when that is not the case, such as when the API is
completely unreachable (text/html 404 response).
Updated the ResponseErrorCode exception to account for that and
updated the moderation util `post_infraction` to reflect that.
Diffstat (limited to 'bot/utils/moderation.py')
| -rw-r--r-- | bot/utils/moderation.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/bot/utils/moderation.py b/bot/utils/moderation.py index b295e4649..7860f14a1 100644 --- a/bot/utils/moderation.py +++ b/bot/utils/moderation.py @@ -37,7 +37,7 @@ async def post_infraction( try: response = await ctx.bot.api_client.post('bot/infractions', json=payload) except ResponseCodeError as exp: - if exp.status == 400 and 'user' in exp.response_data: + if exp.status == 400 and 'user' in exp.response_json: log.info( f"{ctx.author} tried to add a {type} infraction to `{user.id}`, " "but that user id was not found in the database." |