Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,10 @@
# Discord Bot Configuration
DISCORD_TOKEN=your_discord_bot_token_here
CLIENT_ID=your_discord_client_id_here
<<<<<<< HEAD
GUILD_ID=your_discord_guild_id_here
OWNER_IDS=your_discord_id_here (optional)

# Optional — enable slash commands in every server the bot is invited to.
# Leave unset or false for single-server setup (recommended for most users).
MULTI_GUILD=false

=======
# Your server ID (used in the setup tutorial; slash commands register globally via CLIENT_ID).
GUILD_ID=your_discord_guild_id_here
OWNER_IDS=your_discord_id_here (optional)

>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
# Bot Runtime Configuration
NODE_ENV=production
LOG_LEVEL=warn
Expand Down Expand Up @@ -61,18 +51,6 @@ BACKUP_DIR=./backups
BACKUP_RETENTION_DAYS=14
POSTGRES_RESTORE_URL=

<<<<<<< HEAD
# Music (Lavalink + Riffy) — requires a Lavalink v4 server
# Local dev: run Lavalink via docker compose (see README), then use localhost below.
# Docker Compose bot service uses LAVALINK_HOST=lavalink instead.
LAVALINK_HOST=localhost
LAVALINK_PORT=2333
LAVALINK_PASSWORD=youshallnotpass
LAVALINK_SECURE=false
LAVALINK_NAME=Main
# Optional: override nodes as JSON array (for multiple Lavalink nodes)
# LAVALINK_NODES=[{"host":"lavalink","port":2333,"password":"youshallnotpass","secure":false,"name":"Main"}]
=======
# Music (Lavalink + Riffy) — requires Lavalink v4 nodes
# Default: loads public v4 SSL nodes from lavalink/nodes.json
# Source: https://lavalink.darrennathanael.com/SSL/Lavalink-SSL/
Expand All @@ -85,7 +63,6 @@ LAVALINK_NAME=Main
# LAVALINK_PASSWORD=youshallnotpass
# LAVALINK_SECURE=false
# LAVALINK_NAME=Main
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
LAVALINK_SEARCH_PLATFORM=ytmsearch
LAVALINK_REST_VERSION=v4

Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/tests.yml

This file was deleted.

36 changes: 0 additions & 36 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@ Thank you for your interest in contributing to TitanBot! This guide covers local
- Bug fixes and reliability improvements
- New commands or enhancements to existing features
- Documentation updates
<<<<<<< HEAD
- Test coverage for behavior that is easy to regress
=======
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)

