1
0
Fork 0
mirror of https://gitlab.jonasled.de/jonasled/discordbot synced 2024-06-03 10:21:08 +02:00

fixed the cat command (new API)

This commit is contained in:
Jonas Leder 2020-06-26 10:34:32 +02:00
parent 39eb3e0c63
commit 7ff1086da8

6
bot.py
View file

@ -404,10 +404,10 @@ async def result(ctx, id):#this function prints the result of a poll
@bot.command(pass_context=True, brief="sends a random cat image")
async def cat(ctx):
r = get("http://aws.random.cat/meow") # get random cat image
r = get("https://api.thecatapi.com/v1/images/search?size=full") # get random cat image
answer = loads(r.text)
extension = answer["file"].split(".")[-1]#get the file extension
r = get(answer["file"])#get the url to the cat
extension = answer[0]["url"].split(".")[-1]#get the file extension
r = get(answer[0]["url"])#get the url to the cat
image_data = BytesIO(r.content)#download tthe image and load it into BytesIO
image_data.seek(0)
await ctx.send(file=discord.File(image_data, 'cat.' + extension))#send the cat image