mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 12:21:00 -05:00
Glad I didn't pull the untested changes to main bot.
This commit is contained in:
parent
3ce1f09a7d
commit
74c9dc0ebd
@ -16,6 +16,7 @@ export default {
|
||||
|
||||
if (client.bannedWords._content.some((x)=>msgarr.includes(x)) && !message.member.roles.cache.has(client.config.mainServer.roles.dcmod) && message.guildId == client.config.mainServer.id && !Whitelist.includes(message.channelId) && client.config.botSwitches.automod){
|
||||
automodded = true;
|
||||
const threshold = 30000;
|
||||
message.delete().catch(err=>console.log('bannedWords automod; msg got possibly deleted by another bot.'))
|
||||
message.channel.send('That word is banned here.').then((x)=>setTimeout(()=>x.delete(), 5000));
|
||||
if (client.repeatedMessages[message.author.id]){
|
||||
@ -24,10 +25,7 @@ export default {
|
||||
|
||||
// reset timeout
|
||||
clearTimeout(client.repeatedMessages[message.author.id].timeout);
|
||||
client.repeatedMessages[message.author.id].timeout = setTimeout(onTimeout, 30000);
|
||||
|
||||
// this is the time in which 4 messages have to be sent, in milliseconds (ms)
|
||||
const threshold = 30000;
|
||||
client.repeatedMessages[message.author.id].timeout = setTimeout(onTimeout, threshold);
|
||||
|
||||
// message mustve been sent after (now - threshold), so purge those that were sent earlier
|
||||
client.repeatedMessages[message.author.id].data = client.repeatedMessages[message.author.id].data.filter((x, i)=>i >= Date.now() - threshold)
|
||||
@ -39,41 +37,39 @@ export default {
|
||||
|
||||
// if a spammed message exists;
|
||||
if (spammedMessage){
|
||||
// mute
|
||||
await client.punishments.addPunishment('mute', { time: '30m' }, (client.user as Discord.User).id, 'Automod; Banned words', message.author, message.member as Discord.GuildMember);
|
||||
// clear their list of long messages
|
||||
delete client.repeatedMessages[message.author.id];
|
||||
await client.punishments.addPunishment('mute', { time: '30m' }, (client.user as Discord.User).id, 'Automod; Banned words', message.author, message.member as Discord.GuildMember);
|
||||
}
|
||||
} else {
|
||||
client.repeatedMessages[message.author.id] = new client.collection();
|
||||
client.repeatedMessages[message.author.id] = {data: new client.collection(), timeout: setTimeout(onTimeout, threshold)}
|
||||
client.repeatedMessages[message.author.id].data.set(message.createdTimestamp, {cont: 0, ch: message.channelId});
|
||||
// autodelete after 30 secs
|
||||
client.repeatedMessages[message.author.id].timeout = setTimeout(onTimeout, 30000);
|
||||
client.repeatedMessages[message.author.id].timeout = setTimeout(onTimeout, threshold);
|
||||
}
|
||||
}
|
||||
if (message.content.toLowerCase().includes('discord.gg/') && !message.member.roles.cache.has(client.config.mainServer.roles.dcmod) && message.guildId == client.config.mainServer.id && !Whitelist.includes(message.channelId)) {
|
||||
automodded = true;
|
||||
const threshold = 60000;
|
||||
message.delete().catch(err=>console.log('advertisement automod; msg got possibly deleted by another bot.'))
|
||||
message.channel.send('Advertising other Discord servers is not allowed.').then(x=>setTimeout(()=>x.delete(), 10000))
|
||||
if (client.repeatedMessages[message.author.id]){
|
||||
client.repeatedMessages[message.author.id].data.set(message.createdTimestamp,{cont:1,ch:message.channelId});
|
||||
|
||||
clearTimeout(client.repeatedMessages[message.author.id].timeout);
|
||||
client.repeatedMessages[message.author.id].timeout = setTimeout(onTimeout, 60000);
|
||||
const threshold = 60000;
|
||||
client.repeatedMessages[message.author.id].timeout = setTimeout(onTimeout, threshold);
|
||||
client.repeatedMessages[message.author.id].data = client.repeatedMessages[message.author.id].data.filter((x, i)=> i >= Date.now() - threshold)
|
||||
const spammedMessage = client.repeatedMessages[message.author.id]?.data.find((x)=>{
|
||||
const spammedMessage = client.repeatedMessages[message.author.id].data.find((x)=>{
|
||||
return client.repeatedMessages[message.author.id].data.filter((y)=>x.cont === y.cont).size >= 4;
|
||||
});
|
||||
|
||||
if (spammedMessage){
|
||||
await client.punishments.addPunishment('mute', {time: '1h'}, (client.user as Discord.User).id, 'Automod; Discord advertisement', message.author, message.member as Discord.GuildMember);
|
||||
delete client.repeatedMessages[message.author.id];
|
||||
await client.punishments.addPunishment('mute', {time: '1h'}, (client.user as Discord.User).id, 'Automod; Discord advertisement', message.author, message.member as Discord.GuildMember);
|
||||
}
|
||||
}else{
|
||||
client.repeatedMessages[message.author.id] = new client.collection();
|
||||
client.repeatedMessages[message.author.id].data.set(message.createdTimestamp, {cont: 1, ch: message.channelId});
|
||||
client.repeatedMessages[message.author.id].timeout = setTimeout(onTimeout, 60000);
|
||||
client.repeatedMessages[message.author.id].timeout = setTimeout(onTimeout, threshold);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user