0
votes

I was just trying to code a welcome message for new members who join the server. I wanted to send an embed everytime a new member joins. However, the embed is not getting sent. Could someone please help me out?

This is my code:

async def on_member_join(member):
    mention = member.mention
    guild = member.guild
    embed = discord.Embed(title="**New Member Joined!**", description=f"{mention} joined {guild}!", color = discord.Colour.purple())
    embed.set_thumbnail(url=f"{member.avatar.url}")
    channel = discord.utils.get(member.guild.channels, id=Channel_ID)
    await channel.send(embed=embed)

Thanks!

1

1 Answers

1
votes

In the new version of discord.py(1.5.x), there're some updates about Intents. Intents are similar to permissions, you have to define Intents to get channels, members and some events etc. You have to define it before defining the client = discord.Bot(prefix='').

import discord

intents = discord.Intents().all()
client = discord.Bot(prefix='', intents=intents)

Also, you have to activate Intents from your bot application in Discord Developer Portal.

If you want to get more information about Intents, you can look at the API References.