Welcome bot (Python)

Greets every new member in a channel you choose.

Python 3.13

Environment variables you'll need

KeyWhat it is
DISCORD_TOKENYour bot's token from the Discord Developer Portal. Paste it on the Secrets tab; we store it encrypted.
WELCOME_CHANNEL_IDChannel to greet in

Create an account to use it

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