Manual Setup
This is the manual install procedure for technical users who’d rather not use the guided wizard. If you want the hand-held path, use the setup wizard instead as it creates .env, generates a safe CRYPTO_SECRET, configures PostgreSQL, and runs the install for you.
Prerequisites
Section titled “Prerequisites”- Bun
- PostgreSQL installed natively, or run in a Docker container (see step 2)
PostgreSQL schema, pgcrypto, seeds, and migrations initialize automatically on bot startup.
1. Install
Section titled “1. Install”git clone https://github.com/Bredrumb/TomoriBot.gitcd TomoriBotbun install --frozen-lockfile2. Configure
Section titled “2. Configure”Create your environment file from the example and fill in the required values:
Copy-Item .env.example .envcp .env.example .envcp .env.example .envRequired:
DISCORD_TOKEN: your Discord bot token (enable theGuildMembers,MessageContent, andGuildPresencesprivileged intents).CRYPTO_SECRET: a 32-character encryption key (used to encrypt stored API keys).- PostgreSQL connection:
POSTGRES_HOST,POSTGRES_PORT,POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DB. ALLOW_PRIVATE_NETWORK:true,false, or ahost:portlist. See Private networks to choose.
Keep a protected copy of your encryption secret separately from database backups. New backups contain no .env. For rotation, use CRYPTO_SECRET_V1, CRYPTO_SECRET_V2, or any later positive integer version, with optional CRYPTO_SECRET_CURRENT selection.
Optional tuning lives in .env.optional.example. Copy over any values you want to customize (limits, timeouts, feature toggles, local server URLs, etc.).
Keep the data/ directory on persistent storage. Local files can include persona avatars and sprites in data/avatars/, voice samples in data/voice-samples/, and custom expressions in data/custom-expressions/. The database is stored separately, so back it up alongside these files.
3. Run
Section titled “3. Run”bun run devWhen you see TomoriBot up and running!, go to Discord and run /setup in your server to connect an AI provider and initialize the bot. The command opens a guided checklist panel, and nothing is written until you press Finish Setup.
Use bun run launch instead of bun run dev if you want optional local servers (SearXNG, Crawl4AI, local TTS/STT) launched alongside the bot:
bun run launch --searxng --crawl4aibun run launch --help # see all flagsOptional extras (the manual “Full Install”)
Section titled “Optional extras (the manual “Full Install”)”The setup wizard’s Full Install path layers lightweight extras on top of the base install. None are required to run the bot, but each unlocks a feature. If you’re installing by hand, add whichever you want:
pgvector: document/RAG memory
Section titled “pgvector: document/RAG memory”RAG (document uploads and cross-channel recall) stores embeddings in a vector column, which needs the pgvector extension.
There is no prebuilt pgvector package for native Windows PostgreSQL. Installing it natively requires building from source against your exact PostgreSQL version with Visual Studio C++ and nmake (see pgvector’s Windows instructions). The simpler path on Windows is to run PostgreSQL in the pgvector/pgvector container shown under Configure, then open psql inside it:
docker exec -it tomori-db psql -U tomori -d tomoriIf you built pgvector for native Windows PostgreSQL, connect with psql instead:
psql -h localhost -p 5432 -U tomori -d tomodbInstall the pgvector package for your PostgreSQL major version (Debian/Ubuntu example for PostgreSQL 16):
sudo apt-get install -y postgresql-16-pgvectorConnect to your database with psql (or docker exec -it tomori-db psql -U tomori -d tomori if running in Docker):
psql -h localhost -p 5432 -U tomori -d tomodbInstall pgvector via Homebrew against Homebrew’s matching PostgreSQL formula (if you pin an older PostgreSQL formula whose bottle does not match, build pgvector from source with make && make install against that formula’s pg_config):
brew install pgvectorConnect to your database with psql (or docker exec -it tomori-db psql -U tomori -d tomori if running in Docker):
psql -h localhost -p 5432 -U tomori -d tomodbOnce connected (psql prompts for POSTGRES_PASSWORD), enable the extension:
CREATE EXTENSION vector;Without pgvector the bot still runs but RAG features become completely unavailable. This extension is also required on the target database before restoring a backup; see Maintenance & Backups for details.
pg_cron: scheduled cleanup jobs
Section titled “pg_cron: scheduled cleanup jobs”pg_cron powers optional periodic database maintenance (cooldown/reminder-row cleanup). Docker Compose from this repo already configures it.
For a self-managed PostgreSQL, install the extension package if needed before loading it in postgresql.conf:
There are no standard prebuilt binaries for pg_cron on native Windows PostgreSQL; compiling it requires a Visual Studio C++ build (nmake) against your PostgreSQL server headers, or running PostgreSQL via Docker Compose or WSL2 Linux instead. Because pg_cron only cleans expired rows, skipping it leaves all bot features working.
Install the pg_cron package for your PostgreSQL major version (Debian/Ubuntu example for PostgreSQL 16):
sudo apt-get install -y postgresql-16-cronInstall pg_cron via Homebrew against Homebrew’s matching PostgreSQL formula:
brew install pg_cronFind your active config file in psql:
SHOW config_file;Enable the extension in postgresql.conf: append to shared_preload_libraries if it already lists other libraries:
shared_preload_libraries = 'pg_cron' # e.g. 'pg_stat_statements,pg_cron'cron.database_name = 'your_dbname'Restart PostgreSQL, then:
CREATE EXTENSION IF NOT EXISTS pg_cron;Tokenizer assets
Section titled “Tokenizer assets”NovelAI text generation and model-aware logit bias need local tokenizer assets:
bun run setup:tokenizersSome families (e.g. Gemma) are gated and require a HuggingFace token after you accept their license:
$secureToken = Read-Host -Prompt "Hugging Face token" -AsSecureString$env:HF_TOKEN = [System.Net.NetworkCredential]::new("", $secureToken).Passwordtry { bun run setup:tokenizers} finally { Remove-Item Env:\HF_TOKEN -ErrorAction SilentlyContinue}read -r -s -p "Hugging Face token: " HF_TOKENechoHF_TOKEN="$HF_TOKEN" bun run setup:tokenizersunset HF_TOKENprintf 'Hugging Face token: 'read -r -s HF_TOKENechoHF_TOKEN="$HF_TOKEN" bun run setup:tokenizersunset HF_TOKENMissing assets disable optional logit bias. NovelAI text generation requires its three tokenizer families and returns a setup error if they are missing or invalid. These families use pinned public MIT definitions and need no Hugging Face token. To install only those families:
bun run setup:tokenizers --family novelai_nerdstash_v2bun run setup:tokenizers --family novelai_llama3bun run setup:tokenizers --family novelai_glmThe downloader writes to the repository’s tokenizers/ directory. If TOKENIZER_ASSET_DIR points elsewhere, copy the downloaded family directories there. Restart TomoriBot after installing or repairing assets, because the runtime caches load failures.
The secure fetch_url fallback and the DuckDuckGo web_search fallback both run in process, so neither needs an extra installation.
Maintenance, updating, and backups
Section titled “Maintenance, updating, and backups”Once you’re installed, the host-side scripts (bun run update, bun run backup, bun run restore-backup, bun run nuke-db, bun run rotate-keys, …) and the update and backup procedures all live on the Maintenance & Backups page. If you’re about to pull a new version, start with Maintenance & Backups.