Array
(
[0] => Array
(
[category] => 1
[attribute] => 1
[option] => 1
)
[1] => Array
(
[category] => 1
[attribute] => 1
[option] => 2
)
[2] => Array
(
[category] => 1
[attribute] => 2
[option] => 3
)
[3] => Array
(
[category] => 1
[attribute] => 2
[option] => 4
)
[4] => Array
(
[category] => 2
[attribute] => 3
[option] => 5
)
[5] => Array
(
[category] => 2
[attribute] => 3
[option] => 6
)
[6] => Array
(
[category] => 2
[attribute] => 4
[option] => 7
)
[7] => Array
(
[category] => 2
[attribute] => 4
[option] => 8
)
)
您看到的代码在
下@client.event
async def on_member_join(member):
channel = client.get_channel(659080736229294130)
await channel.send(f'{member.mention} Katıldı, Hoşgeldin! {channel.guild.member_count} Kişiyiz!')
role = get(member.guild.roles, name=ROLE)
await member.add_roles(role)
print(f"{member} Katıldı!")
if member.guild is None and not member.author.bot:
async with member.typing():
await asyncio.sleep(0.7)
embed = discord.Embed(
title="Hoşgeldin!",
colour=discord.Colour.blue(),
)
embed.set_thumbnail(
url="https://cdn.discordapp.com/avatars/649985273249398784/493fe440660d331687e426ba976da8f4.webp?size=1024")
embed.add_field(name="",
value="**TEXT**",
inline=False)
embed.add_field(name="TEXT",
value= "TEXT", )
embed.set_footer(text="© @MakufonSkifto#0432")
await member.send(embed=embed)
我希望我的机器人向加入服务器的人发送DM。我已经通过welceme频道发出了欢迎新来者的命令,但是我无法使DM正常工作。而且由于漫游器不知道消息是什么,它使文本变为红色。当我将@client.event
async def on_member_join(member):
放在顶部时,当有人加入时,它说“消息是缺少的必需上下文”。我不知道如何进行,但我绝对需要你们的帮助!如果大家愿意,我可以提供完整的message
事件
答案 0 :(得分:1)
您可以通过member.send(...)
向用户发送个人消息,其中member
是上下文中的用户(已加入服务器)。
<destination>.send(<content>)
函数将content
(您的消息)发送到给定的destination
,该@client.event
async def on_member_join(member):
print ("{} joined!".format(member.name))
print (f'{member.guild.name}')
await member.send("Welcome!")
role = member.guild.roles
# member.guild.roles returns an object of type <class 'list'>
if member.guild and not member.bot:
async with member.typing():
embed = discord.Embed(
title="Hoşgeldin!",
colour=discord.Colour.blue(),
)
embed.set_thumbnail(
url="https://cdn.discordapp.com/avatars/649985273249398784/493fe440660d331687e426ba976da8f4.webp?size=1024")
embed.add_field(name="something",
value="**TEXT**",
inline=False)
embed.add_field(name="TEXT",
value="TEXT")
embed.set_footer(text="© @MakufonSkifto#0432")
await member.send(embed=embed)
可以是频道,组或成员(在这种情况下)等。
这是一个示例代码(您的代码进行了一些更改),该代码将嵌入内容发送到加入用户的DM:
stk.size()