feat(bible): make the bible_passage command have an embed
Some checks failed
Actions / Lint Code (Pylint) (push) Failing after 16s
Actions / Build Documentation (MkDocs) (push) Successful in 14s

This commit is contained in:
Seaswimmer 2024-02-01 18:20:48 -05:00
parent 162d669502
commit 1c8037274b
Signed by: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -9,6 +9,7 @@ import aiohttp
import json
import logging
from discord import Embed
from redbot.core import commands, Config
from redbot.core.bot import Red
@ -33,7 +34,7 @@ class Bible(commands.Cog):
books = await self._get_books(bible_id)
for book in books:
if book_name == book['abbreviation'] or book_name == book['name']:
return book['id']
return book['id'], book['name']
raise ValueError(f"Book {book_name} not found.")
async def _get_passage(self, bible_id: str, passage_id: str) -> dict:
@ -77,11 +78,18 @@ class Bible(commands.Cog):
Example usage:
`[p]bible passage John 3:16-3:17`"""
bible_id = await self.config.bible()
try:
book_id = await self.translate_book_name(bible_id, book)
book_id, book_name = await self.translate_book_name(bible_id, book)
except ValueError as e:
await ctx.send(str(e))
return
from_verse, to_verse = passage.replace(":", ".").split("-")
if '.' not in to_verse:
to_verse = f"{from_verse.split('.')[0]}.{to_verse}"
passage = await self._get_passage(bible_id, f"{book_id}.{from_verse}-{book_id}.{to_verse}")
await ctx.send(passage["content"])
embed = Embed(title=f"{book_name} {passage['reference']}", description=passage["content"], color=await self.bot.get_embed_color(ctx.channel))
await ctx.send(embed=embed)