- Create a new Discord bot in the developer portal
- Fork the repository
- Clone your fork to your computer
- If you'd like to get a tour of the codebase and a second pair of eyes during setup, snag a slot on the calendar
- Copy
.env.example
to.env
- Configure env variable
- From the General Information page:
- From the Bot page:
- (optional) Request access token for Amplitude metrics from vcarl#7694 and paste the token as
AMPLITUDE_KEY
- From the Bot page: 3 settings off, 2 settings on
- Public Bot off
- Requires Oauth2 Code Grant off
- Presence Intent off
- Server Members Intent on
- Message Content Intent on
npm install
npm run dev
- Look for the following message in the logs, and open the URL in a browser where you're logged into Discord.
Bot started. If necessary, add it to your test server:
There are subtle issues when making some chaings. These are notes for steps to take to make sure it's done correctly when needed.
Adding a new environment variable needs to be done in several places to work corectly and be predictable for new developers:
- Add a suitable example to
.env.example
- Add to your own
.env
(and restart the dev server) - Add to the action in
.github/workflows/node.js.yml
- Add to the Kubernetes config under `cluster/deployment.yml
This bot runs on a managed Kubernetes cluster on DigitalOcean. It's possible (tho beyond the scope of this document) to configure a local kubectl
environment to access and control this cluster. What follows are reference commands for performing common tasks:
# Tail the logs of the production instance
kubectl logs -f mod-bot-set-0
# Force a restart without merging a PR (as of 2024-09 only 1 replica is in use)
kubectl scale statefulset mod-bot-set --replicas 0
kubectl scale statefulset mod-bot-set --replicas 1
# Copy out the production database (for backups!)
kubectl cp mod-bot-set-0:data/mod-bot.sqlite3 ./mod-bot-prod.sqlite3
# Execute a command on the production instance.
# Rarely necessary, but useful for diagnostics if something's gone sideways.
kubectl exec mod-bot-set-0 -- npm run start:migrate
# Extract production secrets (in base64)
kubectl get secret modbot-env -o json