@bot.event
async def on_member_join(ctx):
user1 = discord.Member
channel = bot.get_channel(654805249311375400)
embed= discord.Embed(title='Welcome to Kitty\'s Play Place <3', description='Welcome! We hope you enjoy your time at Kitty\'s play place {} \n ----------------------------------------------------------------------- \n Please check <#654820877304856606> to avoid any problems \n after please go to <#654806729162227743> and <#654806701123567616> \n To gain access to our chats, click the reaction in the channels mentioned above \n ----------------------------------------------------------------------- \n'. format(user1), colour=discord.Color.red())
embed.set_image(url='https://cdn.discordapp.com/attachments/654804320222707723/665897722213171205/ezgif-7-ec547b785e7d.gif')
await channel.send(embed=embed)
所以我有这段代码,但是奇怪的是它可以工作,只是用户ping显示为:
<class 'discord.member.Member'>
代替username
。
谁能告诉我该怎么做?
答案 0 :(得分:2)
不管缩进是否正确,您都将Member
类本身分配给user
。
您需要使用该类的实例。
请参见How do I get a specific model? section of the FAQ in discord.py's documentation。
如果您打算使用刚刚加入的成员,则on_member_join
会传递该Member
对象,而不是Context
对象,并且您可以使用它。
一旦有了特定的对象,就可以对相应的字符串使用Member.mention
属性来提及它们。