Project index/02 — TypeScript
Case study / 02In development

Valor.

A TypeScript Discord bot for reviewing requests and managing Roblox group roles through validated commands.

CategoryTypeScript
FocusDiscord bot and Roblox Open Cloud integration
TechnologyTypeScript / discord.js / Roblox Open Cloud / Zod
StatusIn development
01 / Overview

Why it exists

Put identity, rank, target, and API checks around staff-facing role changes.

A Discord command can cause a Roblox group write, so the executor, target, current role, and failure path need explicit handling.

Based on the code in the private Valor repo.

02 / System

How it works

  1. 01

    Receive command

    Slash-command modules parse a staff action such as promote, demote, accept, inspect, or exile.

  2. 02

    Resolve identities

    The command resolves a Discord member and the corresponding Roblox user and membership.

  3. 03

    Authorize

    Rank, self-targeting, and target hierarchy checks run before a role-changing operation.

  4. 04

    Call Roblox

    RobloxClient handles Open Cloud requests, bounded retries, timeouts, and rate-limit responses.

  5. 05

    Respond and audit

    CommandResponse returns an outcome while audit and error paths record the attempted operation.

03 / Code

Selected code

These excerpts are from the paths shown on each patch. Select an annotation for a focused note; copy code directly from each patch.

typescript / source excerpt

Authorise.ts

src/backend/authorization/Authorise.ts

The command authorization module prevents self-targeting and equal-or-higher-rank targets before a role operation.

Notes on the patch
04 / Decisions

Engineering decisions

01

Composable authorization

Reason
Reusable conditions keep rank and target checks visible at command boundaries.
Alternative
Rely on Discord command visibility alone.
Tradeoff
Each command must assemble the conditions it needs.
02

Bounded API retries

Reason
RobloxClient retries network failures and 429/5xx responses within a fixed attempt limit.
Alternative
Fail every transient response immediately.
Tradeoff
Retries add latency and do not guarantee a successful write.
05 / Reflection

Outcome & next steps

Outcome

The source implements modular commands, authorization conditions, a Roblox API client, health checks, and audit handling.

What improved

The role-changing commands put target and hierarchy checks before external writes.

Current limitations

  • The repository states that it has typecheck and build validation but no automated test or lint script.
  • A successful live role write was not verified in this audit.

Future improvements

  • Add automated command and Roblox-client tests using mocked API responses.

What this demonstrates

Typed Discord command boundaries, authorization, and defensive third-party API handling.

Continue readingZone System