I try to run this code below, but on_member_join is not working for me.
async def on_member_join(self, member):
guild = member.guild
if guild.system_channel is not None:
to_send = f'Welcome {member.mention} to {guild.name}!'
await guild.system_channel.send(to_send)
# self.logger.info(f'{member.mention} 加入了伺服器')
full code: https://github.com/Cutespirit-Team/CutespiritDiscordBot/blob/main/src/ctbot/ctbot.py#L66-L71
run python -m src/ctbot/
I have already turned this on.
when a user enter my server, it will show the default message. how can i fix it? thx
Make sure to subscribe to members intent.
class Bot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.members = True
super().__init__(intents=intents)