mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-18 00:31:00 -05:00
Add new automod rule
This commit is contained in:
parent
d38d27765e
commit
d6812cb6d3
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,4 +4,5 @@ ips.txt
|
|||||||
.yarn
|
.yarn
|
||||||
# TypeScript stuff
|
# TypeScript stuff
|
||||||
dist
|
dist
|
||||||
|
src/private
|
||||||
src/*.json
|
src/*.json
|
||||||
|
@ -4,7 +4,7 @@ import Logger from '../helpers/Logger.js';
|
|||||||
export default class Automoderator {
|
export default class Automoderator {
|
||||||
private static lockQuery:Set<Discord.Snowflake> = new Set();
|
private static lockQuery:Set<Discord.Snowflake> = new Set();
|
||||||
static scanMsg =(message:Discord.Message)=>message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b/g, '').split(' ').join('');
|
static scanMsg =(message:Discord.Message)=>message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b/g, '').split(' ').join('');
|
||||||
static async repeatedMessages(client:TClient, message:Discord.Message, action:'mute'|'ban', thresholdTime:number, thresholdAmount:number, type:string, duration:string, reason:string) {
|
static async repeatedMessages(client:TClient, message:Discord.Message, action:'mute'|'ban'|'softban', thresholdTime:number, thresholdAmount:number, type:string, duration:string, reason:string) {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
if (!client.repeatedMessages[message.author.id]) client.repeatedMessages[message.author.id] = {type: type, count:1, firstTime:now, timeout: null};
|
if (!client.repeatedMessages[message.author.id]) client.repeatedMessages[message.author.id] = {type: type, count:1, firstTime:now, timeout: null};
|
||||||
|
@ -5,6 +5,7 @@ import CmdTrigger from '../modules/CmdModule.js';
|
|||||||
import Logger from '../helpers/Logger.js';
|
import Logger from '../helpers/Logger.js';
|
||||||
import ConfigHelper from '../helpers/ConfigHelper.js';
|
import ConfigHelper from '../helpers/ConfigHelper.js';
|
||||||
import Automoderator from '../components/Automod.js';
|
import Automoderator from '../components/Automod.js';
|
||||||
|
import __PRIVATE from '../private/_.js';
|
||||||
import MessageTool from '../helpers/MessageTool.js';
|
import MessageTool from '../helpers/MessageTool.js';
|
||||||
export default class MessageCreate {
|
export default class MessageCreate {
|
||||||
static async run(client:TClient, message:Discord.Message) {
|
static async run(client:TClient, message:Discord.Message) {
|
||||||
@ -15,12 +16,21 @@ 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 automodRules = {
|
const automodRules = {
|
||||||
|
phishingDetection: {
|
||||||
|
check: async()=>await __PRIVATE.phishingDetection(message),
|
||||||
|
action: async()=>{
|
||||||
|
automodded = true;
|
||||||
|
message.delete().catch(()=>Logger.console('log', 'AUTOMOD:PHISHING', automodFailReason));
|
||||||
|
message.channel.send('Phishing links aren\'t allowed here. Nice try though!').then(msg=>setTimeout(()=>msg.delete(), 15000));
|
||||||
|
await Automoderator.repeatedMessages(client, message, 'softban', 60000, 2, 'phish', null, 'Phishing/scam link');
|
||||||
|
}
|
||||||
|
},
|
||||||
prohibitedWords: {
|
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;
|
||||||
message.delete().catch(()=>Logger.console('log', 'AUTOMOD:PROHIBITEDWORDS', automodFailReason));
|
message.delete().catch(()=>Logger.console('log', 'AUTOMOD:PROHIBITEDWORDS', automodFailReason));
|
||||||
message.channel.send('That word isn\'t allowed here.').then(x=>setTimeout(()=>x.delete(), 10000));
|
message.channel.send('That word isn\'t allowed here.').then(x=>setTimeout(()=>x.delete(), 15000));
|
||||||
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');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -108,7 +108,6 @@ client.on('raw', async (packet:RawGatewayPacket<RawMessageUpdate>)=>{
|
|||||||
const channel = client.channels.cache.get(packet.d.channel_id) as Discord.TextBasedChannel;
|
const channel = client.channels.cache.get(packet.d.channel_id) as Discord.TextBasedChannel;
|
||||||
const old_message = await channel.messages.fetch(packet.d.id);
|
const old_message = await channel.messages.fetch(packet.d.id);
|
||||||
const new_message = await channel.messages.fetch(packet.d.id);
|
const new_message = await channel.messages.fetch(packet.d.id);
|
||||||
if (old_message.content === new_message.content) return;
|
|
||||||
|
|
||||||
client.emit('messageUpdate', old_message, new_message);
|
client.emit('messageUpdate', old_message, new_message);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user