user8116739
user8116739

Reputation:

How do I send a direct message to someone when they join a server with discord.py

I'm writing a bot for my discord server and I want to send an automatic direct message to anyone who joins the server for the first time. I have looked through the documentation and I can't find anything about how to do this. I am using python 3.5 and discord.py version 0.16.12.

Upvotes: 0

Views: 3793

Answers (2)

kushalr3ddy
kushalr3ddy

Reputation: 21

this should work if you are using the discord py rewrite make sure you have enabled intents for the bot as shown in this picture member intents enable

intents=discord.Intents.all()
client = commands.Bot(command_prefix= cmd,intents=intents)
@client.event
async def on_member_join(member):
    await member.send(f"your welcome message here")

Upvotes: 1

ADug
ADug

Reputation: 314

https://discordpy.readthedocs.io/en/latest/api.html#discord.on_member_join

You can do something along the lines of:

await bot.send_message(member, "hello")

Upvotes: 0

Related Questions