mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 04:10:59 -05:00
Add new automod rule and refactor the existing rules
This commit is contained in:
parent
12c2714ccf
commit
455b9a2f80
@ -38,4 +38,9 @@ export default class Automoderator {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
@ -12,14 +12,21 @@ export default class MessageCreate {
|
||||
if (!message.inGuild()) return (client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({content: `<:fish_unamused:1083675172407623711> ${MessageTool.formatMention(client.config.whitelist[0], 'user')}\n**${message.author.username}** (\`${message.author.id}\`) tried to send me a DM, their message is:\`\`\`${message.content}\`\`\``, allowedMentions: {parse: ['users']}});
|
||||
let automodded: boolean;
|
||||
|
||||
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.';
|
||||
if (await client.prohibitedWords.findWord(Automoderator.scanMsg(message))) {
|
||||
const automodRules = {
|
||||
prohibitedWords: {
|
||||
check: async()=>await client.prohibitedWords.findWord(Automoderator.scanMsg(message)),
|
||||
action: async()=>{
|
||||
automodded = true;
|
||||
message.delete().catch(()=>Logger.console('log', 'AUTOMOD:PROHIBITEDWORDS', automodFailReason));
|
||||
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');
|
||||
} 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);
|
||||
if (validInvite && validInvite.guild?.id !== client.config.dcServer.id) {
|
||||
automodded = true;
|
||||
@ -28,12 +35,25 @@ export default class MessageCreate {
|
||||
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);
|
||||
// Mop gifs from banned channels without admins having to mop them.
|
||||
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())
|
||||
// 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())
|
||||
|
||||
// Autoresponse:tm:
|
||||
if (client.config.botSwitches.autores && !automodded) {
|
||||
@ -73,10 +93,22 @@ export default class MessageCreate {
|
||||
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.mentions.members.has('309373272594579456') && !MessageTool.isStaff(message.member)) message.reply('Please don\'t tag Daggerwin, read rule 14 in <#468846117405196289>');
|
||||
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 (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 (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 (message.content.toLowerCase().includes('is daggerbot working')) message.reply(picStorage.amAlive);
|
||||
|
Loading…
Reference in New Issue
Block a user