Reputation: 11
I have a discord bot, and I want it to do something like
once a member joins
DM member (message)
if member replies with key
give them this role
Thanks
Upvotes: 0
Views: 7756
Reputation: 11
@client.event
async def on_member_join(member):
await member.send("hello")
This code sends hello to the user when he/she joins the server. Hope this is helpful for everybody
Upvotes: 1
Reputation: 566
You need to use the function on_member_join()
.
@client.event
async def on_member_join(member):
pass
Then put the code message sending/receiving code in there. With your example you would do:
@client.event
async def on_member_join(member):
await client.send_message(member, 'Prompt.')
m = await client.wait_for_message(author=member, channel=member)
if m.content == 'key':
# give the user the role
await client.send_message(member, 'Role added')
else:
await client.send_message(member, 'Incorrect key')
To find out how to give a user a role from a dm to a server, read this question: How To Assign A User A Role In A Server From A Direct Message - Discord.py
Upvotes: 3