Reputation: 25
How can I add an @-mention from a list of strings of users? I want to notify those selected users.
sample_text: @user#tag
That will be plain text and its not mentionable. Tried to iterate through members and save it as an object but only the bot is returned.
Example code:
async def on_message(self, message):
(...)
embed = discord.Embed(title=c.LFG_OVER, description="Party:", color=c.COLOUR_BANANA)
embed.set_author(name=f"{message.author.display_name}", url="", icon_url=f"{message.author.avatar_url}")
embed.set_thumbnail(url=c.LFG_TY)
embed.add_field(name="_", value=f"This is text: {list1[0]}\nThis is text: {list1[1]}\nThis is text: {list2[0]}\nThis is text: {list2[1]}", inline=True)
embed.add_field(name="_", value=f"This is text: {list3[0]}\nThis is text: {dps[1]}\nThis is text: {list3[2]}\nThis is text: {list3[3]}", inline=True)
await message.channel.send(embed=embed)
Upvotes: 0
Views: 586
Reputation: 2613
Using discord.utils.get
you can get a member object from their name and # and mention them afterwards using member.mention
:
#members is your list of members (format is name#1111)
for str_member in members:
member = discord.utils.get(message.guild.members, name=str_member[:-5], discriminator=str_member[-4:])
#using member.mention you can mention the person now, or save the mention in a list or whatever you want to do
Upvotes: 1