diff --git a/bible/bible.py b/bible/bible.py index 519a45c..e8b5783 100644 --- a/bible/bible.py +++ b/bible/bible.py @@ -5,6 +5,7 @@ # ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ | # |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_| +import json import logging import random @@ -63,8 +64,11 @@ class Bible(commands.Cog): } async with self.session.get(url, headers=headers, params=params) as response: + data = await response.json() self.logger.debug( - "_get_passage executed with a response code of: %s", response.status + "_get_passage executed with a response code of: %s\n%s", + response.status, + json.dumps(data), ) if response.status == 401: raise bible.errors.Unauthorized() @@ -72,7 +76,6 @@ class Bible(commands.Cog): raise bible.errors.BibleAccessError() if response.status == 404: raise bible.errors.NotFound() - data = await response.json() return data["data"] async def _get_books(self, bible_id: str) -> dict: @@ -81,14 +84,16 @@ class Bible(commands.Cog): headers = await self.bot.get_shared_api_tokens("api.bible") async with self.session.get(url, headers=headers) as response: + data = await response.json() self.logger.debug( - "_get_books executed with a response code of: %s", response.status + "_get_books executed with a response code of: %s\n%s", + response.status, + json.dumps(data), ) if response.status == 401: raise bible.errors.Unauthorized() if response.status == 403: raise bible.errors.BibleAccessError() - data = await response.json() return data["data"] async def _get_chapters(self, bible_id: str, book_id: str) -> dict: @@ -97,14 +102,16 @@ class Bible(commands.Cog): headers = await self.bot.get_shared_api_tokens("api.bible") async with self.session.get(url, headers=headers) as response: + data = await response.json() self.logger.debug( - "_get_chapters executed with a response code of: %s", response.status + "_get_chapters executed with a response code of: %s\n%s", + response.status, + json.dumps(data), ) if response.status == 401: raise bible.errors.Unauthorized() if response.status == 403: raise bible.errors.BibleAccessError() - data = await response.json() return data["data"] async def _get_verses(self, bible_id: str, book_id: str, chapter: int) -> dict: @@ -113,14 +120,16 @@ class Bible(commands.Cog): headers = await self.bot.get_shared_api_tokens("api.bible") async with self.session.get(url, headers=headers) as response: + data = await response.json() self.logger.debug( - "_get_verses executed with a response code of: %s", response.status + "_get_verses executed with a response code of: %s\n%s", + response.status, + json.dumps(data), ) if response.status == 401: raise bible.errors.Unauthorized() if response.status == 403: raise bible.errors.BibleAccessError() - data = await response.json() return data["data"] @commands.group(autohelp=True)