A template for building Reddit moderation tools using Devvit Web with feature-isolated server modules.
Each moderation capability lives in its own folder under src/features so developers can remove a feature by deleting its folder and unregistering its route wiring.
- Mop Moderation Tool: Moderator menu actions to remove/lock comment trees or all comments in a post.
- Keyword Vote Tallies: Configurable
!keywordvote comments with a sticky tally comment per post. - Banned Words Enforcement: Auto-removes matching posts/comments and sends a modmail notice to the author; subreddit moderators are exempt.
- Weekly Megathread Scheduler: Posts a recurring weekly megathread on a configurable UTC weekday, plus manual mod-triggered creation.
- Flair Updater: Updates user flair on each post/comment event using Redis-backed counts (
posts: X | comments: Y).
- Mop README
- Keyword Votes README
- Banned Words README
- Weekly Megathread Scheduler README
- Flair Updater README
- Devvit: Reddit's platform for building and deploying apps
- Vite: Fast build tool for the web components
- Hono: Lightweight web framework for backend logic
- TypeScript: Type-safe development
- Clone this template or use it as a starting point for your mod tool
- Install dependencies:
npm install
- Configure your app in
devvit.json:- Update the app name
- Set your development subreddit
- Start developing:
npm run dev
- Test your changes in your development subreddit
src/
├── index.ts # Main server setup and route mounting
├── features/
│ ├── mop/
│ │ ├── forms.ts # Mop form handling logic
│ │ ├── menu.ts # Mop form field definitions
│ │ └── nuke.ts # Mop moderation operations
│ ├── keyword-votes/
│ │ ├── README.md
│ │ ├── render.ts # Sticky tally comment rendering
│ │ ├── settings.ts # Keyword settings parsing/validation
│ │ ├── storage.ts # Redis storage for tallies/comment ids
│ │ └── triggers.ts # Post create + comment submit handlers
│ ├── banned-words/
│ │ ├── README.md
│ │ ├── matching.ts # Word/phrase matching rules
│ │ ├── settings.ts # Banned words settings parsing/validation
│ │ └── triggers.ts # Post/comment enforcement + modmail
│ ├── scheduler-megathread/
│ │ ├── README.md
│ │ ├── handlers.ts # Scheduled/manual megathread creation logic
│ │ ├── settings.ts # Megathread settings parsing/validation
│ │ └── storage.ts # Weekly idempotency Redis keys
│ └── flair-updater/
│ ├── README.md
│ ├── settings.ts # Flair updater feature toggle access
│ ├── storage.ts # Redis post/comment counters
│ └── triggers.ts # Post/comment submission handlers
└── routes/
├── api.ts # Public API endpoints (placeholder)
├── forms.ts # Mop form submit route handlers
├── menu.ts # Mop menu route handlers
├── scheduler.ts # Scheduler task endpoints
├── settings.ts # Install setting validation endpoints
└── triggers.ts # App lifecycle/content trigger endpoints
This template is designed to be easily customizable:
- Modify existing actions: Edit the Mop logic in
src/features/mop/. - Add/remove isolated features: Add a folder under
src/features/and wire/unwire it insrc/routes/*anddevvit.json. - Add new menu items: Update
devvit.jsonand add handlers insrc/routes/menu.ts. - Add API endpoints: Extend
src/routes/api.tsfor external integrations.
- Install settings are configured in
devvit.jsonundersettings.subreddit. - Triggers are configured in
devvit.jsonand handled insrc/routes/triggers.ts. - Scheduled jobs are configured in
devvit.json.scheduler.tasksand handled insrc/routes/scheduler.ts. - Feature toggles are checked inside each feature's
settings.ts.
npm run dev: Starts development mode with live reload on your test subredditnpm run build: Builds your mod tool for productionnpm run deploy: Uploads a new version of your app to Redditnpm run launch: Publishes your app for review and public usenpm run login: Authenticates your CLI with Redditnpm run type-check: Runs TypeScript type checking, linting, and formatting
- Permissions: This template requires
redis: trueand Reddit API moderator scope indevvit.json. - User Types: Mop menu items are restricted to
moderator. - Feature isolation: Each feature folder is intentionally self-contained for template portability.
- Test thoroughly in your development subreddit
- Run
npm run deployto upload your app - Use
npm run launchto submit for Reddit's app review process - Once approved, users can install your mod tool from Reddit's app directory
This template provides a modular starting point for building Reddit moderation tools that are easy to extend and easy to remove feature-by-feature.