Discord Welcome Bot
import os
import discord
from discord import app_commands
from abilities import apply_sqlite_migrations
from sqlalchemy.orm import Session as SQLAlchemySession
from models import Base, engine, Session, GuildSettings
def generate_oauth_link(client_id):
base_url = "https://discord.com/api/oauth2/authorize"
redirect_uri = "http://localhost"
scope = "bot"
permissions = "8" # Administrator permission for simplicity, adjust as needed.
return f"{base_url}?client_id={client_id}&permissions={permissions}&scope={scope}"
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
intents.members = True # Enable member events
bot = discord.Client(intents=intents, activity=discord.CustomActivity("Example Activity"))
tree = app_commands.CommandTree(bot)
@bot.event
Created: | Last Updated:
Discord Welcome Bot Template Guide
This template creates a Discord bot that welcomes new members to your server with customizable welcome messages in a designated channel.
Getting Started
- Click "Start with this Template" to begin using the Discord Welcome Bot template
Initial Setup
You'll need to create a Discord bot and get the required credentials:
- Go to the Discord Developer Portal (https://discord.com/developers/applications)
- Create a new application
- Navigate to the "Bot" section
- Click "Add Bot" and confirm
- Under the "TOKEN" section, click "Copy" to get your BOT_TOKEN
- Go to the "OAuth2" section and copy your CLIENT_ID
- Enable the "Message Content Intent" slider under the Bot section
Add these credentials in the Environment Secrets tab: * BOT_TOKEN * CLIENT_ID
Test the Bot
- Click the "Test" button to start the deployment
- The CLI will provide an OAuth link to invite your bot to your Discord server
- Click the link and select the server where you want to add the bot
- Grant the necessary permissions
Using the Bot
The bot provides two main commands:
/set-welcome-channel
- Set the channel where welcome messages will appear (requires "Manage Server" permission)/echo
- Makes the bot echo back any message you send
When new members join your server, the bot will automatically send a welcome message in the designated welcome channel.
Example welcome message:
🎉 Welcome @username to ServerName! 🎉
We're excited to have you here! Feel free to introduce yourself and make yourself at home! 🏠
That's it! Your Discord Welcome Bot is now ready to greet new members in your server.
Template Benefits
- Enhanced User Engagement & Retention
- Automatically welcomes new members with customized messages
- Creates an immediate positive first impression
- Helps maintain active community participation
-
Reduces member drop-off rates through immediate engagement
-
Streamlined Community Management
- Automates welcome processes, saving moderator time
- Configurable welcome channels through simple commands
- Reduces manual moderation workload
-
Ensures consistent greeting experience for all new members
-
Database-Driven Customization
- Stores guild-specific settings in SQLite database
- Allows for scalable server-specific configurations
- Enables data-driven decision making
-
Maintains settings persistence across bot restarts
-
Professional Server Appearance
- Creates a more professional and organized server environment
- Demonstrates active community management
- Enhances server credibility
-
Improves overall user experience
-
Easy Integration & Setup
- Simple OAuth2 implementation for quick bot installation
- Clear error handling and setup instructions
- Minimal configuration requirements
- Secure token management through environment variables