E
E
egoxx2020-10-09 23:00:16
Python
egoxx, 2020-10-09 23:00:16

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

3 answer(s)
V
Verce11o, 2020-10-10
@Verce11o

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")

R
RAINGM, 2021-07-23
@RAINGM

send_message is long gone from discord.py
await channel.send(f"{member.mention} hello")

P
Philip Sagan, 2021-10-29
@Yatochka_sagan

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 question

Ask a Question

731 491 924 answers to any question