I wrote a discord role selection menu like following:
class Whoyouare_select(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label = "Developer", emoji="<:developer:1085656157764464854>"),
discord.SelectOption(label = "Quant", emoji="📐"),
discord.SelectOption(label = "Enthusiast", emoji="👨💻")
]
super().__init__(placeholder = "Pick a role...", options=options)
async def callback(self, interaction = discord.Interaction):
user = interaction.user
guild = interaction.guild
role = guild.get_role(role_map[self.values[0]])
embed = discord.Embed(title = f"```ansiAdded role(s): \u001b[0;37;42m@{self.values[0]}```")
await user.add_roles(role)
await interaction.response.send_message(embed=embed, ephemeral=True)
role_map
is a dict containing key and value pairs for my discord server roles. I would like to send an embed message upon selection of the roles like below:
but i am only able to get this:
i dont think what i want to achieve is an actual mention therefore i tried to alter the text background but failed.
i dont think what i want to achieve is an actual mention
Yes it is. The first screenshot is quite literally an actual mention.
You can't change the background colour. Discord does support ANSII codes for codeblocks, but that won't fly here.
To create a mention string for a role, you can just use Role.mention
.
...Embed(title = f"Added role(s): {self.values[0].mention}")
Though embed titles don't support mentions, so you'll have to do it somewhere else (e.g. a field, the description, ...)