1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 20:30:58 -05:00

Add new automod rule and refactor the existing rules

This commit is contained in:
AnxietyisReal 2024-01-11 09:19:39 +11:00
parent 7f389c3eb9
commit b5fb8bde97
2 changed files with 55 additions and 18 deletions

View File

@ -38,4 +38,9 @@ export default class Automoderator {
data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime); data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime);
} }
} }
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.';
if (io_channels.includes(message.channelId) && message.attachments.size < 1 && message.attachments.every(x=>!x.contentType.includes('image/'))) await message.delete().then(()=>message.channel.send(deleteReason).then((msg:Discord.Message)=>setTimeout(()=>msg.delete(), 8000)));
}
} }

View File

@ -14,12 +14,19 @@ 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.';
if (await client.prohibitedWords.findWord(Automoderator.scanMsg(message))) { const automodRules = {
prohibitedWords: {
check: async()=>await client.prohibitedWords.findWord(Automoderator.scanMsg(message)),
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(), 10000));
await Automoderator.repeatedMessages(client, message, 30000, 3, 'bw', '30m', 'Prohibited word spam'); await Automoderator.repeatedMessages(client, message, 30000, 3, 'bw', '30m', 'Prohibited word spam');
} else if (message.content.toLowerCase().includes('discord.gg/') && !MessageTool.isStaff(message.member as Discord.GuildMember)) { }
},
discordInvite: {
check: async()=>message.content.toLowerCase().includes('discord.gg/') && !MessageTool.isStaff(message.member as Discord.GuildMember),
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);
if (validInvite && validInvite.guild?.id !== client.config.dcServer.id) { if (validInvite && validInvite.guild?.id !== client.config.dcServer.id) {
automodded = true; automodded = true;
@ -28,12 +35,25 @@ export default class MessageCreate {
await Automoderator.repeatedMessages(client, message, 60000, 2, 'adv', '1h', 'Discord advertisement'); await Automoderator.repeatedMessages(client, message, 60000, 2, 'adv', '1h', 'Discord advertisement');
} }
} }
},
imageOnly: {
check: async()=>!MessageTool.isStaff(message.member as Discord.GuildMember),
action: async()=>await Automoderator.imageOnly(message)
} }
};
for (const rule of Object.values(automodRules)) {
if (await rule.check()) {
await rule.action();
break;
}
}
};
if (message.guildId === client.config.dcServer.id && !automodded) client.userLevels.messageIncremental(message.author.id); if (message.guildId === client.config.dcServer.id && !automodded) client.userLevels.messageIncremental(message.author.id);
// Mop gifs from banned channels without admins having to mop them. // Mop gifs from banned channels without admins having to mop them.
const bannedChannels = [] // const bannedChannels = []
if (['tenor.com/view', 'giphy.com/gifs', 'giphy.com/media'].some(e=>message.content.toLowerCase().includes(e)) && bannedChannels.includes(message.channelId)) message.reply('Gifs are not allowed in this channel.').then(()=>message.delete()) // if (['tenor.com/view', 'giphy.com/gifs', 'giphy.com/media'].some(e=>message.content.toLowerCase().includes(e)) && bannedChannels.includes(message.channelId)) message.reply('Gifs are not allowed in this channel.').then(()=>message.delete())
// Autoresponse:tm: // Autoresponse:tm:
if (client.config.botSwitches.autores && !automodded) { if (client.config.botSwitches.autores && !automodded) {
@ -73,10 +93,22 @@ export default class MessageCreate {
title: '*Monster has broken something*', title: '*Monster has broken something*',
} }
]; ];
let dontMention = [
{
user_id: '309373272594579456',
message: 'Please don\'t tag Daggerwin, read rule 14 in <#468846117405196289>',
type: undefined
},
{
user_id: '215497515934416896',
message: 'Please don\'t tag Monster unless it\'s important!',
type: Discord.MessageType.Default
}
]
if (message.type === Discord.MessageType.GuildBoost && message.channelId === GeneralChatID) message.channel.send({content: outgoingArrays.guildBoost[Math.floor(Math.random() * outgoingArrays.guildBoost.length)], allowedMentions: {parse: ['users']}}) if (message.type === Discord.MessageType.GuildBoost && message.channelId === GeneralChatID) message.channel.send({content: outgoingArrays.guildBoost[Math.floor(Math.random() * outgoingArrays.guildBoost.length)], allowedMentions: {parse: ['users']}})
if (message.mentions.members.has('309373272594579456') && !MessageTool.isStaff(message.member)) message.reply('Please don\'t tag Daggerwin, read rule 14 in <#468846117405196289>'); if (dontMention.some(e=>message.mentions.members.has(e.user_id) && !MessageTool.isStaff(message.member)) && (dontMention.find(e => message.mentions.has(e.user_id)).type === undefined || message.type === dontMention.find(e => message.mentions.has(e.user_id)).type)) message.reply(dontMention.find(e=>message.mentions.members.has(e.user_id)).message);
if (message.mentions.members.has('215497515934416896') && !MessageTool.isStaff(message.member) && message.type != Discord.MessageType.Reply) message.reply('Please don\'t tag Monster unless it\'s important!');
if (incomingArrays.password.some(e=>message.content.toLowerCase().includes(e))) message.reply('Password and other details can be found in <#543494084363288637>'); if (incomingArrays.password.some(e=>message.content.toLowerCase().includes(e))) message.reply('Password and other details can be found in <#543494084363288637>');
if (incomingArrays.cantRead.some(e=>message.content.toLowerCase().includes(e))) message.reply(picStorage.cantRead); if (incomingArrays.cantRead.some(e=>message.content.toLowerCase().includes(e))) message.reply(picStorage.cantRead);
if (message.content.toLowerCase().includes('is daggerbot working')) message.reply(picStorage.amAlive); if (message.content.toLowerCase().includes('is daggerbot working')) message.reply(picStorage.amAlive);