From 7f2555218ce2c44b19a658e851e2fff1f8093649 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 1 Feb 2024 18:27:08 -0500 Subject: [PATCH] fix(bible): allow bible_passage to be used for single verses --- bible/bible.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bible/bible.py b/bible/bible.py index c714120..ecbeb86 100644 --- a/bible/bible.py +++ b/bible/bible.py @@ -69,7 +69,9 @@ class Bible(commands.Cog): await ctx.send(str(e)) return passage = await self._get_passage(bible_id, f"{book_id}.{chapter}.{verse}") - await ctx.send(passage["content"]) + embed = Embed(title=f"{passage['reference']}", description=passage["content"].replace('¶ ', ''), color=await self.bot.get_embed_color(ctx.channel)) + embed.footer = f"{ctx.prefix}bible verse - Powered by API.bible" + await ctx.send(embed=embed) @bible.command(name="passage") async def bible_passage(self, ctx: commands.Context, book: str, passage: str): @@ -85,11 +87,14 @@ class Bible(commands.Cog): 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}") + if len(passage.split('-')) == 2: + 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}") + else: + passage = await self._get_passage(bible_id, f"{book_id}.{passage.replace(':', '.')}") embed = Embed(title=f"{passage['reference']}", description=passage["content"].replace('¶ ', ''), color=await self.bot.get_embed_color(ctx.channel)) + embed.footer = f"{ctx.prefix}bible passage - Powered by API.bible" await ctx.send(embed=embed)