From 1c8037274b66511bc61891c547c4b9c5a934e432 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 1 Feb 2024 18:20:48 -0500 Subject: [PATCH] feat(bible): make the bible_passage command have an embed --- bible/bible.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bible/bible.py b/bible/bible.py index d12dd95..ab5bd52 100644 --- a/bible/bible.py +++ b/bible/bible.py @@ -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)