Skip to content

Commit 469c477

Browse files
Redditbaraknutsynstad
Redditbara
authored andcommittedDec 15, 2024
Project import generated by Copybara.
GitOrigin-RevId: be44dfe1f220ad3e0184623ff1d62200c14750ff
1 parent 1ac06fd commit 469c477

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["penis", "nigger", "nigga", "nazi", "hitler", "fuck"]

‎packages/apps/pixelary/src/main.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { Router } from './posts/Router.js';
4141
* Triggers
4242
*/
4343
import { appUpgrade } from './triggers/appUpgrade.js';
44+
import { commentCreate } from './triggers/commentCreate.js';
4445
import { commentDelete } from './triggers/commentDelete.js';
4546

4647
/*
@@ -94,5 +95,6 @@ Devvit.addMenuItem(revealWord);
9495

9596
Devvit.addTrigger(appUpgrade);
9697
Devvit.addTrigger(commentDelete);
98+
Devvit.addTrigger(commentCreate);
9799

98100
export default Devvit;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { CommentCreateDefinition } from '@devvit/public-api';
2+
3+
import bannedWords from '../data/bannedWords.json';
4+
5+
export const commentCreate: CommentCreateDefinition = {
6+
event: 'CommentCreate',
7+
onEvent: async (event, context) => {
8+
if (!event.comment) return;
9+
10+
const commentBody = event.comment?.body.toLowerCase() ?? '';
11+
const isSpam = bannedWords.some((bannedWord) => commentBody.includes(bannedWord.toLowerCase()));
12+
13+
if (!isSpam) return;
14+
15+
const comment = await context.reddit.getCommentById(event.comment.id);
16+
await Promise.all([comment.remove(isSpam), comment.lock()]);
17+
},
18+
};

0 commit comments

Comments
 (0)
Please sign in to comment.