fix(bible): return if error is encountered

This commit is contained in:
Seaswimmer 2024-02-01 17:59:19 -05:00
parent 660f561109
commit ad32a0fa67
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -44,11 +44,6 @@ class Bible(commands.Cog):
data = await response.json()
return data["data"]
async def _get_verse(self, bible_id: str, book_id: str, chapter: int, verse: int) -> dict:
"""Get a Bible verse from the API.bible API."""
passage_id = f"{book_id}.{chapter}.{verse}"
return await self._get_passage(bible_id, passage_id)
async def _get_books(self, bible_id: str) -> dict:
"""Get the books of the Bible from the API.bible API."""
url = f"https://api.scripture.api.bible/v1/bibles/{bible_id}/books"
@ -57,22 +52,6 @@ class Bible(commands.Cog):
data = await response.json()
return data["data"]
async def _get_chapters(self, bible_id: str, book_id: str) -> dict:
"""Get the chapters of a book of the Bible from the API.bible API."""
url = f"https://api.scripture.api.bible/v1/bibles/{bible_id}/books/{book_id}/chapters"
headers = await self.bot.get_shared_api_tokens("api.bible")
async with self.session.get(url, headers=headers) as response:
data = await response.json()
return data["data"]
async def _get_verses(self, bible_id: str, book_id: str, chapter: int) -> dict:
"""Get the verses of a chapter of a book of the Bible from the API.bible API."""
url = f"https://api.scripture.api.bible/v1/bibles/{bible_id}/books/{book_id}/chapters/{chapter}/verses"
headers = await self.bot.get_shared_api_tokens("api.bible")
async with self.session.get(url, headers=headers) as response:
data = await response.json()
return data["data"]
@commands.group(autohelp=True)
async def bible(self, ctx: commands.Context):
"""Core command for the Bible cog."""
@ -85,5 +64,6 @@ class Bible(commands.Cog):
book_id = await self.translate_book_name(bible_id, book)
except ValueError as e:
await ctx.send(str(e))
return
passage = await self._get_verse(bible_id, book_id, chapter, verse)
await ctx.send(passage["content"])