A Discord bot for managing community applications and events.
- Application Processing: Automated Google Forms integration for member applications
- Voting System: Staff voting on applications with configurable thresholds
- Member Management: Automatic role assignment and member onboarding
- Event Management: Automatic weekly event creation and management
- Python 3.13 or higher
- Discord Bot Token
- Google Forms API credentials
-
Clone the repository:
git clone github.com/ljackson330/tacbot cd tacbot -
Install dependencies:
pip install -e .[dev]
-
Configure environment variables - Create a
.envfile:# Discord DISCORD_TOKEN=your_discord_bot_token GUILD_ID=your_guild_id APPLICATION_CHANNEL_ID=channel_for_applications GENERAL_CHANNEL_ID=general_chat_channel MEMBER_ROLE_ID=role_to_assign_accepted_members ADMIN_ROLE_ID=admin_role_id # Google Forms GOOGLE_FORM_ID=your_google_form_id GOOGLE_CREDENTIALS_FILE=path/to/credentials.json GOOGLE_TOKEN_FILE=path/to/token.json # ID of the form question that is autopopulated with the user's UID DISCORD_ID_ENTRY=entry.123456 # Application Processing ACCEPTANCE_THRESHOLD=3 DENIAL_THRESHOLD=2 APPLICATION_POLL_INTERVAL=30 # Event Management EVENT_VOICE_CHANNEL_ID=voice_channel_for_events EVENT_NOTIFICATION_CHANNEL_ID=notification_channel EVENT_NOTIFICATION_ROLE_ID=role_to_ping_for_events EVENT_TIME_HOUR=17 # 3 PM EVENT_TIME_MINUTE=0 # On the hour EVENT_CREATE_DAY=0 # Monday EVENT_CREATE_HOUR=20 # 5 PM EVENT_DELETE_DAY=6 # Sunday EVENT_DELETE_HOUR=0 # 11 PM TIMEZONE=US/Eastern # Database DATABASE_PATH=tacbot.db
-
Set up Google Forms API:
- Create a Google Cloud Project
- Enable the Forms API
- Download credentials JSON file
- Run the bot once to authenticate and generate token file
python3 bot.py/apply- Get application form link with pre-filled Discord ID/event_create- Manually create weekly event (admin only)/event_delete- Manually delete active event (admin only)/event_stats- Show event statistics (admin only)/app_stats- Show application statistics (admin only)
- User runs
/applycommand to get personalized form link - User fills out Google Form with their information
- Bot automatically posts application to configured channel with voting buttons
- Staff members vote approve/deny on applications
- When threshold is reached, bot processes the decision:
- Accepted: User gets member role and welcome message
- Denied: User is removed from server
The bot automatically:
- Creates weekly events on configured day/time
- Posts notifications with role pings
- Tracks participant counts
- Deletes old events and archives participation data
The project includes several development tools configured in pyproject.toml:
# Format code
black .
# Check code style
flake8 .
# Run tests
pytest
# Run all checks
./scripts/check.shpip install pre-commit
pre-commit installThis will automatically run Black and Flake8 before each commit.
# Run all tests
pytest
# Run with coverage
pytest --cov=cogs --cov-report=html
# Run specific test file
pytest tests/test_database.pytacbot/
├── bot.py # Main bot entry point
├── cogs/ # Bot functionality modules
│ ├── application_handler.py # Application processing
│ ├── chat_commands.py # Slash commands
│ ├── event_handler.py # Event management
│ ├── database.py # Database operations
│ └── google_forms_service.py # Google Forms API
├── tests/ # Unit tests
├── scripts/ # Development scripts
│ └── check.sh # Code quality checker
├── pyproject.toml # Project configuration
└── .env # Environment variables
Find Discord IDs by enabling Developer Mode in Discord settings, then right-clicking on channels, roles, or users.
- Create a Google Form for applications
- Include a question for Discord ID (note the entry ID from the URL)
- Set up Google Cloud Project with Forms API enabled
- Download service account credentials
ACCEPTANCE_THRESHOLD: Number of approve votes neededDENIAL_THRESHOLD: Number of deny votes needed- Staff can change their votes before thresholds are reached
- Decisive votes have a 10-second undo window
EVENT_CREATE_DAY: 0=Monday, 6=SundayEVENT_DELETE_DAY: When to clean up old events- Times are in 24-hour format
- Timezone configurable via
TIMEZONEsetting
The bot uses SQLite with the following tables:
processed_responses: Tracks processed form submissionsapplications: Application status and metadatavotes: Staff voting recordsevents: Event creation and participation tracking
The bot logs to both console and bot.log file. Check logs for detailed error information.
MIT License - see LICENSE file for details.