forked from blizzthewolf/SeaCogs
feat(bible): make the bible_passage command have an embed
This commit is contained in:
parent
162d669502
commit
1c8037274b
1 changed files with 11 additions and 3 deletions
|
@ -9,6 +9,7 @@ import aiohttp
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from discord import Embed
|
||||||
from redbot.core import commands, Config
|
from redbot.core import commands, Config
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ class Bible(commands.Cog):
|
||||||
books = await self._get_books(bible_id)
|
books = await self._get_books(bible_id)
|
||||||
for book in books:
|
for book in books:
|
||||||
if book_name == book['abbreviation'] or book_name == book['name']:
|
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.")
|
raise ValueError(f"Book {book_name} not found.")
|
||||||
|
|
||||||
async def _get_passage(self, bible_id: str, passage_id: str) -> dict:
|
async def _get_passage(self, bible_id: str, passage_id: str) -> dict:
|
||||||
|
@ -77,11 +78,18 @@ class Bible(commands.Cog):
|
||||||
Example usage:
|
Example usage:
|
||||||
`[p]bible passage John 3:16-3:17`"""
|
`[p]bible passage John 3:16-3:17`"""
|
||||||
bible_id = await self.config.bible()
|
bible_id = await self.config.bible()
|
||||||
|
|
||||||
try:
|
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:
|
except ValueError as e:
|
||||||
await ctx.send(str(e))
|
await ctx.send(str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
from_verse, to_verse = passage.replace(":", ".").split("-")
|
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}")
|
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)
|
||||||
|
|
Loading…
Reference in a new issue