forked from blizzthewolf/SeaCogs
fix(bible): don't use fums on an api route that doesn't support it
This commit is contained in:
parent
7597dcf5f7
commit
83edd36d6b
1 changed files with 3 additions and 23 deletions
|
@ -107,16 +107,12 @@ class Bible(commands.Cog):
|
||||||
"""Get the books of the Bible from the API.bible API."""
|
"""Get the books of the Bible from the API.bible API."""
|
||||||
url = f"https://api.scripture.api.bible/v1/bibles/{bible_id}/books"
|
url = f"https://api.scripture.api.bible/v1/bibles/{bible_id}/books"
|
||||||
headers = await self.bot.get_shared_api_tokens("api.bible")
|
headers = await self.bot.get_shared_api_tokens("api.bible")
|
||||||
params = {
|
|
||||||
"fums-version": "3",
|
|
||||||
}
|
|
||||||
|
|
||||||
async with self.session.get(url, headers=headers, params=params) as response:
|
async with self.session.get(url, headers=headers) as response:
|
||||||
data = await response.json()
|
data = await response.json()
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"_get_books executed with a response code of: %s\nURL: %s\n%s",
|
"_get_books executed with a response code of: %s\n%s",
|
||||||
response.status,
|
response.status,
|
||||||
response.url,
|
|
||||||
json.dumps(data),
|
json.dumps(data),
|
||||||
)
|
)
|
||||||
if response.status == 401:
|
if response.status == 401:
|
||||||
|
@ -125,23 +121,7 @@ class Bible(commands.Cog):
|
||||||
raise bible.errors.BibleAccessError()
|
raise bible.errors.BibleAccessError()
|
||||||
if response.status == 503:
|
if response.status == 503:
|
||||||
raise bible.errors.ServiceUnavailable()
|
raise bible.errors.ServiceUnavailable()
|
||||||
|
return data["data"]
|
||||||
fums_url = "https://fums.api.bible/f3"
|
|
||||||
fums_params = {
|
|
||||||
"t": data["meta"]["fumsToken"],
|
|
||||||
"dId": "discord-" + str(self.bot.user.id),
|
|
||||||
"sId": "discord-" + str(ctx.message.created_at.timestamp()),
|
|
||||||
"uId": ctx.author.id,
|
|
||||||
}
|
|
||||||
|
|
||||||
async with self.session.get(fums_url, params=fums_params) as response:
|
|
||||||
fums_data = await response.json()
|
|
||||||
self.logger.debug(
|
|
||||||
"_get_books FUMS executed with a response code of: %s\n%s",
|
|
||||||
response.status,
|
|
||||||
json.dumps(fums_data),
|
|
||||||
)
|
|
||||||
return data["data"]
|
|
||||||
|
|
||||||
async def _get_chapters(
|
async def _get_chapters(
|
||||||
self, ctx: commands.Context, bible_id: str, book_id: str
|
self, ctx: commands.Context, bible_id: str, book_id: str
|
||||||
|
|
Loading…
Reference in a new issue