Prerequisites

Requirement Version Notes
Node.js 22+ Download from nodejs.org
npm bundled with Node
Discord application See Part 1 below
FACEIT API key Required from Phase 2 onwards
No database server

The bot stores account links and quotes in a local SQLite file (data.db). No PostgreSQL, no Docker, no separate process to manage.

Part 1 — Discord Application

1

Create a Discord application

Go to the Discord Developer Portal, click New Application, and give it a name.

2

Add a bot

Under the Bot tab, click Add Bot. Copy the bot token — you'll need it as DISCORD_TOKEN. Never share this token.

3

Note your Application ID

Under General Information, copy the Application ID. This is your DISCORD_CLIENT_ID.

4

Invite the bot to your server

Build an OAuth2 URL (replace YOUR_CLIENT_ID). Select your server and authorise — this grants the bot and applications.commands scopes.

https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=277025770496&scope=bot+applications.commands
5

Get your Server ID

In Discord, enable Developer Mode (User Settings → Advanced). Right-click your server icon → Copy Server ID. This is your DISCORD_GUILD_ID.

Part 2 — FACEIT API Key

1

Create a FACEIT developer account

Go to developers.faceit.com and sign in with your FACEIT account.

2

Create an application and generate an API key

Create a new application. Under API Keys, generate a Server-Side key. Copy it as FACEIT_API_KEY.

Keep it server-side

Never expose your FACEIT API key in client-side code or commit it to version control.

Part 3 — Run the Bot

1

Clone the repository

git clone https://github.com/Easton99/Insomniacs-bot.git
cd Insomniacs-bot
2

Install dependencies

npm install
3

Configure environment variables

Copy the example file and fill in DISCORD_TOKEN, DISCORD_CLIENT_ID, DISCORD_GUILD_ID, and FACEIT_API_KEY:

cp .env.example .env
4

Set up the database

Creates the local SQLite file and applies the schema — one command, done:

npm run prisma:migrate
5

Register Discord slash commands

npm run commands:register
6

Start the bot

npm run dev

Uses tsx --watch — the bot restarts automatically when you save a source file.

Production — Docker (optional)

For running on a server 24/7. Docker is not required for development.

1

Fill in .env

The Compose file overrides DATABASE_URL to store the SQLite file in a named volume (bot_data) so it persists across container rebuilds.

2

Start

docker compose up -d
3

Apply migrations (first time only)

docker compose exec bot npm run prisma:migrate
4

View logs

docker compose logs -f bot

Environment Variables

Variable Required Default Description
DISCORD_TOKEN Bot token from Discord Developer Portal
DISCORD_CLIENT_ID Application ID from Discord Developer Portal
DISCORD_GUILD_ID ID of the Discord server to register commands to
FACEIT_API_KEY Phase 2+ Server-side FACEIT Data API key
DATABASE_URL file:./data.db SQLite file path — change if you want the db somewhere else
BOT_TIMEZONE Europe/London Timezone for session grouping and the "Go To Bed" achievement
CHEMISTRY_MIN_MATCHES 10 Minimum shared matches before labelling a "best" or "worst" teammate
NODE_ENV development development or production
LOG_LEVEL info Logging level: trace debug info warn error

npm Scripts

Script Description
npm run dev Start in development mode with hot reload (tsx --watch)
npm run build Compile TypeScript to dist/
npm start Run compiled bot from dist/index.js
npm run lint Run ESLint over src/
npm test Run Vitest test suite
npm run commands:register Register slash commands to DISCORD_GUILD_ID
npm run prisma:migrate Apply pending schema changes (creates data.db on first run)
npm run prisma:generate Re-generate the Prisma client after schema changes
npm run prisma:studio Open Prisma Studio (visual database browser)
You're set up

Try /ping in your server to confirm the bot is responding. Then link your FACEIT account with /link once Phase 2 is released.