不一致的提到用户从字符串



如何从用户字符串列表中添加@-mention ?我想通知那些选定的用户。

sample_text: @user#tag

这将是纯文本,它是不可提及的。尝试遍历成员并将其保存为对象,但只返回bot。

示例代码:

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)

使用discord.utils.get,您可以从他们的名称和#中获得成员对象,然后使用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

最新更新