Add Images command

Clean up Animals command
This commit is contained in:
Michał Gdula 2023-09-08 21:53:33 +01:00
parent 68d638c7ee
commit 4e685393de
12 changed files with 283 additions and 27 deletions

View file

@ -15,7 +15,6 @@ class Animals(commands.Cog):
@commands.command()
async def animal(self, ctx, animal):
animal = animal.lower().strip() or "racc"
animal_filename = f"{animal}.png"
if animal not in TINYFOX_ANIMALS:
await ctx.reply(
@ -27,17 +26,16 @@ class Animals(commands.Cog):
return
async with ctx.typing():
animal_image_request = requests.get(
f"https://api.tinyfox.dev/img?animal={animal}"
).content
animal_image = BytesIO(animal_image_request)
request = requests.get(f"https://api.tinyfox.dev/img?animal={animal}&json")
animal_image = BytesIO(request.content)
animal_image.seek(0)
animal_file = discord.File(animal_image, filename=animal_filename)
animal_file = discord.File(animal_image, filename="image.png")
embed = discord.Embed(
title="Animal",
description=f"Here's a random {animal}!",
title=animal.capitalize(),
colour=discord.Colour.orange(),
).set_image(url="attachment://" + animal_filename)
).set_image(
url="attachment://image.png"
)
await ctx.reply(embed=embed, file=animal_file, mention_author=False)