Ask coding questions

← Back to all posts
Welcome Discord Bot Python
pvk1ng (0)

Hello there! I'm trying to code a bot that sends welcome embed when a member joins the server, but i'm having trouble figuring out the coding for it. If anyone could help that would be great!

P.S Im trying to achieve a likewise welcome messages as that of carl bot if that makes sense :)

Comments
hotnewtop
InvisibleOne (3226)

I might be able to help.
I think you just need an on_join event, something like this:

@bot.event
async def on_join(member):
  guild = bot.get_guild(0192837401983274) # guild id
  channel = guild.get_channel(109387401893274098) # welcome channel id
  await channel.send(f"Hi {member.mention}, Welcome to the server!")

Or something like that

pvk1ng (0)

@InvisibleOne Thank you! But what im trying to do is have an embed send instead of a message like this but i dont think my coding is correct

@client.event
async def on_join(member):
guild = bot.get_guild(836304285545398272)
channel = client.get_channel(843182724255580201)
embed=discord.Embed(title="Welcome To Tryhards", description="Hello {user(proper)} To The 'Name' Server. Please Read the Rules in #𝐑𝐮𝐥𝐞𝐬 , and Grab Some Roles in #𝐑𝐨𝐥𝐞𝐬 .")
embed.set_thumbnail(url='https://media.discordapp.net/attachments/762023030830399529/862102999782129694/image0.gif')
embed.set_footer(text="Made by Sawyer")
await channel.send(embed=embed)

InvisibleOne (3226)

It's looks ok, but for your description it needs to be an fstring if you are going to include stuff like that. To make an fstring just put f in front of the string:

fruit = "Banana"
text = f"This is an fstring, we can include stuff like this fruit: {fruit}}"

@pvk1ng

pvk1ng (0)

@InvisibleOne For some reason nothing is sending when a member joins and this is the code im running

@client.event
async def on_join(member):
guild = bot.get_guild(836304285545398272)
channel = client.get_channel(843182724255580201)
embed=discord.Embed(title="Welcome To Tryhards", description="Hello {user(proper)} To The 'Name' Server. Please Read the Rules in #𝐑𝐮𝐥𝐞𝐬 , and Grab Some Roles in #𝐑𝐨𝐥𝐞𝐬 .")
embed.set_thumbnail(url='https://media.discordapp.net/attachments/762023030830399529/862102999782129694/image0.gif')
embed.set_footer(text="Made by Sawyer")
await channel.send(embed=embed)