Project Detail
This project is a Sapphire-based Discord bot that records message, command, member, and voice activity for every guild it joins. Metrics are buffered in Redis, persisted with Prisma/PostgreSQL, and rendered into shareable image cards using @napi-rs/canvas.
Clone the repository and install packages. If you are already inside the project folder you can skip the git clone step.
git clone https://github.com/your-org/discord-server-analytic.git
cd discord-server-analytic
pnpm install
Use the same package manager for all remaining commands. For npm users replace pnpm with npm.
Create a .env file in the project root. The bot loads configuration through @skyra/env-utilities during boot.
DISCORD_TOKEN=your_discord_bot_token
OWNERS=123456789012345678,987654321098765432
DATABASE_URL=postgresql://user:password@localhost:5432/server_analytic?schema=public
REDIS_URL=redis://localhost:6379
# Only include this line if your Redis instance requires authentication
# REDIS_PASSWORD=your_redis_password
Never commit this file; it contains sensitive credentials.
DATABASE_URL if it does not exist.pnpm prisma migrate deploy
During active development you can instead run pnpm prisma migrate dev --name init to create new migration files as the schema changes.
pnpm watch:start
tsc-watch recompiles the project and restarts the bot whenever you save changes. Slash commands are (bulk) registered on login.
Alternatively, build once and start:
pnpm dev
Compile TypeScript and launch the compiled output:
pnpm build
pnpm start
Ensure the production host has the same environment variables and network access to PostgreSQL and Redis.
DISCORD_TOKEN is correct and the bot has been invited with the intents specified above.DATABASE_URL, ensure PostgreSQL is reachable, and re-run if migrations were missed.This project is distributed under the MIT license. Refer to LICENSE for the full text.
pnpm prisma migrate deployREDIS_PASSWORD if unnecessary or supply the correct password.