Sir,
I want to get avatar of member in on_member_join
using python discord bot as we know that it only takes member I can't use ctx so how can I get the avatar image. This is required because I want to make welcome embeds like mee6 or Koya. Can anyone help me to solve this problem
we know ctx is required to get avatar
avatmember = ctx.author await ctx.send(avatmember.avatar.url)
if we write it as
await channel.send(member.avatar.url)
`
it shows
await channel.send(member.avatar.url) ^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'url'
My code
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
robota = commands.Bot(command_prefix=".", intents=intents, help_command=None)
clients = discord.Client(intents=intents)
@robota.event
async def on_member_join(member):
channel = robota.get_channel(Channel_ID)
embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined")
embed.set_thumbnail(url=member.avatar.url)
await channel.send(embed=embed)
Did you pass member
when declaring the function?
If you want to create a welcome message with member avatar then you can use something like this -
@bot.event
async def on_member_join(member):
channel = bot.get_channel(WELCOME_CHANNEL_ID)
await channel.send("Welcome!")
embed = discord.Embed(title=f"Welcome to the server, {member.name}!")
embed.set_thumbnail(url=member.avatar.url)
await channel.send(embed=embed)