No description
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m9s
|
||
---|---|---|
.forgejo/workflows | ||
.vscode | ||
src | ||
.env.example | ||
.gitignore | ||
biome.json | ||
bun.lock | ||
Dockerfile | ||
package.json | ||
README.md | ||
tsconfig.json |
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
- Bun runtime installed
- Discord bot token from Discord Developer Portal
- osu! API credentials from osu! settings
Installation
- Clone the repository:
git clone <repository-url>
cd osu-discord-bot
- Install dependencies:
bun install
- Create a
.env
file by copying the example:
cp .env.example .env
- 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.