My code works fine and the bot sends the link, but Discord does not recognize it as one and does not embed it. When I copy and paste it myself, it then recognizes it as a link and embed the image. Here is my code:
import requests
from bs4 import BeautifulSoup
if message.content.startswith(".dog"):
response = requests.get("https://dog.ceo/api/breeds/image/random")
soupRaw = BeautifulSoup(response.text, 'lxml')
soupBackend = str(soupRaw).split("message")
soup2 = soupBackend[1]
soup3 = soup2[3:]
soup = soup3[:-20]
await bot.send_message(message.channel, soup)
Here is an example: https://imgur.com/m9GM2wQ
Does anyone know how to make it embed the link when it is sent by my bot? Thanks for the help!
Edit: I am not trying to send an embedded message, I am trying to send a link that will BE embedded by Discord, as shown in my example. This is not a duplicate question.
e.set_image(url=soup). Then you would call it with a different parameter passing your embed object:await bot.send_message(message.channel, embed=e)- bbollurl = response.json()['message']. BeautifulSoup is doing nothing here besides mangling the JSON response from the api. - Nathan Vērzemnieks