bos gamer
bos gamer

Reputation: 113

Discord I Can't Find A Way To Make A On Join Member Message

I have been trying to make a member on join message in discord.py (Rewrite) I get an error. First my command is below.

@bot.event
async def on_member_join(member):
guild = member.guild
channel = (553090886683197451)
message ='Hello {}, Welcome to {} Discord server, We hope u good day at our server. Also please read the rules carefully'.format(member.mention, guild.name)
await user.send(channel, message)

The error is below

line 15, in on_member_join
await user.send(channel, message)
NameError: name 'user' is not defined

i want my bot to send message to a specific channel and the message which i have written above. of anybody could help it would be great!.

Upvotes: 1

Views: 1785

Answers (1)

Kanasaki
Kanasaki

Reputation: 146

Unlike the async version, you have to first find the channel using the get_channel() method

@bot.event
async def on_member_join(member):
    channel = bot.get_channel(553090886683197451)
    guild=member.guild
    message ='Hello {}, Welcome to {} Discord server, We hope u good day at our server. Also please read the rules carefully'.format(member.mention, guild.name)
    await channel.send(message)

And as Patric Haugh mentioned you'd do member.send() to private message

Upvotes: 6

Related Questions