Answer the question
In order to leave comments, you need to log in
Why is the on_member_join function not working, Discordpy?
There is the following code. When a new member connects to the server, it does not display any messages, either to the console or to the text channel itself in the discord on the server.
@client.event
async def on_member_join(member):
print("New member!")
channel = member.guild.default_channel
await client.send_message(channel, "Hello")
Answer the question
In order to leave comments, you need to log in
the client class does not have a send_message attribute.
You need to send a message to a channel, then contact it
await channel.send("Hello")
send_message is long gone from discord.py
await channel.send(f"{member.mention} hello")
Check your client variable, it might not include intents.
client = commands.Bot(command_prefix='YOUR PREFIX', intents=discord.Intents.all())
Also don't forget to check "SERVER MEMBERS INTENT" in the "BOT" section of your bot's "discord developer" page first portal". (link: https://discord.com/developers/ )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question