Database Schema
Kiba Bot uses SQLite with WAL journaling and foreign keys enabled. The database file is stored at the path specified by DATABASE_PATH (default: /app/data/kiba.db).
users
| Column | Type | Default | Description |
discord_id | TEXT (PK) | - | Discord user snowflake ID |
code | TEXT (UNIQUE) | - | 4-char alphanumeric code |
roblox_username | TEXT | NULL | Bound Roblox username |
roblox_user_id | TEXT | NULL | Bound Roblox numeric user ID |
is_banned | INTEGER | 0 | 0 = active, 1 = banned |
ban_reason | TEXT | NULL | Reason for ban |
is_paused | INTEGER | 0 | 0 = active, 1 = paused |
rebind_count | INTEGER | 0 | Number of rebinds used (max 3) |
is_invalidated | INTEGER | 0 | 0 = valid, 1 = invalidated |
created_at | TEXT | - | ISO 8601 timestamp of code creation |
join_date | TEXT | - | ISO 8601 timestamp of Discord server join |
last_snapshot_at | TEXT | NULL | ISO 8601 timestamp of last RPC read |
code_history
| Column | Type | Description |
id | INTEGER (PK) | Auto-increment |
discord_id | TEXT | Discord user snowflake ID |
code | TEXT | The code that was issued |
issued_at | TEXT | ISO 8601 timestamp |
/rotate prunes this table to the last 5 entries per discord_id.
action_log
| Column | Type | Description |
id | INTEGER (PK) | Auto-increment |
discord_id | TEXT | Discord user snowflake ID |
action | TEXT | Action type: rebind, rotate, ban, unban, delete, invalidated |
details | TEXT | Human-readable description |
performed_by | TEXT | Discord ID of the operator, or "system" |
timestamp | TEXT | ISO 8601 timestamp |
infractions
Stores trusted safety event records tied to a linked user when the game server sends a code with the event.
| Column | Type | Description |
id | INTEGER (PK) | Auto-increment |
discord_id | TEXT | Discord user snowflake ID |
roblox_user_id | TEXT | Roblox user ID |
infraction_type | TEXT | Safety event type label |
description | TEXT | Description of the event |
issued_by | TEXT | Source that issued the event |
timestamp | TEXT | ISO 8601 timestamp |
webhook_config
| Column | Type | Description |
id | INTEGER (PK) | Auto-increment |
category | TEXT (UNIQUE) | Private event route key |
webhook_url | TEXT | Private Discord webhook URL |
set_by | TEXT | Discord ID of the operator |
set_at | TEXT | ISO 8601 timestamp |
server_config
| Column | Type | Description |
server_id | TEXT (PK) | Discord guild snowflake ID |
is_whitelisted | INTEGER | 0 = not whitelisted, 1 = whitelisted |
whitelisted_by | TEXT | Discord ID of the operator |
whitelisted_at | TEXT | ISO 8601 timestamp |
channel_config
| Column | Type | Description |
id | INTEGER (PK) | Auto-increment |
guild_id | TEXT | Discord guild snowflake ID |
channel_id | TEXT (UNIQUE) | Discord channel snowflake ID |
is_allowed | INTEGER | 0 = disallowed, 1 = allowed |
set_by | TEXT | Discord ID of the operator |
set_at | TEXT | ISO 8601 timestamp |