Repository navigation
feat: add gateway bans, audit logs, and auto moderation - #109
Conversation
◈ PR LensPR Lens paused analysis for this repository — the fair-use limit was reached. It resumes automatically at 2026-09-25T18:00:00.000Z. |
@wolfstar/plugin-api
@wolfstar/plugin-cache
@wolfstar/plugin-gateway
@wolfstar/plugin-i18next
@wolfstar/plugin-logger
@wolfstar/plugin-subcommands-advanced
commit: |
There was a problem hiding this comment.
Important
One correctness bug: GuildAuditLogsEntry#actionType's classification diverges from the discord.js parity it claims.
Reviewed changes
Reviewed the full diff adding gateway bans, audit logs, and auto moderation to @wolfstar/plugin-gateway.
GuildBanManager/GuildBan(guild.bans): list, fetch, create, remove, and bulk-create bans, delegating create/remove to the existing member ban/unban REST calls and caching the banned user alongside the ban.AutoModerationRuleManager/AutoModerationRule(guild.autoModerationRules): fetchAll/create/edit/delete, with discord.js-style trigger setters (setKeywordFilter,setAllowList, ...) that merge into the currenttriggerMetadatasince Discord replaces it wholesale on PATCH.GuildManager#fetchAuditLogs/GuildAuditLogsEntry: fetches a page of the audit log, resolves each entry's executor from the page's users (caching them), and builds the page's webhooks/rules/threads as structures.AutoModerationActionExecution: wraps theAUTO_MODERATION_ACTION_EXECUTIONdispatch with resolved guild/user relations.- Dispatch wiring: adds
guildBanAdd/guildBanRemove,guildAuditLogEntryCreate,autoModerationRuleCreate/Update/Delete, andautoModerationActionExecutiontoDispatchHandlers/GatewayEventMap.
I verified the before/build snapshot ordering for the ban-remove and rule-update handlers against @wolfstar/plugin-cache's actual write/delete ordering (operations.ts), the CachedManager base class, and the guild-scoped manager instantiation convention (Guild.bans/.autoModerationRules match Guild.emojis/.channels) — all correct and consistent with the rest of the codebase.
Claude Sonnet | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues — the new commit is a merge of the stacked base branch (
feat/voice-presence) intofeat/moderation.
The only files it touches (ThreadChannelMemberManager.ts, ThreadManager.ts, tests/threads.test.ts) are outside this PR's diff — every file in this PR's own TOC is byte-identical to what was reviewed at d292c00. The two inline comments from the previous review (GuildAuditLogsEntry.ts actionType classification) still stand.
Claude Sonnet | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed commit 93dec47, which fixes the actionType classification bug flagged in the prior review.
- Un-swapped ban actions:
AuditLogEvent.MemberBanRemovemoved intoCreateActionsandAuditLogEvent.MemberBanAddmoved intoDeleteActions, matching discord.js's actualGuildAuditLogsEntry.actionType()mapping. - Reclassified auto-moderation block:
AuditLogEvent.AutoModerationBlockMessageremoved fromCreateActionsso it now falls through to the default"Update", matching discord.js. - Updated test assertion:
tests/moderation.test.tsnow expects["Delete", "Delete"]for aMemberBanAdd+MemberKickpair (previously incorrectly expected["Create", "Delete"]) — a falsifiable assertion that would catch a regression of this swap.
Both inline threads from the previous review are addressed and resolved. No other issues found.
Claude Sonnet | 𝕏
93dec47 to
fc2b797
Compare
fc2b797 to
26cb1a4
Compare
|
Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an Add repo secret → · Model settings → · Setup docs → · Ask in Discord →
|
26cb1a4 to
70df197
Compare
|
Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an Add repo secret → · Model settings → · Setup docs → · Ask in Discord →
|

Stacked on #108.
🔗 Linked issue
Related to #54 (phase 11a of the roadmap).
🧭 Context
Members could be banned and unbanned, but bans couldn't be listed, and there were no structures for bans, audit logs or auto moderation. The cache already stored bans, rules and audit log entries from the gateway, but their events only reached
raw.📚 Description
Moderation follows discord.js, on the same per-guild manager pattern as emojis and stickers:
GuildBanandguild.bans(client.guilds.bans(guildId)) withlist,fetch,create,removeandbulkCreate. The gateway doesn't send ban reasons, so bans fromguildBanAddhave none.fetch(userId, { force: true })gets it, andguildBanRemoveemits the cached ban, so the reason is included when it was fetched before.guild.fetchAuditLogs({ user, type, before, after, limit })returns a page ofGuildAuditLogsEntrys. Each entry has itsexecutorresolved from the page's users, which are also added to the cache, and discord.js'sactionType. The page also carries its webhooks, rules and threads as structures.AutoModerationRuleandguild.autoModerationRuleswithfetchAll,create,editanddelete. The rule has discord.js's setters. Discord replaces trigger metadata as a whole, so the trigger setters (setKeywordFilter,setAllowList,setPresets, ...) merge their field into the current trigger instead of wiping the rest.AutoModerationActionExecutioncovers executed actions.guildBanAdd,guildBanRemove,guildAuditLogEntryCreate,autoModerationRuleCreate/Update/DeleteandautoModerationActionExecution.Left for later: scheduled events, stage instances, soundboard, templates, welcome screen, widget, onboarding, integrations, and sharding (phase 11b).
Key changes
GuildBan,GuildAuditLogsEntry,AutoModerationRule,AutoModerationActionExecution;Guild#bans/autoModerationRules/fetchAuditLogsGuildBanManager,AutoModerationRuleManager,client.guilds.fetchAuditLogsType of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.