How it works
Manually onboarding users for paid Sierra Chart studies means editing usernames in Sierra's control panel, keeping a separate list in Discord, and remembering to revoke access when someone leaves. The bot replaces all of it with one auditable workflow driven from Discord.
Self-service onboarding
- A persistent "Fill in Your Sierra Info" button opens a modal where members submit their Sierra Chart username.
- The Discord ↔ Sierra mapping is stored in SQLite; the bot calls Sierra's
CustomDLLStudiesManagementAPI to grant access to the study. - Users can update their username later; API failures roll back the database row so state never diverges.
Kept in sync automatically
- When a member leaves or loses the subscription role, their Sierra access is revoked automatically.
- When a member regains the role, access is restored from the stored mapping.
- Every API call, database change and membership event is logged.
v2 — Multi-tenant, licensed product
The single-server bot proved the workflow; v2 rebuilds it as a product any indicator vendor can use. One bot instance serves many Discord servers, each belonging to a "buyer" who onboards themselves with a license key — bespoke automation turned into per-seat SaaS.
Multi-tenancy & licensing
- A server admin runs
!setup_buyer: a modal collects their Lemon Squeezy license key, Sierra credentials, study name and access roles — validated against the licensing API before anything is persisted. - Anti-key-sharing at the data layer: the first Discord user to redeem a key owns it; reuse across their own servers is allowed, anyone else is rejected.
- License validation cross-checks product and variant IDs, so a key for a cheaper product cannot unlock this one.
Reliability & security
- Sierra admin passwords are encrypted at rest (Fernet); the bot runs as a non-root Docker container targeting AWS Fargate, fully env-driven with fail-fast config validation.
- One stable button identity for every tenant — the buyer is resolved from where the click happened (guild + channel), sidestepping unbounded component growth.
- Compensating writes: if the Sierra API call fails after a local insert, the row is deleted — the database never claims an entitlement the vendor panel doesn't have. On startup the bot self-heals missing registration buttons.