Clickable link inside message discord.py
Question:
I would like my bot to send message into chat like this:
await ctx.send("This country is not supported, you can ask me to add it here")
But to make "here" into clickable link, In HTML I would do it like this, right?
<a href="https://www.youtube.com/" > This country is not supported, you can ask me to add it here </a>
How can I do it in python?
Answers:
As far as i know, Discord don’t allow using HTML in messages, when you see any form of formating on some messages it’s either :
- Done with markdown
- Embed usage.
The problem is that both those methods won’t help you to solve your problem, because :
- in markdown we use
[Here](link)
to achieve what you want, but after i tried it on Discord, it doesn’t seem to render, so my guess is that not all markdown is usable in Discord
- Embeds are really different from what you want to achieve.
As the other answer explained, you can’t add hyperlinks in normal messages, but you can in Embeds. I don’t see why you wouldn’t want to use an Embed for an error message, especially considering it adds more functionality, so you should consider using that.
embed = discord.Embed()
embed.description = "This country is not supported, you can ask me to add it [here](your_link_goes_here)."
await ctx.send(embed=embed)
Feel free to mess around with the Embed & add some fields, a title, a colour, and whatever else you might want to do to make it look better. More info in the relevant API docs.
Another way of solving this; you can add url=(pop_in_link)
, but this one works when you do, import discord. You can use either method
This might help people trying to embed links in their code for their bot.
embed = discord.Embed(
title="[title]",
url="[URL]",
description="[description (optional)]",
color=[color hex code or tag (optional)]
)
I would like my bot to send message into chat like this:
await ctx.send("This country is not supported, you can ask me to add it here")
But to make "here" into clickable link, In HTML I would do it like this, right?
<a href="https://www.youtube.com/" > This country is not supported, you can ask me to add it here </a>
How can I do it in python?
As far as i know, Discord don’t allow using HTML in messages, when you see any form of formating on some messages it’s either :
- Done with markdown
- Embed usage.
The problem is that both those methods won’t help you to solve your problem, because :
- in markdown we use
[Here](link)
to achieve what you want, but after i tried it on Discord, it doesn’t seem to render, so my guess is that not all markdown is usable in Discord - Embeds are really different from what you want to achieve.
As the other answer explained, you can’t add hyperlinks in normal messages, but you can in Embeds. I don’t see why you wouldn’t want to use an Embed for an error message, especially considering it adds more functionality, so you should consider using that.
embed = discord.Embed()
embed.description = "This country is not supported, you can ask me to add it [here](your_link_goes_here)."
await ctx.send(embed=embed)
Feel free to mess around with the Embed & add some fields, a title, a colour, and whatever else you might want to do to make it look better. More info in the relevant API docs.
Another way of solving this; you can add url=(pop_in_link)
, but this one works when you do, import discord. You can use either method
This might help people trying to embed links in their code for their bot.
embed = discord.Embed(
title="[title]",
url="[URL]",
description="[description (optional)]",
color=[color hex code or tag (optional)]
)