A Discord bot for the symm.city server with advanced role management, server configuration features, and AI-powered help system.
- Role Selection Menus - Create interactive role menus with buttons
- Member Count Display - Shows the current server member count in a voice channel name
- Join/Leave Notifications - Sends notifications when users join or leave
- Role Block System - Prevent users with certain roles from selecting other roles
- AI-powered Help - Ask questions about the server and get AI responses
The project is organized into modular components to make development easier:
bot/
- Main package for the Discord bot__init__.py
- Package initializationmain.py
- Bot startup and main event loopconfig.py
- Configuration loading and setupcommands.py
- Discord slash commandsdatabase.py
- Database models and operationsevents.py
- Event handlers for Discord eventsutils.py
- Utility functionsai_helper.py
- AI integration using Google's Gemini APItasks.py
- Scheduled tasks
run.py
- Main entry point for starting the bot
To add new functionality:
- Commands: Add new slash commands to
bot/commands.py
- Event Listeners: Add new event listeners to
bot/events.py
- Background Tasks: Add new background tasks to
bot/tasks.py
- Database Models: Add new models to
bot/database.py
- Utility Functions: Add new utility functions to
bot/utils.py
Create a .env
file in the root directory with the following variables:
# Bot Configuration
DISCORD_BOT_TOKEN=your_bot_token_here
OWNER_ID=your_discord_id_here
# Database Configuration
DATABASE_URL=postgresql://username:password@hostname:port/database_name
# Optional Configuration
GEMINI_API_KEY=your_gemini_api_key_here # Required for AI help features
The bot uses PostgreSQL to store server configurations, role menus, and role relationships.
- Create a PostgreSQL database
- Set the
DATABASE_URL
environment variable - The bot will automatically create the necessary tables on first run
Here are the main commands provided by the bot:
/create_role_menu
- Create a role selection menu with buttons/set_member_count_channel
- Set the channel to display member count/set_notifications_channel
- Set the channel for join/leave notifications/set_new_user_roles
- Set roles to assign to new users who join/set_bot_roles
- Set roles to assign to bots that join/view_server_config
- View the current server configuration/block_role
- Block users with a certain role from selecting another role/unblock_role
- Remove a role blocking relationship/view_role_blocks
- View all role blocking relationships/server_docs add
- Add/update documentation for AI help/server_docs remove
- Remove documentation/server_docs list
- List all documentation/server_docs view
- View a specific documentation entry/help
- Ask a question and get AI-powered help/update_member_count
- Manually update the member count channel
The bot can be configured through either environment variables or directly via Discord commands.
- Use the bot commands to set up the server configuration directly.
- All settings are stored in the database and can be viewed with
/view_server_config
- Use the role management commands to set up role menus and role blocks
- Install dependencies:
pip install -r requirements.txt
- Set up your
.env
file with the required environment variables - Run the bot:
python run.py
The role blocking system allows you to define roles that prevent users from selecting other roles:
- If a user has a blocking role, they cannot select any roles that are blocked by that role
- When attempting to select a blocked role, the user will receive a message explaining which of their roles is blocking the selection
- This system works across all role menus, unlike the exclusive roles feature which only works within a single menu
- Administrators can manage role blocks using the
/block_role
,/unblock_role
, and/view_role_blocks
commands
The AI help system allows users to ask natural language questions about the server and get AI-generated responses:
- Administrators can add documentation about the server using
/server_docs add
- Users can ask questions using the
/help
command - The bot uses Google's Gemini AI to generate responses based on the server documentation
- The system is designed to only provide information that exists in the server documentation
- Responses are formatted with Markdown for better readability
- To use this feature, you must set the
GEMINI_API_KEY
in your environment variables