1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-12-27 04:15:38 -05:00

Refactor the automodRules

This commit is contained in:
toast-ts 2024-03-26 10:21:47 +11:00
parent 6cf51095ce
commit 02c33a0e64

View File

@ -22,8 +22,9 @@ export default class MessageCreate {
if (client.config.botSwitches.automod && !message.member?.roles.cache.has(client.config.dcServer.roles.dcmod) && !message.member?.roles.cache.has(client.config.dcServer.roles.admin) && message.guildId === client.config.dcServer.id) { if (client.config.botSwitches.automod && !message.member?.roles.cache.has(client.config.dcServer.roles.dcmod) && !message.member?.roles.cache.has(client.config.dcServer.roles.admin) && message.guildId === client.config.dcServer.id) {
const automodFailReason = 'msg got possibly deleted by another bot.'; const automodFailReason = 'msg got possibly deleted by another bot.';
const automodLog = 'Automod:'; const automodLog = 'Automod:';
const automodRules = { const automodRules = [
phishingDetection: { {
name: 'phishingDetection',
check: async()=>await __PRIVATE__.phishingDetection(message), check: async()=>await __PRIVATE__.phishingDetection(message),
action: async()=>{ action: async()=>{
automodded = true; automodded = true;
@ -32,7 +33,8 @@ export default class MessageCreate {
await Automoderator.repeatedMessages(client, message, 'softban', 60000, 3, 'phish', '15m', 'Phishing scam link'); await Automoderator.repeatedMessages(client, message, 'softban', 60000, 3, 'phish', '15m', 'Phishing scam link');
} }
}, },
prohibitedWords: { {
name: 'prohibitedWords',
check: async()=>await client.prohibitedWords.findWord(Automoderator.scanMsg(message)), check: async()=>await client.prohibitedWords.findWord(Automoderator.scanMsg(message)),
action: async()=>{ action: async()=>{
automodded = true; automodded = true;
@ -41,7 +43,8 @@ export default class MessageCreate {
await Automoderator.repeatedMessages(client, message, 'mute', 30000, 3, 'bw', '30m', 'Prohibited word spam'); await Automoderator.repeatedMessages(client, message, 'mute', 30000, 3, 'bw', '30m', 'Prohibited word spam');
} }
}, },
discordInvite: { {
name: 'discordInvite',
check: ()=>message.content.toLowerCase().includes('discord.gg/') && !MessageTool.isStaff(message.member as Discord.GuildMember), check: ()=>message.content.toLowerCase().includes('discord.gg/') && !MessageTool.isStaff(message.member as Discord.GuildMember),
action: async()=>{ action: async()=>{
const validInvite = await client.fetchInvite(message.content.split(' ').find(x=>x.includes('discord.gg/'))).catch(()=>null); const validInvite = await client.fetchInvite(message.content.split(' ').find(x=>x.includes('discord.gg/'))).catch(()=>null);
@ -53,14 +56,15 @@ export default class MessageCreate {
} }
} }
}, },
imageOnly: { {
name: 'imageOnly',
check: ()=>!MessageTool.isStaff(message.member as Discord.GuildMember), check: ()=>!MessageTool.isStaff(message.member as Discord.GuildMember),
action: async()=>await Automoderator.imageOnly(message) action: async()=>await Automoderator.imageOnly(message)
} }
}; ];
for (const rule of Object.values(automodRules)) { for (const rule of automodRules) {
if (!automodded && await rule.check()) { if (!automodded && rule.name && await rule.check()) {
await rule.action(); await rule.action();
break; break;
} }