The source code of the helper bot for the SupportMail support server.
If you want to use this code, you can do so by forking this repository and modifying the code to fit your needs.
-
Node.js (version 20 or higher)
-
bun package manager
-
MongoDB database
-
Discord Bot Token from the Discord Developer Portal
-
Sentry account (required)
Fork this repository to your own GitHub account to create a personal copy of the code.
git clone https://github.com/<your-username>/<repositoryname>.git
cd <repositoryname>bun installCreate environment files in the root directory, based on the .env.example file:
.env.dev: For development environment variables.env.production: For production environment variables
DB_ENCRYPTION_KEY is the AES-256-GCM key for encrypted DB fields: 64 hex chars, generate with openssl rand -hex 32.
- Invite your bot to your Discord server with the necessary permissions
- Set up the required channels and roles according to your server structure
- Copy
example.config.jsontoconfig.jsonand edit it (validated againstconfig-schema.json) - Copy
example.vote.yamltovote.yamlto customize the vote message, the role-lost DM and the vote bots. The file is re-read on change (no restart); if it is missing or invalid, the example file is used.
Development mode:
bun devProduction mode (systemd):
The bot runs as the systemd unit sm-helper.service (user helper, checkout /home/helper/bot). One-time setup, by a user with sudo, from the checkout:
sudo make install # unit, MongoDB wait script, sudo rule for the deploy scriptThen, as helper:
# Deploy: pull, install, build, restart
bash ~/bot/scripts/deploy.sh
# Stop / restart the bot
sudo systemctl stop sm-helper.service
sudo systemctl restart sm-helper.service
# View logs
journalctl -u sm-helper -fbun buildThis doesn't have any output though as Bun handles builds internally.
The bot requires the following Discord permissions:
- Send Messages
- Use Slash Commands
- Manage Messages
- Manage Threads
- Add Reactions
- Read Message History
- Embed Links
- Attach Files
- Mention Everyone
- Use External Emojis
Each support post gets a reminder after 24h without a message from its author and is closed automatically after 48h if the author does not react. To repair or backfill these Agenda jobs:
bun run --env-file=.env.production src/scripts/fixPostReminders.ts --dry # preview
bun run --env-file=.env.production src/scripts/fixPostReminders.ts --days=7The bot uses MongoDB to store data. Make sure your MongoDB instance is running and accessible via the MONGODB_URI in your environment file. The bot will automatically create the necessary collections and indexes on startup.
Please refer to the FEATURES.md file for a detailed list of current features, components, event-driven automations, cron jobs, database models, caches, utilities, and configuration options.
MIT
- Add suggestion tracking to the bot
- one command for starting the "filling" of the db with the current backlog of suggestions
- one command for showing the current suggestions in a paginated message
- modify suggestion command to do the DB stuff instead of just editing the post
- Add a way to input
ends_aton/incident createfield for maintenance