Before starting large features, open an issue or discuss in the [support server](https://discord.gg/8kJBYhTGW9) so we can align on scope and avoid duplicate work.

## Getting Started

### Prerequisites

<<<<<<< HEAD
- **Node.js 18+** (CI uses Node 20)
=======
- **Node.js 20+** (Docker and CI use Node 20)
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
- **PostgreSQL** (recommended for development; the bot can fall back to in-memory storage if PostgreSQL is unavailable)
- A **Discord bot application** with the intents listed in [README.md](README.md#required-bot-intents)

Expand Down Expand Up @@ -53,38 +45,14 @@ For Docker-based setup, see [README.md](README.md#docker-deployment-recommended)

1. **Fork the repository** and create a branch from `main`.
2. **Make focused changes** — one logical change per pull request when possible.
<<<<<<< HEAD
3. **Run tests** before opening a PR (see below).
4. **Open a pull request** with a clear description of what changed and why.
=======
3. **Open a pull request** with a clear description of what changed and why.
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)

Use descriptive branch names, for example:

- `fix/ticket-panel-refresh`
- `feat/economy-shop-filter`
- `docs/contributing-guide`

<<<<<<< HEAD
## Running Tests

Tests use Node's built-in test runner:

```bash
npm test
```

Test files live in `tests/` and follow the `*.test.js` naming pattern. When adding or changing behavior, add or update tests for:

- Permission checks and command access rules
- Parsing, validation, and utility logic
- UI/panel builders and status helpers

CI runs `npm test` on every pull request and on pushes to `main` and `master`. A separate workflow also validates database migrations against PostgreSQL when migration-related code changes.

=======
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
## Database & Migrations

TitanBot uses PostgreSQL as its primary store. If PostgreSQL is unreachable at startup, the bot can operate in a **degraded in-memory mode** — but that mode is not suitable for production and should not be the only way you test persistence-related changes.
Expand All @@ -105,11 +73,7 @@ Test features that read or write guild data with **both** PostgreSQL and the mem

- **Match existing style** — ES modules (`import`/`export`), async/await, and the conventions used in neighboring files.
- **Handle errors gracefully** — catch failures, log with context, and send user-friendly embed replies where appropriate.
<<<<<<< HEAD
- **Avoid breaking guild isolation** — guild-specific config and data must stay scoped per server, especially when `MULTI_GUILD=true`.
=======
- **Avoid breaking guild isolation** — guild-specific config and data must stay scoped per server (`guild:{guildId}:...` keys, `interaction.guildId`).
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
- **Keep changes minimal** — prefer extending existing utilities and services over duplicating logic.
- **Document user-facing behavior** — update README.md when setup steps or configuration change; mention new env vars in `.env.example`.

Expand Down
21 changes: 0 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
FROM node:20-alpine

<<<<<<< HEAD
# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./

# Install only production dependencies
RUN npm ci --omit=dev

# Bundle app source
COPY . .

# Expose the health check port from src/app.js
EXPOSE 3000

# Start the bot
CMD [ "npm", "start" ]
=======
WORKDIR /usr/src/app

ENV NODE_ENV=production
Expand All @@ -32,4 +12,3 @@ COPY . .
EXPOSE 3000

CMD ["npm", "start"]
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
42 changes: 0 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,6 @@ TitanBot is fully containerized for easy deployment.
```

2. **Configure environment variables:**
<<<<<<< HEAD
Create a `.env` file from `.env.example` and fill in your bot details and PostgreSQL credentials.

3. **Start the containers:**
```bash
docker-compose up -d
```

This will start the bot, PostgreSQL, and Lavalink (when music is enabled).
=======
```bash
cp .env.example .env
```
Expand All @@ -136,31 +126,21 @@ This will start the bot, PostgreSQL, and Lavalink (when music is enabled).
```

This starts the bot and PostgreSQL. The compose file sets `POSTGRES_SSL=false` and `AUTO_MIGRATE=true` for the bundled database. Music uses public Lavalink v4 nodes from `lavalink/nodes.json` by default.
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)

### Music

Music uses [Lavalink v4](https://github.com/lavalink-devs/Lavalink) via [Riffy](https://github.com/riffy-rb/riffy), similar to [Musicify](https://github.com/codebymitch/Musicify).

<<<<<<< HEAD
1. Set in `.env`:
=======
1. By default, the bot loads multiple public v4 SSL nodes from [`lavalink/nodes.json`](lavalink/nodes.json) (sourced from [lavalink.darrennathanael.com](https://lavalink.darrennathanael.com/SSL/Lavalink-SSL/)). Edit that file to add or remove nodes.
2. To self-host Lavalink instead, run `docker compose --profile local-lavalink up -d` and set single-node env vars in `.env`:
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
```env
LAVALINK_HOST=lavalink
LAVALINK_PORT=2333
LAVALINK_PASSWORD=youshallnotpass
LAVALINK_SECURE=false
```
<<<<<<< HEAD
2. With Docker Compose, Lavalink is included automatically when you `docker compose up`.
3. On Railway, deploy Lavalink separately or as another service and point `LAVALINK_HOST` at the private hostname.
=======
Remove or rename `lavalink/nodes.json` so the bot falls back to those env vars.
3. Override nodes inline with `LAVALINK_NODES` (JSON array) or point at another file with `LAVALINK_NODES_FILE`.
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
4. Use `/play <song>` from a voice channel, or `/join` to connect without playing. Prefix shortcuts: `join`, `np`, `leave`, `pause`, `resume`, `skip`, `stop`, `volume <0-100>`, or `music <subcommand>`. Use `/nowplaying` and `/queue` for status; `/music` for loop, shuffle, seek, and other controls.

### Using GitHub Container Registry
Expand All @@ -175,11 +155,7 @@ docker pull ghcr.io/codebymitch/titanbot:main
## Manual Installation Steps

### Prerequisites
<<<<<<< HEAD
- Node.js 18.0.0 or higher
=======
- Node.js 20.10.0 or higher
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
- PostgreSQL server (recommended) or memory storage fallback
- Discord bot application with proper intents

Expand Down Expand Up @@ -236,28 +212,13 @@ docker pull ghcr.io/codebymitch/titanbot:main
This gives clear startup/online status messages while keeping logs simple for non-technical operators.
If port `3000` is busy, the bot tries the next available ports automatically (up to `PORT_RETRY_ATTEMPTS`).

<<<<<<< HEAD
### Running in multiple servers (optional)

Most users run TitanBot on a **single server** with `GUILD_ID` set (default tutorial setup). If you want commands to work in **every server** the bot is invited to, opt in with:

```env
MULTI_GUILD=true
```

Notes for multi-server mode:
- `GUILD_ID` is not used for command registration when `MULTI_GUILD=true` (you can leave it set or remove it)
- Global slash commands may take up to about an hour to propagate on first deploy
- Each server still has **isolated** config, economy, tickets, leveling, and other data
=======
### Multiple servers

Slash commands are registered **globally** on startup (via `CLIENT_ID`), so the bot works in every server it is invited to. `GUILD_ID` stays in the tutorial `.env` for setup steps but is not used for command registration.

Notes:
- Global slash commands may take up to about an hour to propagate on first deploy
- Each server has **isolated** data: config, economy, tickets, leveling, dashboards, warnings, etc. (all keys are scoped as `guild:{guildId}:...`)
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
- In the [Discord Developer Portal](https://discord.com/developers/applications), ensure your bot is not restricted to a single guild if you plan to invite it elsewhere
- Generate an OAuth2 invite URL from the [Discord Developer Portal](https://discord.com/developers/applications) (OAuth2 → URL Generator, scopes: `bot` and `applications.commands`)

Expand All @@ -279,15 +240,12 @@ Notes:
```bash
npm start
```
<<<<<<< HEAD
=======

> **Note on database migrations:** Schema tables and legacy key migrations run
> **automatically on startup**, so` managed hosts like **Railway** need no manual
> migration step — just deploy/restart. To disable auto-migration set
> `AUTO_MIGRATE=false`. You can still run a manual key migration locally with
> `node scripts/migrate-keys.js --dry-run` (preview) or `node scripts/migrate-keys.js`.
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
<a name="bot-intents"></a>

## Required Bot Intents
Expand Down
21 changes: 0 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,13 @@ services:
build: .
container_name: titanbot
restart: unless-stopped
<<<<<<< HEAD
=======
env_file:
- .env
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
environment:
- NODE_ENV=production
- DISCORD_TOKEN=${DISCORD_TOKEN}
- CLIENT_ID=${CLIENT_ID}
- GUILD_ID=${GUILD_ID}
<<<<<<< HEAD
- MULTI_GUILD=${MULTI_GUILD:-false}
- DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
- LAVALINK_HOST=lavalink
- LAVALINK_PORT=2333
- LAVALINK_PASSWORD=${LAVALINK_PASSWORD:-youshallnotpass}
- LAVALINK_SECURE=false
- PORT=3000
depends_on:
db:
condition: service_healthy
lavalink:
condition: service_started
=======
- DATABASE_URL=postgres://${POSTGRES_USER:-titanbot}:${POSTGRES_PASSWORD:-password}@db:5432/${POSTGRES_DB:-titanbot}
- POSTGRES_URL=postgres://${POSTGRES_USER:-titanbot}:${POSTGRES_PASSWORD:-password}@db:5432/${POSTGRES_DB:-titanbot}
- POSTGRES_HOST=db
Expand All @@ -51,16 +34,12 @@ services:
timeout: 5s
retries: 3
start_period: 40s
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
networks:
- titan-network

lavalink:
<<<<<<< HEAD
=======
profiles:
- local-lavalink
>>>>>>> 771ebe2 (Reorganize project structure, wire bot config, and fix dependency vulnerabilities)
image: ghcr.io/lavalink-devs/lavalink:4
container_name: titanbot-lavalink
restart: unless-stopped
Expand Down
Loading
Loading