šŸ¤– Roblox Auto-Rank Bot

An API bot that automatically ranks members in your Roblox group based on configurable rules.

Features

  • Manual Ranking — Rank any member via API
  • Auto-Ranking — Scheduled interval that promotes members based on time-in-group rules
  • Rule Management — Add/remove ranking rules via API
  • Action Logging — Every rank change is logged with timestamps

Setup

1. Get a Roblox Open Cloud API Key

  1. Go to https://create.roblox.com/dashboard/credentials
  2. Create a new API key
  3. Add the Groups resource with Read and Write permissions
  4. Select your group
  5. Copy the API key

2. Set Environment Variables

šŸ‘‰ Add ROBLOX_API_KEY here: https://www.val.town/x/jamesdopp/API/environment-variables?key=ROBLOX_API_KEY

šŸ‘‰ Add ROBLOX_GROUP_ID here: https://www.val.town/x/jamesdopp/API/environment-variables?key=ROBLOX_GROUP_ID

šŸ‘‰ Add API_SECRET here (optional, protects write endpoints): https://www.val.town/x/jamesdopp/API/environment-variables?key=API_SECRET

3. Set Up Auto-Rank Schedule

The auto-rank.ts interval runs on a schedule. Configure it in the Val Town UI or via the interval settings.

API Reference

GET / — API Info

Returns group details and available endpoints.

GET /roles — List Group Roles

Returns all roles in your group with their IDs and names.

GET /members — List Group Members

Returns all members with their user IDs, current roles, and join dates.

POST /rank — Manually Rank a User

{ "userId": "123456789", "roleId": "role_id_from_/roles" }

GET /rules — List Ranking Rules

Returns all configured auto-ranking rules.

POST /rules — Add a Ranking Rule

{ "sourceRoleId": "current_role_id", "targetRoleId": "target_role_id", "minDaysInGroup": 7 }

This means: If a member has the source role and has been in the group for 7+ days, promote them to the target role.

DELETE /rules/:id — Delete a Ranking Rule

POST /auto-rank — Trigger Auto-Ranking Manually

Runs the auto-ranking engine immediately and returns results.

GET /logs?limit=50 — View Ranking Logs

Returns recent ranking actions.

How Auto-Ranking Works

  1. The interval fetches all group roles and members
  2. For each member, it checks enabled rules sorted by minDaysInGroup (highest first)
  3. If a member's current role matches a rule's source role AND they've been in the group long enough → they get promoted
  4. Every promotion is logged in SQLite

Example: Promote members after 7 days

  1. Call GET /roles to find your role IDs
  2. Call POST /rules with the "Member" role as source, "Veteran" role as target, and minDaysInGroup: 7
  3. The auto-rank interval will automatically promote eligible members

Architecture

main.ts       → HTTP API (Hono) — manual ranking, rules, logs
auto-rank.ts  → Interval — scheduled auto-promotion engine
roblox.ts     → Roblox Open Cloud API helper
db.ts         → SQLite for rules & logs