No description
Find a file
Yumeo a02e1b3bdb
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m9s
fix: refresh oauth token when it expires
2025-07-28 12:56:26 +02:00
.forgejo/workflows initial commit 2025-07-18 20:36:26 +02:00
.vscode initial commit 2025-07-18 20:36:26 +02:00
src fix: refresh oauth token when it expires 2025-07-28 12:56:26 +02:00
.env.example initial commit 2025-07-18 20:36:26 +02:00
.gitignore initial commit 2025-07-18 20:36:26 +02:00
biome.json initial commit 2025-07-18 20:36:26 +02:00
bun.lock initial commit 2025-07-18 20:36:26 +02:00
Dockerfile initial commit 2025-07-18 20:36:26 +02:00
package.json initial commit 2025-07-18 20:36:26 +02:00
README.md initial commit 2025-07-18 20:36:26 +02:00
tsconfig.json fix: output js files 2025-07-18 20:43:41 +02:00

osu-discord-bot

A Discord bot that monitors osu! player scores and posts them to a designated channel.

Features

  • Monitors recent scores for specified osu! players
  • Supports all game modes (osu!, osu!taiko, osu!catch, osu!mania)
  • Posts score embeds to Discord with player stats and beatmap information
  • Automatic database cleanup (keeps last 10 scores per player per mode)
  • Comprehensive logging system with file output

Setup

Prerequisites

Installation

  1. Clone the repository:
git clone <repository-url>
cd osu-discord-bot
  1. Install dependencies:
bun install
  1. Create a .env file by copying the example:
cp .env.example .env
  1. Edit the .env file and fill in your actual values.

Configuration

  • DISCORD_TOKEN: Your Discord bot token from the Discord Developer Portal
  • DISCORD_CHANNEL_ID: The ID of the Discord channel where scores will be posted
  • OSU_CLIENT_ID: Your osu! OAuth application client ID
  • OSU_CLIENT_SECRET: Your osu! OAuth application client secret
  • OSU_USERNAMES: Comma-separated list of osu! usernames or user IDs to monitor

Running

Development mode (with hot reload):

bun run dev

Production mode:

bun run start

Direct execution:

bun src/index.ts

Docker

Using prebuilt images:

# Create .env file first (see Setup section)
docker run -d \
  --name osu-discord-bot \
  --env-file .env \
  -v $(pwd)/data:/usr/src/app/data \
  -v $(pwd)/logs:/usr/src/app/logs \
  git.yumeo.dev/yumeo/osu-discord-bot:latest

Building locally:

# Build the image
docker build -t osu-discord-bot .

# Run the container
docker run -d \
  --name osu-discord-bot \
  --env-file .env \
  -v $(pwd)/data:/usr/src/app/data \
  -v $(pwd)/logs:/usr/src/app/logs \
  osu-discord-bot

Using Docker Compose:

services:
  osu-discord-bot:
    image: git.yumeo.dev/yumeo/osu-discord-bot:latest
    container_name: osu-discord-bot
    env_file:
      - .env
    volumes:
      - ./data:/usr/src/app/data
      - ./logs:/usr/src/app/logs
    restart: unless-stopped

Logging

The bot automatically creates logs in the logs/ directory with the following features:

  • Daily log rotation: Each day gets its own log file (format: bot-YYYY-MM-DD.log)
  • Multiple log levels: INFO, ERROR, and DEBUG messages
  • Console and file output: All logs are written to both console and file
  • Comprehensive logging: API calls, database operations, Discord interactions, and errors are all logged
  • Graceful shutdown: Logs are properly closed when the bot shuts down

Log files will contain:

  • Bot startup and shutdown events
  • User and score fetching operations
  • Database operations (new scores, cleanup)
  • Discord message sending
  • Error handling and debugging information

Database

The bot uses SQLite to store processed scores and prevent duplicate posts. The database file scores.sqlite is created automatically on first run.