A clean, modern Discord bot for managing questions and posting a daily question of the day.
- Node.js + TypeScript
- discord.js v14 (slash commands)
- Prisma + PostgreSQL
- node-cron scheduler
- pino logging
- Vitest + ESLint + Prettier
qotd/
prisma/
schema.prisma
seed.ts
src/
commands/
config/
db/
events/
jobs/
repositories/
scripts/
services/
startup/
types/
utils/
index.ts
tests/
quoteService.test.ts
-
Install dependencies:
npm install
-
Copy env file and fill values:
copy .env.example .env
-
Create database and Prisma client:
npm run db:migrate -- --name init npm run db:generate npm run seed
-
Register slash commands:
npm run bot:register
-
Run in development:
npm run dev
/question add text:<question> author:<optional>/question random/qotd post/qotd setup channel:<#channel> time:<HH:mm>
/qotd setup saves your schedule in qotd-settings.json, so your configured channel/time persists across restarts.
npm run check:typesnpm run lintnpm run testnpm run build
For container deploys (Dokploy), these optional env vars control startup behavior:
DB_PUSH_ON_DEPLOY(defaulttrue): runprisma db pushduring startup.DB_PUSH_MAX_RETRIES(default3): number of retries when DB is unreachable.DB_PUSH_RETRY_DELAY_SECONDS(default5): delay between retries.REQUIRE_DB_ON_STARTUP(defaultfalse): iftrue, container exits when schema apply fails.
Recommended for unstable/external DB links:
- Set
REQUIRE_DB_ON_STARTUP=falseso the bot can still boot and reconnect behavior can be observed in logs.