Local setup
By the end of this page the bot is running on your machine, logged in to your Discord server, with a migrated database behind it.
What you need
Section titled “What you need”| Requirement | Detail |
|---|---|
| Node | Version 24. The bot declares >=24.21.0 and .nvmrc holds 24.21.0. Install it from nodejs.org or with a version manager such as nvm. |
| Bun | Installs dependencies and runs the scripts (curl -fsSL https://bun.sh/install | bash). bun run does not load .env for the dev server or the migration script, so the commands below pass --env-file to Bun. |
| Postgres database | A Neon database (a hosted Postgres service) with the vector extension (pgvector, which stores the numbers used for search by meaning). The tests and CI use Postgres 18. |
| Discord application | A bot in a test server. See Discord application. Use a test application: a second copy of the bot with the same token and server answers too. |
Set it up
Section titled “Set it up”-
Clone the bot repository and install.
Terminal window git clone git@github.com:dogelabsvr/doge-discord-bot.git && cd doge-discord-bot && bun install -
Create your env file.
Terminal window cp .env.example .envNever commit
.env. The example file says where each value comes from. Keep values bare: no# commentafter a value on the same line. -
Fill in the four required values. Open
.envin an editor and setDISCORD_TOKEN,DISCORD_GUILD_ID,DATABASE_URL_POOLEDandDATABASE_URL. The bot refuses to start without them. Also setREMINDER_ALLOWLISTto your own Discord user id (see the warning under What a good start looks like). See Configuration for every variable.Create the database shows where to click. Neon gives two URLs for one database: the pooled one (host contains
-pooler) isDATABASE_URL_POOLED, the direct one isDATABASE_URL. With a local Postgres both are the same URL. -
Enable pgvector. In your database, for example in the Neon SQL Editor, run:
CREATE EXTENSION IF NOT EXISTS vector;A migration (a script that creates the bot’s tables) runs this too, but only a database user allowed to create extensions can. On a local Postgres on macOS, run
brew install pgvectorfirst. -
Apply the migrations.
Terminal window bun --env-file=.env run db:migrateThe package scripts do not read
.envthemselves, so--env-filehands the file to Bun for this one command. It prints[migrate] completeon success. It readsDATABASE_URL, which must be the direct URL, and always connects with TLS (an encrypted connection). A local Postgres without TLS cannot use it: apply the migrations withpsqlinstead, the way the tests do. -
Start the bot in watch mode. Leave this terminal open: the bot runs in it.
Terminal window bun --env-file=.env run devWatch mode restarts the bot when you save a file. Stop it with Ctrl+C.
What a good start looks like
Section titled “What a good start looks like”The terminal shows [http] listening on :3000, then [bot] logged in as <bot tag> and [bot] registered N guild commands, then one line per feature saying enabled, disabled or off: needs .... Asking, summaries, ticket prompts, meeting transcripts and voice notes are off by default. Scripts and health lists every line. If the bot exits instead, see Troubleshooting.
Then, in Discord, type /whoami in any channel of your server. If the bot answers with your member profile (only you see it), the setup works. The bot also starts reading your server’s message history in the background. That is normal: see First start.
Compile and run like production
Section titled “Compile and run like production”bun run buildnode --env-file=.env dist/index.jsbuild compiles to dist/ and rewrites the @/ import aliases. Production runs node dist/index.js with Node, not Bun. bun run start runs the same file but does not load .env.
Run the tests
Section titled “Run the tests”| Command | What it does |
|---|---|
bun run test | Unit tests. |
bun run typecheck | Type check with tsc --noEmit. |
bun run verify | Typecheck and unit tests together. |
bun run test:integration | Integration tests against a real database. |
The unit tests need no database. Integration tests need TEST_DATABASE_URL, the direct URL of a throwaway database with pgvector (on a Neon branch run CREATE EXTENSION vector;; on a local Postgres on macOS run brew install pgvector first). Use a separate Neon branch, never your real data. The tests do not read .env, so put the variable in the command’s environment: TEST_DATABASE_URL=<url> bun run test:integration. Without it they stop with TEST_DATABASE_URL is required for integration tests. The integration files run one after another because they share the database.
They do not create the tables. Apply the migrations to the test database first, the way CI does. This needs psql, the Postgres command line client:
for f in src/db/migrations/*.sql; do psql "$TEST_DATABASE_URL" -v ON_ERROR_STOP=1 -f "$f"; done- Discord application to create the bot and get its token.
- Configuration for every environment variable.