Welcome bots automatically greet new members when they join your Discord server. Without a welcome bot, new users may feel lost or ignored in a large server. This article explains how to create a custom welcome bot using Discord’s bot API and a simple programming language like Python. You will learn the exact steps to set up a bot that sends a welcome message in a chosen channel.
Key Takeaways: Building a Discord Welcome Bot
- Discord Developer Portal > Applications > New Application: Register your bot and get the bot token.
- Bot Permissions > Send Messages and Read Message History: Required for the bot to post welcome messages in a channel.
- Python discord.py library on_member_join event: The event that triggers your bot when a new user joins the server.
What a Welcome Bot Does and What You Need Before Building
A Discord welcome bot listens for the on_member_join event. When a new member joins the server, the bot sends a customizable message to a specific channel. The message can include the member’s mention, server rules, or a link to a guide.
Before you start coding, you need these items:
- A Discord account and a server where you have the Manage Server permission.
- Python 3.8 or newer installed on your computer. Download it from python.org.
- A code editor such as Notepad++ or Visual Studio Code.
- Basic familiarity with the command line or terminal.
This guide uses the discord.py library version 2.3.0. The bot will run on your local machine. For 24/7 uptime, you would host it on a cloud service like Heroku or a Raspberry Pi.
Steps to Build and Deploy Your Welcome Bot
Step 1: Register a Bot Application on the Discord Developer Portal
- Go to the Discord Developer Portal
Open your browser and visit discord.com/developers/applications. Log in with your Discord account. - Create a New Application
Click the New Application button in the top right corner. Give your application a name like “My Welcome Bot”. Click Create. - Go to the Bot Section
In the left sidebar, click Bot. Then click Add Bot and confirm. This creates your bot user. - Copy the Bot Token
Under the Token section, click Reset Token and then Copy. Store this token in a safe place. You will use it in your Python code. Never share this token. - Set Bot Permissions
Scroll down to the Bot Permissions section. Check Send Messages and Read Message History. Optionally, check Embed Links if you want to send rich embeds. The portal will generate a permission integer. Copy that integer. - Invite the Bot to Your Server
In the left sidebar, click OAuth2 > URL Generator. Under Scopes, check bot. Under Bot Permissions, paste the permission integer you copied. The generated URL appears at the bottom. Copy it, paste it into your browser, and follow the prompts to add the bot to your server.
Step 2: Set Up Your Python Environment
- Install discord.py
Open a command prompt or terminal. Run the command:pip install discord.py. If you use Python 3 specifically, runpip3 install discord.pyinstead. - Create a New Python File
Open your code editor and create a file namedwelcome_bot.py. Save it in a folder you can find easily.
Step 3: Write the Bot Code
- Paste the following code into welcome_bot.py
import discord from discord.ext import commands intents = discord.Intents.default() intents.members = True bot = commands.Bot(command_prefix='!', intents=intents) WELCOME_CHANNEL_ID = 123456789012345678 # Replace with your channel ID @bot.event async def on_ready(): print(f'{bot.user} has connected to Discord!') @bot.event async def on_member_join(member): channel = bot.get_channel(WELCOME_CHANNEL_ID) if channel is not None: await channel.send(f'Welcome to the server, {member.mention}!') bot.run('YOUR_BOT_TOKEN_HERE') # Replace with your bot token - Understand the code
The script imports the discord library, enables the members intent, and creates a bot instance. Theon_member_joinevent triggers when a new user joins. It sends a welcome message to the channel whose ID you specify. Replace the placeholder channel ID and bot token with your own values. - Find your welcome channel ID
In Discord, open your server. Right-click the channel where you want welcome messages and select Copy ID. If you do not see this option, go to User Settings > Advanced and enable Developer Mode. - Replace the placeholders
Edit theWELCOME_CHANNEL_IDvalue with the numeric ID you copied. ReplaceYOUR_BOT_TOKEN_HEREwith the token you copied from the Developer Portal.
Step 4: Run the Bot
- Start the bot
In your command prompt or terminal, navigate to the folder containingwelcome_bot.py. Run:python welcome_bot.pyorpython3 welcome_bot.py. You should see a message likeMyWelcomeBot has connected to Discord! - Test the bot
Open your Discord server. Invite a test user or use a second account to join. The bot should post a welcome message in the designated channel.
Common Mistakes and Limitations When Building a Welcome Bot
Bot does not respond to new members
The most common cause is missing the members intent. In the Discord Developer Portal, go to Bot > Privileged Gateway Intents and enable Server Members Intent. Then restart your bot. Also confirm that the bot has the Send Messages permission in the target channel.
Bot goes offline after you close the terminal
The bot runs only while your Python script is executing. To keep it online 24/7, you must host it on a cloud platform like Heroku, AWS, or a dedicated server. Alternatively, use a Raspberry Pi that stays on all the time.
Welcome message does not mention the new user
Check that you used member.mention in the message string. If you typed member.name instead, the message will show the username without a ping. Also verify that the bot has the Mention @everyone, @here, and All Roles permission if you want to use role mentions.
Bot sends duplicate welcome messages
This usually happens if you run multiple instances of the same bot script. Close all terminal windows and run only one instance. Also check that you did not add the bot to the server twice with different tokens.
Welcome Bot Options: Custom Message vs Embed vs External Service
| Item | Custom Python Bot | Discord Embed | Third-Party Bot (e.g., MEE6) |
|---|---|---|---|
| Setup complexity | Requires coding and hosting | Same as custom bot but with embed code | No coding, invite and configure |
| Customization | Full control over message, formatting, and logic | Rich formatting with colors, fields, and images | Limited to what the bot offers |
| Cost | Free (if you host on own machine) | Free | Free tier often limited; premium costs money |
| Uptime | Depends on your hosting | Same as custom bot | Hosted by the service, usually 24/7 |
| Example use case | Server with unique welcome rules | Stylish welcome card with server logo | Quick setup for a small community |
You can now build a welcome bot that greets new members automatically. Next, try adding a private message to the new user with server rules. An advanced tip is to use Discord’s Embed feature in your bot for a more polished welcome message. Create an discord.Embed object, set a color, add a thumbnail of your server icon, and send it to the channel for a professional look.