mirror of
https://gitlab.jonasled.de/jonasled/discordbot
synced 2024-11-20 10:13:03 +01:00
fixed the cat command (new API)
This commit is contained in:
parent
39eb3e0c63
commit
7ff1086da8
1 changed files with 3 additions and 3 deletions
6
bot.py
6
bot.py
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue