0
votes

I'm creating my discord bot in discord.py and came across this one problem that I've been trying to solve. I want my bot to make a custom welcome to whomever joins the server. My code so far:

@client.event
async def on_member_join(ctx, member):
    id = client.get_guild(x)
    general = client.get_channel(x)
    
    if discord.on_member_join:
        general.send(f"{member.mention} has joined the server!")

VS code is giving me an error at discord saying: Module 'discord' has no 'on_member_join' memberpylint(no-member)

Two questions:

  1. How do I achieve what I initially wanted - sending the message in the channel that I've obtained the ID of?
  2. Why does it give me that error (for my better understanding)?

PS: Hidden the client ID's just to be safe, dunno if it matters, but better safe than sorry! And I'm also new to discord.py

1

1 Answers

0
votes

Try this:

@client.event  #Event to detect when a user joins
async def on_member_join(member):
    general = client.get_channel(id)    #Where id is the channel's ID
    await general.send(member.mention + ' has joined the server!')