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:
parent
7f389c3eb9
commit
b5fb8bde97
@ -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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,28 +12,48 @@ 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']}});
|
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;
|
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.';
|
const automodFailReason = 'msg got possibly deleted by another bot.';
|
||||||
if (await client.prohibitedWords.findWord(Automoderator.scanMsg(message))) {
|
const automodRules = {
|
||||||
automodded = true;
|
prohibitedWords: {
|
||||||
message.delete().catch(()=>Logger.console('log', 'AUTOMOD:PROHIBITEDWORDS', automodFailReason));
|
check: async()=>await client.prohibitedWords.findWord(Automoderator.scanMsg(message)),
|
||||||
message.channel.send('That word isn\'t allowed here.').then(x=>setTimeout(()=>x.delete(), 10000));
|
action: async()=>{
|
||||||
await Automoderator.repeatedMessages(client, message, 30000, 3, 'bw', '30m', 'Prohibited word spam');
|
automodded = true;
|
||||||
} else if (message.content.toLowerCase().includes('discord.gg/') && !MessageTool.isStaff(message.member as Discord.GuildMember)) {
|
message.delete().catch(()=>Logger.console('log', 'AUTOMOD:PROHIBITEDWORDS', automodFailReason));
|
||||||
const validInvite = await client.fetchInvite(message.content.split(' ').find(x=>x.includes('discord.gg/'))).catch(()=>null);
|
message.channel.send('That word isn\'t allowed here.').then(x=>setTimeout(()=>x.delete(), 10000));
|
||||||
if (validInvite && validInvite.guild?.id !== client.config.dcServer.id) {
|
await Automoderator.repeatedMessages(client, message, 30000, 3, 'bw', '30m', 'Prohibited word spam');
|
||||||
automodded = true;
|
}
|
||||||
message.delete().catch(()=>Logger.console('log', 'AUTOMOD:ADVERTISEMENT', automodFailReason));
|
},
|
||||||
message.channel.send('Please don\'t advertise other Discord servers.').then(x=>setTimeout(()=>x.delete(), 15000));
|
discordInvite: {
|
||||||
await Automoderator.repeatedMessages(client, message, 60000, 2, 'adv', '1h', 'Discord advertisement');
|
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;
|
||||||
|
message.delete().catch(()=>Logger.console('log', 'AUTOMOD:ADVERTISEMENT', automodFailReason));
|
||||||
|
message.channel.send('Please don\'t advertise other Discord servers.').then(x=>setTimeout(()=>x.delete(), 15000));
|
||||||
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user