/[sudobot]/branches/8.x/extensions/antirickroll/src/services/AntiRickRollService.ts
ViewVC logotype

Annotation of /branches/8.x/extensions/antirickroll/src/services/AntiRickRollService.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months, 1 week ago) by rakinar2
File MIME type: application/typescript
File size: 785 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 import Service from "@sudobot/core/Service";
2     import { Message } from "discord.js";
3     import { rickrolls } from "../../resources/rickrolls.json";
4     export const name = "antiRickRollService";
5    
6     export default class AntiRickRollService extends Service {
7     protected readonly rickrolls = rickrolls;
8    
9     public async containsRickRoll(content: string): Promise<boolean> {
10     for (const rickroll of this.rickrolls) {
11     if (content.includes(rickroll)) {
12     return true;
13     }
14     }
15    
16     return false;
17     }
18    
19     public async scanMessage(message: Message): Promise<void> {
20     if (!message.deletable) {
21     return;
22     }
23    
24     if (await this.containsRickRoll(message.content)) {
25     await message.delete();
26     }
27     }
28     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26