0
votes

I am creating a bot for my Discord server.

There is a new users channel in my server. When a new user joins, I want to send a welcome message to this channel. But, I don't know how can I access to new users channel.

@bot.event
async def on_member_join(member):
    # What i should do here?
1

1 Answers

1
votes

You can use discord.utils.get or guild.get_channel. Then you can send message by channel.send().

@bot.event
async def on_member_join(member):
    channel = discord.utils.get(member.guild.text_channels, name="the name of the channel the bot will send message to")
    await channel.send('A new member joined.')

or

@bot.event
async def on_member_join(member):
    channel = member.guild.get_channel(channel id)
    await channel.send('A new member joined.')