mirror of
https://github.com/artiemis/artemis.git
synced 2026-02-14 08:31:55 +00:00
trace: upload discord cdn images to litterbox
This commit is contained in:
parent
1ce86069fc
commit
bf41bbb0ec
@ -237,10 +237,14 @@ class Anime(commands.Cog):
|
|||||||
|
|
||||||
await ctx.typing()
|
await ctx.typing()
|
||||||
|
|
||||||
headers = {"User-Agent": ctx.bot.user_agent}
|
if "discord" in url:
|
||||||
async with self.bot.session.get(
|
async with self.bot.session.get(url) as r:
|
||||||
f"https://api.trace.moe/search?anilistInfo&url={url}", headers=headers
|
if r.status != 200:
|
||||||
) as r:
|
return await ctx.reply(f"Discord CDN Error: {r.status} {r.reason}")
|
||||||
|
buff = BytesIO(await r.read())
|
||||||
|
url = await self.bot.litterbox.upload(buff)
|
||||||
|
|
||||||
|
async with self.bot.session.get(f"https://api.trace.moe/search?anilistInfo&url={url}") as r:
|
||||||
if r.status == 402:
|
if r.status == 402:
|
||||||
raise ArtemisError("Error: The bot has reached max API search quota for the month.")
|
raise ArtemisError("Error: The bot has reached max API search quota for the month.")
|
||||||
json = await r.json()
|
json = await r.json()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user