mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 20:30:58 -05:00
Get moyai'd.
This commit is contained in:
parent
16a3e1f0d9
commit
9aa486a28c
@ -37,6 +37,25 @@ export default class Automoderator {
|
||||
data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime);
|
||||
}
|
||||
}
|
||||
static isSpam(client:TClient, message:Discord.Message, threshold:number): boolean {
|
||||
const now = Date.now();
|
||||
const time = 30000;
|
||||
|
||||
if (!client.repeatedMessages[message.author.id]) client.repeatedMessages[message.author.id] = {type: 'spam', count: 1, firstTime: now, timeout: null};
|
||||
else {
|
||||
const data = client.repeatedMessages[message.author.id];
|
||||
if (now - data.firstTime < time) {
|
||||
data.count++;
|
||||
if (data.count >= threshold) return true;
|
||||
} else {
|
||||
data.count = 1;
|
||||
data.firstTime = now;
|
||||
}
|
||||
clearTimeout(data.timeout);
|
||||
data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], time);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static async imageOnly(message:Discord.Message) {
|
||||
const io_channels = ['468896467688620032'];
|
||||
let deleteReason:string = 'This is an image-only channel and your message did not contain any images.';
|
||||
|
@ -43,6 +43,17 @@ export default class MessageCreate {
|
||||
await Automoderator.repeatedMessages(client, message, 'mute', 30000, 3, 'bw', '30m', 'Prohibited word spam');
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'messageSpam',
|
||||
check: ()=>Automoderator.isSpam(client, message, 4) && !MessageTool.isStaff(message.member as Discord.GuildMember),
|
||||
action: async()=>{
|
||||
automodded = true;
|
||||
message.delete().catch(()=>Logger.console('log', `${automodLog}MessageSpam`, automodFailReason));
|
||||
message.channel.send('Spamming is not cool, slow down!').then(x=>setTimeout(()=>x.delete(), 15000));
|
||||
await Automoderator.repeatedMessages(client, message, 'mute', 30000, 4, 'spam', '30m', 'Message spam');
|
||||
delete client.repeatedMessages[message.author.id];
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'discordInvite',
|
||||
check: ()=>message.content.toLowerCase().includes('discord.gg/') && !MessageTool.isStaff(message.member as Discord.GuildMember),
|
||||
|
Loading…
Reference in New Issue
Block a user