Reputation: 113
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
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