1
0
Fork 0
mirror of synced 2024-06-09 22:24:32 +12:00

Clean up API method, man I must have made this a while ago, it's ugly

This commit is contained in:
Dan Hess 2020-04-13 15:07:54 -05:00
parent 04c029b368
commit 13e20f73ad

View file

@ -14,16 +14,12 @@ class Images(commands.Cog):
async def horse_noodle_api(self, ctx, animal): async def horse_noodle_api(self, ctx, animal):
data = await utils.request(f"http://hrsendl.com/api/{animal}") data = await utils.request(f"http://hrsendl.com/api/{animal}")
if data is None: try:
await ctx.send(f"I couldn't connect! Sorry no {animal}s right now ;w;") url = data["data"]["file_url_size_large"]
return filename = data["data"]["file_name"]
result = data['data'] except (KeyError, TypeError):
filename = result.get('file_name') return await ctx.send(f"I couldn't connect! Sorry no {animal}s right now ;w;")
url = result.get('file_url_size_large') else:
if url is None:
await ctx.send(f"I couldn't connect! Sorry no {animal}s right now ;w;")
return
image = await utils.download_image(url) image = await utils.download_image(url)
f = discord.File(image, filename=filename) f = discord.File(image, filename=filename)
try: try: