This is exactly what it sounds like. It's a Discord bot that forces a curfew on members in your Discord group.
The bot removes a user from any (and every) voice channel at a specified time and will not allow them to rejoin until their curfew is up.
Explore the docs
View Demo
·
Report Bug
·
Request Feature
Table of Contents
This is exactly what it sounds like. It's a Discord bot that forces a curfew on members in your Discord group. The bot removes a user from any (and every) voice channel at a specified time and will not allow them to rejoin until their curfew is up.
All times are in US/Pacific timezone.
Since it's all in Python, we are going to need pip.
- pip
pip install --upgrade pip
-
To get started with the Discord API: https://discord.com/developers/docs/intro
-
Clone the repo
git clone https://github.com/derekn4/CurfewBot.git cd CurfewBot -
Install Python packages
pip install -r config/requirements.txt
-
Copy the example environment file and enter your credentials
cp config/.env.example .env
Then edit
.envand fill in your values:BOT_TOKEN=your_bot_token_here GUILD_ID=your_guild_id_hereOptional — AI-powered shame messages:
ANTHROPIC_API_KEY=your_api_key_here
| Variable | Required | Default | Description |
|---|---|---|---|
BOT_TOKEN |
Yes | - | Discord bot token |
GUILD_ID |
No | 848474364562243615 |
Discord server ID |
EXCLUDED_USERS |
No | - | Comma-separated user IDs exempt from curfews |
HEALTH_PORT |
No | 8080 |
Health check HTTP port |
HEALTH_HOST |
No | 127.0.0.1 |
Health check bind address |
DB_DIR |
No | Script directory | Directory for SQLite database file |
ANTHROPIC_API_KEY |
No | - | Anthropic API key for AI shame messages |
AI_DAILY_LIMIT |
No | 50 |
Max AI API calls per day (cost guard) |
AI_MODEL |
No | claude-haiku-4-5-latest |
Claude model for shame messages |
- Make sure your bot has the required intents enabled in the Discord Developer Portal:
voice_states-- monitor voice channel joinsmessage_content-- receive prefix command messages
- Run the bot
python src/curfewbot.py
First, make sure that your bot is enabled for the Discord server of intended use. Second, enable access to voice chat and text chats, as well as admin privileges.
Admin commands (require admin permissions):
| Command | Description | Example |
|---|---|---|
!curfew <time> @user |
Set a curfew for a user | !curfew 11:30PM @user |
!list_curfews |
Show all active curfews | !list_curfews |
!remove_curfew @user |
Remove a specific user's curfew | !remove_curfew @user |
!reset |
Clear all curfews | !reset |
User commands (anyone can use):
| Command | Description | Example |
|---|---|---|
!appeal <reason> |
Appeal your curfew for a time extension | !appeal I need 15 more minutes |
The appeal system opens 15 minutes before your curfew. A random roll (~60% grant rate) determines the outcome, and an AI "judge" delivers the ruling. You get 2 appeals per curfew: the first can grant 15 extra minutes, the second 10.
When a curfew is set, the bot will:
- Send a reminder 5 minutes before the curfew
- Kick the user from voice at the curfew time
- Block them from rejoining any voice channel for 5 minutes
- Shame them in the general channel with an AI-generated message if they try to rejoin early (falls back to a static message if no API key is configured)
CurfewBot is set up for deployment on AWS EC2 (free tier) using Docker.
# Build and start
docker compose up -d
# Check logs
docker compose logs -f
# Verify the bot is running
curl http://localhost:8080/healthA systemd service file is provided at deploy/curfewbot.service for running directly on Linux.
The project includes a GitHub Actions workflow (.github/workflows/deploy.yml) that automatically deploys to EC2 on every push to main. See docs/IMPROVEMENT_AND_DEPLOYMENT_PLAN.md for full setup instructions.
- Responds to command
- Adds user to database with cutoff time
- Kicks user out of voice call
- Continues to kick user out of voice channels until curfew is up
- Mentions and shames user in General chat if they try to join before curfew is over
- Health check endpoint for monitoring
- Graceful shutdown handling
- Docker containerization
- CI/CD pipeline for auto-deploy
- Push CurfewBot to server to run remotely and not local
- AI-generated shame messages (Anthropic Claude)
- Curfew appeal system with AI judge rulings
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Derek Nguyen
Project Link: https://github.com/derekn4/CurfewBot
