Search code examples
discorddiscord.py

discord.py on_member_join function not being called?


I am trying to use on_member_join to set a default role in my server but the on_member_join function is never being called and I'm not quite sure why. I have the "Privileged Gateway Intents" and all the imports

import discord
from discord import app_commands
from discord.ext import commands

import responses #my other class with the text responses

def run_discord_bot():
    TOKEN = 'token here'
    intents = discord.Intents.default()
    intents.message_content = True
    discord.members = True
    client = discord.Client(intents=intents)

    @client.event
    async def on_ready():
        print(f'{client.user} is now running!')



    @client.event
    async def on_member_join(member):
        print('here') #never being printed


    client.run(TOKEN)

I looked at other similar questions and they all said to check the "Privileged Gateway Intents" which I did and they are all on

Discord Dev Intents Screenshot

I also have on_message set up and it is working. Tried resetting the privs of the bot in dev and reinviting it but to no avail. No error is ever sent either. Console is clean which is how I know it is never even running in the first place.

Not sure what to check or where to go after this.


Solution

  • You can try two things. Change the discords.members = true into intents.members = true and if not that change your intents to do intents = discord.Intents.all(), although I do not think this is necessary for your case.