guiguilecodeur
guiguilecodeur

Reputation: 457

on_member_join can't print a message

I'm doing a Discord bot with Python 3.8 and I have a problem with my event on_member_join().

@bot.event
async def on_member_join(member):

    embed = discord.Embed(
    title=f"that doesn't function")
    channel = discord.utils.get(member.guild.channels, name='WELCOME_CHANNEL_NAME')


    await member.send('Hello')
    await channel.send(embed=embed)

member.send sends a private message with hello but channel.send sends this error await channel.send(embed=embed) AttributeError: 'NoneType' object has no attribute 'send'

I really don't know how to do,

Thanks for your help!

Upvotes: 0

Views: 39

Answers (1)

Nurqm
Nurqm

Reputation: 4743

Because you probably don't have a channel named WELCOME_CHANNEL_NAME. That's why channel returns None. You need to type the real welcome channel name instead of WELCOME_CHANNEL_NAME in channel = discord.utils.get(member.guild.channels, name='WELCOME_CHANNEL_NAME').

Upvotes: 1

Related Questions