A Discord bot for Star Trek Fleet Command territory defense reminders with web-based management. Named after the Borg character Seven of Nine from Star Trek: Voyager.
- Web-Based Admin Panel: Manage all schedules through a simple, tabbed web interface
- Discord OAuth Authentication: Secure login with your Discord account
- Territory Defense Reminders: Schedule weekly reminders for territory takeovers
- Message Templates: Choose from predefined message templates or use defaults
- Auto-Publishing: Automatically publishes messages in announcement channels
- Role Mentions: Configure role mentions for notifications
- Advance Notifications: Send reminders 5-10 minutes before defense time
- Timezone Support: Times are in UTC with automatic conversion in Discord
- Simple Design: Blunt, efficient interface inspired by the Borg
- Python 3.12+
- Discord Bot Application - Create one at the Discord Developer Portal
- Go to Discord Developer Portal
- Click "New Application" and give it a name (e.g., "Seven of Nine")
- Navigate to the Bot tab:
- Click "Add Bot"
- Enable SERVER MEMBERS INTENT
- Enable MESSAGE CONTENT INTENT
- Copy your bot token for later
- Navigate to OAuth2 → General:
- Add redirect URL:
http://localhost:8000/oauth/callback(or your production URL) - Copy your Client ID and Client Secret
- Add redirect URL:
- Navigate to OAuth2 → URL Generator:
- Select scopes:
bot,applications.commands - Select bot permissions:
- Read Messages/View Channels
- Send Messages
- Send Messages in Threads
- Manage Messages (for auto-publishing)
- Embed Links
- Read Message History
- Mention Everyone
- Use Slash Commands
- Copy the generated URL and use it to invite the bot to your server
- Select scopes:
-
Clone or download this repository
git clone https://github.com/ComputerEndProgram/Seven-of-Nine.git cd Seven-of-Nine -
Install Python dependencies
python3 -m pip install -U pip python3 -m pip install -r requirements.txt
-
Configure the application
Copy the example environment file:
cp .env.example .env
Edit
.envwith your settings:# Discord Bot Configuration TOKEN=your_discord_bot_token_here SYNC_SLASH_COMMANDS=on # Web Dashboard Configuration BASE_URL=http://localhost:8000 DISCORD_CLIENT_ID=your_discord_client_id_here DISCORD_CLIENT_SECRET=your_discord_client_secret_here DISCORD_OAUTH_REDIRECT_URI=http://localhost:8000/oauth/callback SESSION_SECRET=generate_a_random_secret_key_here # Database DATABASE_URL=sqlite+aiosqlite:///./seven_of_nine.db # Web Server WEB_UI_PORT=8000Important Configuration Notes:
- Get
TOKENfrom your bot's page in the Discord Developer Portal (Bot tab) - Get
DISCORD_CLIENT_IDandDISCORD_CLIENT_SECRETfrom OAuth2 → General - Generate
SESSION_SECRETwith:python3 -c "import secrets; print(secrets.token_hex(32))"or runpython3 generate_secret.py - Set
SYNC_SLASH_COMMANDS=onon first run, then change toofffor subsequent runs
- Get
-
Configure territory presets (optional)
Edit
territory_presets.jsonto add or modify territory names:{ "territories": [ "Astrida", "Corvus", "Kaikara", "Morada", "Talios", "Xind" ] }Note: Territory management is done by editing this file directly for admin control.
Start the application (this starts both the bot and web dashboard):
python3 main.pyThe application will:
- Start the Discord bot
- Start the web dashboard on
http://localhost:8000 - Begin checking for scheduled reminders
Access the web dashboard at http://localhost:8000 and login with Discord to manage schedules.
- Login: Click "Login with Discord" on the home page
- Select Guild: Choose a server where you have "Manage Server" permission
- Configure Guild (Configuration Tab):
- Enter a role ID for mentions (optional, defaults to @everyone)
- To get a role ID: Enable Developer Mode in Discord → Right-click role → Copy ID
- Create Schedule (Scheduled Messages Tab):
- Select a territory name from the preset list
- Choose a message template
- Choose a channel where reminders will be sent
- Select the day of the week
- Enter the time in UTC (24-hour format)
- Optionally set advance notice (5-10 minutes before defense)
- Click "Create Schedule"
- Manage Schedules: View, enable/disable, or delete existing schedules in the table
- Manage Territories (optional):
- Edit
territory_presets.jsondirectly to add/remove territory names - Changes take effect after restarting the application
- Edit
The bot has minimal Discord commands. All management is done through the web dashboard.
/info- Display bot information and dashboard link
Territory defense reminders use this format:
🛸 Territory Defense Notification: [Territory Name]
@Role
A Territory Defense is scheduled for [Timestamp].
— Transmission complete.
The timestamp is automatically converted to each user's local timezone in Discord.
You can deploy Seven of Nine using Docker for easier management.
-
Clone and configure
git clone https://github.com/ComputerEndProgram/Seven-of-Nine.git cd Seven-of-Nine cp .env.example .env # Edit .env with your configuration
-
Build and run with Docker Compose
docker compose up -d
-
View logs
docker compose logs -f
-
Stop the container
docker compose down
-
Update your
.envfile with production URLs:BASE_URL=https://sevenofnine.yourdomain.com DISCORD_OAUTH_REDIRECT_URI=https://sevenofnine.yourdomain.com/oauth/callback -
Update Discord OAuth settings in the Developer Portal with your production redirect URI
-
Configure Caddy (
Caddyfile):sevenofnine.yourdomain.com { reverse_proxy localhost:8000 }
-
Run with a process manager (e.g., systemd):
Create
/etc/systemd/system/sevenofnine.service:[Unit] Description=Seven of Nine Territory Defense Bot After=network.target [Service] Type=simple User=yourusername WorkingDirectory=/path/to/Seven-of-Nine Environment="PATH=/usr/local/bin:/usr/bin:/bin" ExecStart=/usr/bin/python3 main.py Restart=always RestartSec=10 [Install] WantedBy=multi-user.target
Enable and start:
sudo systemctl daemon-reload sudo systemctl enable sevenofnine sudo systemctl start sevenofnine
Bot won't start:
- Check that your
TOKENis correct in.env - Verify the bot has the required intents enabled in Discord Developer Portal
Can't login to dashboard:
- Verify
DISCORD_CLIENT_IDandDISCORD_CLIENT_SECRETare correct - Check that the redirect URI is added in Discord OAuth2 settings
- Make sure
BASE_URLmatches your actual URL
Schedules not sending:
- Verify the bot has permissions to send messages in the channel
- Check that the schedule is enabled (not disabled)
- Look at the "Next Send" time to see when it will send
Messages not auto-publishing:
- The bot needs "Manage Messages" permission
- This only works in announcement channels (Discord News channels)
- Language: Python 3.12+
- Bot Framework: discord.py 2.5.2
- Web Framework: FastAPI
- Database: SQLite with SQLAlchemy (async)
- Authentication: Discord OAuth2 with signed cookies
GNU General Public License v3.0 - See LICENSE.txt for details.
Based on code from the message-scheduler-old project by Taaku18.
Seven of Nine, Tertiary Adjunct of Unimatrix 01
Resistance is futile.