zenof
zenof

Reputation: 69

discord.py throws error with on_member_join

I'm trying to make an on_member_join function for a discord.py bot that sends a welcome message when someone joins my server.

This is the code I have for the function:

@client.event
async def on_member_join(member):
    print(f"{member.name} JOINED!")
    welkomChannel = client.get_channel(channel id)
    await welkomChannel.send(f"Hello!")

When I join the server with an alt account, it throws this error: discord.errors.PrivilegedIntentsRequired. I went to discord.com/developers/applications and turned on the SERVER MEMBERS intent;

SERVER MEMBERS INTENT

And I added these lines to my code after the imports:

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix="!", intents=intents)

So if I have enabled it on the website and I put the intents in the code, why does it still throw the error?

Upvotes: 0

Views: 75

Answers (1)

InsanePhin
InsanePhin

Reputation: 61

intents = discord.Intents()
intents.members = True

intents.Default basically includes presence, member, so you need to activate presence intents or change to Intents().

docs

Upvotes: 1

Related Questions