1 |
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 |
} |