I am making a discord bot that is meant to send embeds with images gotten froms APIs. I have one for a dog, and it works. The code for the dog one:
if message.content.lower().startswith("!dog"):
async with aiohttp.ClientSession() as session:
request = await session.get('https://some-random-api.ml/img/dog') # Make a request
dogjson = await request.json() # Convert it to a JSON dictionary
dogembed = discord.Embed(title="Doggy!", color=discord.Color.blue())
dogembed.set_image(url=dogjson['link'])
await message.channel.send(embed=dogembed)
This works perfectly, and always. However when I try to do the same thing for a cat images, using "https://api.thecatapi.com/v1/images/search" I get this error.
Here is my code for the cat one:
if message.content.lower().startswith("!cat"):
async with aiohttp.ClientSession() as session:
request = await session.get('https://api.thecatapi.com/v1/images/search') # Make a request
catjson = await request.json() # Convert it to a JSON dictionary
Catembed = discord.Embed(title="Kitty!", color=discord.Color.blue())
Catembed.set_image(url=catjson['link'])
await message.channel.send(embed=Catembed)
Please help me with this, I am a beginner to python and APIs.