Skip to content

Latest commit

 

History

History
206 lines (164 loc) · 10.9 KB

File metadata and controls

206 lines (164 loc) · 10.9 KB

Project Structure

This Discord bot was converted from the Idle Champions Code Redeemer browser extension. All browser extension code has been removed; only the Discord bot remains.

Repository Composition [OSPS-QA-04.01]

This project consists of a single monolithic repository containing all source code:

Component Repository Status Purpose
Discord Bot This repository Active Main bot codebase - handles commands, API interactions, and database

No subprojects or submodules exist. All functionality is contained within this single repository and compiled into a single Docker container image for deployment.

Directory Layout

idle-code-redeemer/
├── README.md              ← Start here
├── docs/                  ← All documentation
├── BUILD.md               ← Build instructions
├── LICENSE
├── .env.example           ← Configuration template
├── .gitignore
├── drizzle.config.ts      ← Drizzle ORM / drizzle-kit configuration
│
├── src/
│   ├── bot/               ← Discord bot (ACTIVE)
│   │   ├── bot.ts         ← Main Discord client & event handlers
│   │   ├── api/           ← Game server API client
│   │   ├── commands/      ← Slash command handlers (15 commands)
│   │   ├── database/      ← Database managers & Drizzle schema
│   │   │   ├── db.ts      ← Drizzle connection & migrate()
│   │   │   ├── userManager.ts
│   │   │   ├── codeManager.ts
│   │   │   ├── auditManager.ts
│   │   │   ├── backfillManager.ts
│   │   │   ├── schema/    ← Drizzle table definitions (one file per table)
│   │   │   └── migrations/ ← Auto-generated SQL migration files
│   │   ├── handlers/      ← Message scanning for codes
│   │   └── utils/         ← Utilities (logger, crypto, debug, API request logging)
│   │
│   └── bot/api/types/     ← Type definitions from game API
│       ├── player_data.d.ts
│       ├── redeem_code_response.d.ts
│       ├── blacksmith_response.d.ts
│       └── server_definitions.d.ts
│
├── data/                  ← SQLite database (git-ignored)
│   └── idle.db
│
├── debug/                 ← API response logs (auto-cleanup) (git-ignored)
│   └── *.json
│
├── scripts/               ← Utility scripts
│   └── get-credentials.js
│
├── node_modules/          ← Dependencies (git-ignored)
├── package.json           ← Bun dependencies & scripts
├── tsconfig.bot.json      ← TypeScript config (noEmit: true, type-check only)
│
├── .mise.toml             ← Mise task definitions & tool versions
├── Dockerfile             ← Multi-stage Docker build
├── docker-compose.yml     ← Multi-container orchestration
└── .dockerignore

Key Files

Core Bot

Commands (15 slash commands)

Database

Auto Features

Tests

Configuration

  • .env.example - Template for environment variables
  • .mise.toml - Task definitions and tool versions (Bun 1.3.14, Gitleaks)
  • bunfig.toml - Bun configuration (test preload, registered via [test].preload)
  • package.json - Bun scripts & dependencies
  • tsconfig.bot.json - TypeScript compiler options (noEmit: true — type-check only)
  • drizzle.config.ts - Drizzle Kit configuration (schema path, migrations output)

Dependencies

Production

  • discord.js - Discord bot framework
  • drizzle-orm - Type-safe ORM for SQLite
  • winston - Logging framework

Note: dotenv, node-fetch, and sqlite3 were removed. Bun loads .env natively, provides a built-in Fetch API, and includes bun:sqlite as a first-party module.

Development

  • typescript - Type checking (type-check only; noEmit: true)
  • @types/bun - Bun type definitions
  • drizzle-kit - Schema management & migration generation
  • eslint - Code linting
  • prettier - Code formatting
  • husky - Git hooks
  • commitlint - Commit message validation
  • lint-staged - Pre-commit linting

Runtime (managed by Mise)

  • bun 1.3.14 - JavaScript runtime, package manager, and bundler

Removed (Cleanup)

The following browser extension code has been permanently removed:

  • src/chestManagement/ - Extension chest management UI
  • src/inject/ - Extension content script
  • src/options/ - Extension options page
  • src/service_worker/ - Extension background service worker
  • src/shared/ - Shared extension code
  • extension/ - Extension manifest, assets, distribution files

Reason: Converted to Discord bot; extension code no longer needed.

Build & Deployment

For local development:

bun install
mise run dev

For production binary:

bun install
mise run prod:build
./dist-bundle/bot

For Docker deployment:

docker-compose up

For production:

  • mise run prod:build compiles a self-contained binary (dist-bundle/bot) with Bun runtime embedded
  • No Bun, Node.js, or node_modules required at runtime
  • Docker image only needs the binary + ca-certificates
  • Configure DISCORD_TOKEN from Discord Developer Portal
  • Set DISCORD_GUILD_ID and DISCORD_CHANNEL_ID
  • Runs 24/7 in the cloud

See README.md and docs/development.md for details.