0
votes

I'm new making a discord bot with python and I want o make a event that display a welcome message when someone joins the server.

I tried with this code

import discord
import random
from discord.ext import commands

alfred = commands.Bot(command_prefix = '!', description = "Hey!, I'm Alfred, How can I assist you?")

#EVENT

@alfred.event
async def on_ready():

    print("I'm Alfred and I'm Online!")

@alfred.event
async def on_member_join(member):
    embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined")
    await message.channel.send(embed=embed)

But It didn't work, even the documentation of discord says the event is "on_member_join".

I really hope you can help me :)

1

1 Answers

0
votes

Try this, just replace the 790274325533378682 with your channel id

@alfred.event
async def on_member_join(member):
    channel = alfred.get_channel(790274325533378682)
    embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined")
    await channel.send(embed=embed)