Welcome bot (Python)
Greets every new member in a channel you choose.
Python 3.13
♥ 0 likes
Environment variables you'll need
| Key | What it is |
|---|---|
DISCORD_TOKEN | Your bot's token from the Discord Developer Portal. Paste it on the Secrets tab; we store it encrypted. |
WELCOME_CHANNEL_ID | Channel to greet in |
Files
main.py
import os
import discord
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print('ready')
@client.event
async def on_member_join(member):
channel = client.get_channel(int(os.environ['WELCOME_CHANNEL_ID']))
if channel is not None:
await channel.send(f'Welcome, {member.mention}!')
client.run(os.environ['DISCORD_TOKEN'])
requirements.txt
discord.py