fix(bible): allow bible_passage to be used for single verses

This commit is contained in:
Seaswimmer 2024-02-01 18:27:08 -05:00
parent 5652e13ad7
commit 7f2555218c
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -69,7 +69,9 @@ class Bible(commands.Cog):
await ctx.send(str(e)) await ctx.send(str(e))
return return
passage = await self._get_passage(bible_id, f"{book_id}.{chapter}.{verse}") 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") @bible.command(name="passage")
async def bible_passage(self, ctx: commands.Context, book: str, passage: str): 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)) await ctx.send(str(e))
return return
from_verse, to_verse = passage.replace(":", ".").split("-") if len(passage.split('-')) == 2:
if '.' not in to_verse: from_verse, to_verse = passage.replace(":", ".").split("-")
to_verse = f"{from_verse.split('.')[0]}.{to_verse}" 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}") 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 = 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) await ctx.send(embed=embed)