feat(sweep): port reaction sweep from bash to TypeScript - #3
Merged
Conversation
The sweep iterates configured verifications, paginates reactors via REST, and grants the role to anyone who reacted but doesn't already hold it. Mirrors the original one-off bash script's grant-only behavior. Sweep-side revocation needs the privileged GuildMembers intent (to enumerate role holders) and lands in step 5 alongside the reaction handlers. - src/sweep.ts: pure runSweep(rest, verification) with a small DiscordRestLike interface for testability - src/rest.ts: discord.js adapter for that interface - src/events/ready.ts: invokes the sweep for each verification on startup when sweep.on_startup is true - src/index.ts: shares the discord.js REST client with the sweep - test/sweep.test.ts: 9 unit tests covering grant/skip/notInGuild/ errors/pagination/mixed-outcomes Also gitignores config/verifications.yaml so the local dev copy with real IDs doesn't get committed. Verified end-to-end against the live verification message: reactors=119, granted=0, alreadyHadRole=92, notInGuild=27, errors=0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
src/sweep.ts— purerunSweep(rest, verification)over a smallDiscordRestLikeinterface; paginates reactors, fetches each member, grants the role when missing. Mirrors the original bash script.src/rest.ts— discord.js adapter forDiscordRestLike(handles theUnknown Membercode 10007 by returningnullinstead of throwing).events/ready.tsso each verification is reconciled on startup whensweep.on_startupis true.client.restwith sweep insrc/index.tsrather than spinning up a second REST instance..gitignorenow excludesconfig/verifications.yamlso the local dev copy with real IDs stays out of commits.Implements step 4 of
docs/exec-plans/v1.md.Test plan
pnpm test— 21 tests pass (9 new intest/sweep.test.ts)pnpm lint,pnpm typecheck,pnpm buildcleanreactors=119, granted=0, alreadyHadRole=92, notInGuild=27, errors=0— confirms the pipeline is idempotent (no duplicate grants on re-run).Follow-ups
GuildMembersprivileged intent (in the Developer Portal) and theGuildMessageReactionsintent, plus the message/channel/reaction partials. Sweep-side revocation can also land then since enumerating role holders requires that intent.🤖 Generated with Claude Code