@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)
The code you see is under
@client.event
async def on_member_join(member):
I want my bot to DM the person who joins the server. I have made a command that welcomes the newcomer thru the welceme channel but I couldn't make DM work. And as the bot didn't know what message is, It makes the text red. When I put message
on the top It says "message is a required context that is missing" when someone joins. I don't know how to proceed but I definitely need you guys help! I can give the full on_member_joins
event if you guys want
You can send personal messages to a user through member.send(...)
where member
is the user in the context (joined the server).
The <destination>.send(<content>)
function sends the content
(your message) to the given destination
which can be a channel, a group or a member(in this case),etc. Here is a sample code(your code with some changes) which send an embed to the joining user's DM:
@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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.