Web-based config editor setup#54
Merged
Merged
Conversation
Two additions to the config schema, both in service of an upcoming
sibling `azalea-editor` web service. Both are optional / inert from
the bot's perspective — the bot does not consume either.
- New `Permission.ManageGuildConfig = "manage_guild_config"`. The
editor will gate config-edit access by checking this permission
via the same role-based pattern the bot already uses
(`GuildConfig.hasPermission`).
- New optional `preview` block on the global config:
preview:
test_channel_id: <snowflake>
test_webhook_url: https://discord.com/api/webhooks/<id>/<token>
Both fields are optional and validated independently. Webhook URL
validation matches the standard `discord.com` / `discordapp.com`
shape so typos surface at parse time rather than at the moment a
preview is requested. The editor reads these fields to power its
"Test in Discord" button; preview is only enabled when both are
set.
…tion
Add a tiny localhost-only HTTP listener (Bun.serve, no new deps) so
the sibling `azalea-editor` service can detect a successful pm2
reload. The editor uses this signal to decide whether a config save
succeeded or needs to be rolled back.
- `src/utils/health.ts`: starts the listener at module load and
returns `{ markReady, startedAt }`. `startedAt` is the ISO
timestamp captured when the process boots; the editor compares
it against the value seen pre-reload to confirm it's looking at
the new process. PM2's own `restart_time` and `online` status
are insufficient — they flip before ClientReady fires.
- `src/index.ts`: imports and starts the server before any other
startup work so the editor can reach it the moment the new
process spawns.
- `src/events/Ready.ts`: calls `health.markReady()` only after
every cron job (scheduled messages, review reminders, report
removal) is mounted. A 200 with `ready: true` therefore means
the bot is fully operational, not merely logged in.
- `.env.example`: documents the optional `HEALTH_HOST` /
`HEALTH_PORT` overrides. Defaults to 127.0.0.1:7475; the
endpoint must never be exposed beyond loopback.
- `tests/health.test.ts`: covers the ready transition,
startedAt persistence, and 404 for unknown paths.
The sibling editor's "Send to test channel" feature was removed, so the only consumer of `globalConfigSchema.preview` is gone. Drop the field, its `webhookUrlSchema` regex, and the corresponding YAML example in the README. Add `configs/.backups` to .gitignore so the editor's runtime config backups never accidentally land in commits, and tag VIRUSTOTAL_API_KEY as optional in .env.example for parity with the other secondary integrations. `Permission.ManageGuildConfig` stays — the editor still uses it as the per-guild access gate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.