eG8eb
eG8eb

Reputation: 1

Discord.py Enabling Intents for on_member_join Event

I am fixing an old bot from before the intents changes were made and I am trying to just do a simple on_server_join Event but it isn't working, I am not getting any error and assume that this is caused by an issue with intents. I have enabled both privileged intents in the developer portal and tried to implement it into my code however it still isn't functioning correctly.

import discord
from discord.ext import commands
from discord.utils import get
intents = discord.Intents(messages=True)

client = commands.Bot(command_prefix ='-', intents=intents)


@client.event
async def on_member_join(member):
    channel = client.get_channel(751225399798923315)
    print("Person Joined")
    await channel.send("Welcome!")



client.run('Token')

Here is a sample of the code any help is appreciated.

Upvotes: 0

Views: 1141

Answers (1)

Łukasz Kwieciński
Łukasz Kwieciński

Reputation: 15689

You only enabled intents.messages, you need intents.members for any on_member_* event. Also I suggest you simply enabling default intents + intents.members and everything should be working fine.

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

client = commands.Bot(command_prefix ='-', intents=intents)

Also make sure to enable them in the developer portal

Upvotes: 1

Related Questions